本文整理匯總了Golang中github.com/lxc/lxd.Client.ProfileDeviceDelete方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.ProfileDeviceDelete方法的具體用法?Golang Client.ProfileDeviceDelete怎麽用?Golang Client.ProfileDeviceDelete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lxc/lxd.Client
的用法示例。
在下文中一共展示了Client.ProfileDeviceDelete方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: doNetworkDetachProfile
func (c *networkCmd) doNetworkDetachProfile(client *lxd.Client, name string, args []string) error {
if len(args) < 1 || len(args) > 2 {
return errArgs
}
profileName := args[0]
devName := ""
if len(args) > 1 {
devName = args[1]
}
profile, err := client.ProfileConfig(profileName)
if err != nil {
return err
}
if devName == "" {
for n, d := range profile.Devices {
if d["type"] == "nic" && d["parent"] == name {
if devName != "" {
return fmt.Errorf(i18n.G("More than one device matches, specify the device name."))
}
devName = n
}
}
}
if devName == "" {
return fmt.Errorf(i18n.G("No device found for this network"))
}
device, ok := profile.Devices[devName]
if !ok {
return fmt.Errorf(i18n.G("The specified device doesn't exist"))
}
if device["type"] != "nic" || device["parent"] != name {
return fmt.Errorf(i18n.G("The specified device doesn't match the network"))
}
_, err = client.ProfileDeviceDelete(profileName, devName)
return err
}