本文整理匯總了Golang中github.com/lxc/lxd.Client.ContainerDeviceDelete方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.ContainerDeviceDelete方法的具體用法?Golang Client.ContainerDeviceDelete怎麽用?Golang Client.ContainerDeviceDelete使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lxc/lxd.Client
的用法示例。
在下文中一共展示了Client.ContainerDeviceDelete方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: doNetworkDetach
func (c *networkCmd) doNetworkDetach(client *lxd.Client, name string, args []string) error {
if len(args) < 1 || len(args) > 2 {
return errArgs
}
containerName := args[0]
devName := ""
if len(args) > 1 {
devName = args[1]
}
container, err := client.ContainerInfo(containerName)
if err != nil {
return err
}
if devName == "" {
for n, d := range container.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 := container.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"))
}
resp, err := client.ContainerDeviceDelete(containerName, devName)
if err != nil {
return err
}
return client.WaitForSuccess(resp.Operation)
}