From a80d7870eff50654fba18494bf4e7b4d35246929 Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Sat, 22 Dec 2018 00:09:56 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0climc=20eip-change-owner?= =?UTF-8?q?=E5=91=BD=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/climc/shell/elasticips.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/cmd/climc/shell/elasticips.go b/cmd/climc/shell/elasticips.go index 4f59a26f03..8c0a36269b 100644 --- a/cmd/climc/shell/elasticips.go +++ b/cmd/climc/shell/elasticips.go @@ -186,4 +186,29 @@ func init() { return nil }) + type EipChangeOwnerOptions struct { + ID string `help:"EIP to change owner"` + PROJECT string `help:"Project ID or change"` + RawId bool `help:"User raw ID, instead of name"` + } + R(&EipChangeOwnerOptions{}, "eip-change-owner", "Change owner porject of a eip", func(s *mcclient.ClientSession, opts *EipChangeOwnerOptions) error { + params := jsonutils.NewDict() + if opts.RawId { + projid, err := modules.Projects.GetId(s, opts.PROJECT, nil) + if err != nil { + return err + } + params.Add(jsonutils.NewString(projid), "tenant") + params.Add(jsonutils.JSONTrue, "raw_id") + } else { + params.Add(jsonutils.NewString(opts.PROJECT), "tenant") + } + srv, err := modules.Elasticips.PerformAction(s, opts.ID, "change-owner", params) + if err != nil { + return err + } + printObject(srv) + return nil + }) + }