mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix: server-change-ipaddr may ignore errors when changing ipaddr
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user