func addNetworkDeviceToProfile(client *lxdclient.Client, profile, parentDevice, deviceName, hwAddr string, mtu int) (*lxd.Response, error) { props, err := nicProperties(parentDevice, deviceName, hwAddr, mtu) if err != nil { return nil, errors.Trace(err) } logger.Infof("adding nic device %q with properties %+v to profile %q", deviceName, props, profile) return client.ProfileDeviceAdd(profile, deviceName, "nic", props) }
func createNetworkProfile(client *lxdclient.Client, profile string) error { found, err := client.HasProfile(profile) if err != nil { return errors.Trace(err) } if found { logger.Infof("deleting existing container profile %q", profile) if err := client.ProfileDelete(profile); err != nil { return errors.Trace(err) } } err = client.CreateProfile(profile, nil) if err == nil { logger.Infof("created new network container profile %q", profile) } return errors.Trace(err) }