fix: server-change-ipaddr may ignore errors when changing ipaddr

This commit is contained in:
Qiu Jian
2019-07-15 22:54:40 +08:00
parent edb1de5072
commit c8f17ac392
16 changed files with 189 additions and 42 deletions
+6 -1
View File
@@ -21,6 +21,7 @@ import (
"yunion.io/x/jsonutils"
"yunion.io/x/pkg/util/regutils"
"yunion.io/x/onecloud/pkg/cloudcommon/cmdline"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/mcclient/modules"
"yunion.io/x/onecloud/pkg/mcclient/options"
@@ -220,7 +221,11 @@ func init() {
} else {
return fmt.Errorf("Please specify Ip or Mac")
}
params.Add(jsonutils.NewString(args.NETDESC), "net_desc")
conf, err := cmdline.ParseNetworkConfig(args.NETDESC, 0)
if err != nil {
return err
}
params.Add(conf.JSON(conf), "net_desc")
srv, err := modules.Servers.PerformAction(s, args.SERVER, "change-ipaddr", params)
if err != nil {
return err
+25
View File
@@ -984,4 +984,29 @@ func init() {
printObject(result)
return nil
})
R(&options.ServerIdOptions{}, "server-remote-nics", "Show remote nics of a server", func(s *mcclient.ClientSession, opts *options.ServerIdOptions) error {
result, err := modules.Servers.GetSpecific(s, opts.ID, "remote-nics", nil)
if err != nil {
return err
}
listResult := modules.ListResult{}
listResult.Data, _ = result.GetArray()
printList(&listResult, nil)
return nil
})
type ServerSyncFixNicsOptions struct {
ID string `help:"ID or name of VM" json:"-"`
IP []string `help:"IP address of each NIC" json:"ip"`
}
R(&ServerSyncFixNicsOptions{}, "server-sync-fix-nics", "Fix missing IP for each nics after syncing VNICS", func(s *mcclient.ClientSession, opts *ServerSyncFixNicsOptions) error {
params := jsonutils.Marshal(opts)
result, err := modules.Servers.PerformAction(s, opts.ID, "sync-fix-nics", params)
if err != nil {
return err
}
printObject(result)
return nil
})
}