lxc/utils.go
func containerDeviceAdd(client lxd.ContainerServer, name string, devName string, dev map[string]string) error {
	// Get the container entry
	container, etag, err := client.GetContainer(name)
	if err != nil {
		return err
	}

	// Check if the device already exists
	_, ok := container.Devices[devName]
	if ok {
		return fmt.Errorf(i18n.G("Device already exists: %s"), devName)
	}

	container.Devices[devName] = dev

	op, err := client.UpdateContainer(name, container.Writable(), etag)
	if err != nil {
		return err
	}

	return op.Wait()
}
func containerDeviceAdd(client lxd.ContainerServer, name string, devName string, dev map[string]string) error {
	// Get the container entry
	container, etag, err := client.GetContainer(name)
	if err != nil {
		return err
	}

	// Check if the device already exists
	_, ok := container.Devices[devName]
	if ok {
		return fmt.Errorf(i18n.G("Device already exists: %s"), devName)
	}

	container.Devices[devName] = dev

	op, err := client.UpdateContainer(name, container.Writable(), etag)
	if err != nil {
		return err
	}

	return op.Wait()
}
func containerDeviceAdd ( client lxd . ContainerServer , name string , devName string , dev map [ string ] string ) error { // Get the container entry container , etag , err := client . GetContainer ( name ) if err != nil { return err } // Check if the device already exists _ , ok := container . Devices [ devName ] if ok { return fmt . Errorf ( i18n . G ( " " ) , devName ) } container . Devices [ devName ] = dev op , err := client . UpdateContainer ( name , container . Writable ( ) , etag ) if err != nil { return err } return op . Wait ( ) }
// Add a device to a container
Add a device to a container