当前位置: 首页>>代码示例>>Golang>>正文


Golang lxd.Client类代码示例

本文整理汇总了Golang中github.com/lxc/lxd.Client的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: doProfileDelete

func (c *profileCmd) doProfileDelete(client *lxd.Client, p string) error {
	err := client.ProfileDelete(p)
	if err == nil {
		fmt.Printf(i18n.G("Profile %s deleted")+"\n", p)
	}
	return err
}
开发者ID:vahe,项目名称:lxd,代码行数:7,代码来源:profile.go

示例2: doProfileCreate

func doProfileCreate(client *lxd.Client, p string) error {
	err := client.ProfileCreate(p)
	if err == nil {
		fmt.Printf(gettext.Gettext("Profile %s created\n"), p)
	}
	return err
}
开发者ID:rrva,项目名称:lxd,代码行数:7,代码来源:profile.go

示例3: dereferenceAlias

func (c *imageCmd) dereferenceAlias(d *lxd.Client, inName string) string {
	result := d.GetAlias(inName)
	if result == "" {
		return inName
	}
	return result
}
开发者ID:vahe,项目名称:lxd,代码行数:7,代码来源:image.go

示例4: doProfileSet

func doProfileSet(client *lxd.Client, p string, args []string) error {
	// we shifted @args so so it should read "<key> [<value>]"
	if len(args) < 1 {
		return errArgs
	}

	key := args[0]
	var value string
	if len(args) < 2 {
		value = ""
	} else {
		value = args[1]
	}

	if !terminal.IsTerminal(syscall.Stdin) && value == "-" {
		buf, err := ioutil.ReadAll(os.Stdin)
		if err != nil {
			return fmt.Errorf("Can't read from stdin: %s", err)
		}
		value = string(buf[:])
	}

	err := client.SetProfileConfigItem(p, key, value)
	return err
}
开发者ID:achanda,项目名称:lxd,代码行数:25,代码来源:profile.go

示例5: doProfileDelete

func doProfileDelete(client *lxd.Client, p string) error {
	err := client.ProfileDelete(p)
	if err == nil {
		fmt.Printf(gettext.Gettext("Profile %s deleted")+"\n", p)
	}
	return err
}
开发者ID:achanda,项目名称:lxd,代码行数:7,代码来源:profile.go

示例6: doProfileCreate

func doProfileCreate(client *lxd.Client, p string) error {
	err := client.ProfileCreate(p)
	if err == nil {
		fmt.Printf(i18n.G("Profile %s created")+"\n", p)
	}
	return err
}
开发者ID:mickydelfavero,项目名称:lxd,代码行数:7,代码来源:profile.go

示例7: doNetworkAttachProfile

func (c *networkCmd) doNetworkAttachProfile(client *lxd.Client, name string, args []string) error {
	if len(args) < 1 || len(args) > 2 {
		return errArgs
	}

	profile := args[0]
	devName := name
	if len(args) > 1 {
		devName = args[1]
	}

	network, err := client.NetworkGet(name)
	if err != nil {
		return err
	}

	nicType := "macvlan"
	if network.Type == "bridge" {
		nicType = "bridged"
	}

	props := []string{fmt.Sprintf("nictype=%s", nicType), fmt.Sprintf("parent=%s", name)}
	_, err = client.ProfileDeviceAdd(profile, devName, "nic", props)
	return err
}
开发者ID:vahe,项目名称:lxd,代码行数:25,代码来源:network.go

示例8: doProfileRemove

func (c *profileCmd) doProfileRemove(client *lxd.Client, d string, p string) error {
	ct, err := client.ContainerInfo(d)
	if err != nil {
		return err
	}

	if !shared.StringInSlice(p, ct.Profiles) {
		return fmt.Errorf("Profile %s isn't currently applied to %s", p, d)
	}

	profiles := []string{}
	for _, profile := range ct.Profiles {
		if profile == p {
			continue
		}

		profiles = append(profiles, profile)
	}

	ct.Profiles = profiles

	err = client.UpdateContainerConfig(d, ct.Brief())
	if err != nil {
		return err
	}

	fmt.Printf(i18n.G("Profile %s removed from %s")+"\n", p, d)

	return err
}
开发者ID:vahe,项目名称:lxd,代码行数:30,代码来源:profile.go

示例9: getContainerState

func getContainerState(client *lxd.Client, name string) *shared.ContainerState {
	ct, err := client.ContainerState(name)
	if err != nil {
		return nil
	}
	return ct
}
开发者ID:yobert,项目名称:terraform-provider-lxd,代码行数:7,代码来源:resource_lxd_container.go

示例10: doNetworkSet

func (c *networkCmd) doNetworkSet(client *lxd.Client, name string, args []string) error {
	// we shifted @args so so it should read "<key> [<value>]"
	if len(args) < 1 {
		return errArgs
	}

	network, err := client.NetworkGet(name)
	if err != nil {
		return err
	}

	key := args[0]
	var value string
	if len(args) < 2 {
		value = ""
	} else {
		value = args[1]
	}

	if !termios.IsTerminal(int(syscall.Stdin)) && value == "-" {
		buf, err := ioutil.ReadAll(os.Stdin)
		if err != nil {
			return fmt.Errorf("Can't read from stdin: %s", err)
		}
		value = string(buf[:])
	}

	network.Config[key] = value

	return client.NetworkPut(name, network)
}
开发者ID:vahe,项目名称:lxd,代码行数:31,代码来源:network.go

示例11: doNetworkDelete

func (c *networkCmd) doNetworkDelete(client *lxd.Client, name string) error {
	err := client.NetworkDelete(name)
	if err == nil {
		fmt.Printf(i18n.G("Network %s deleted")+"\n", name)
	}

	return err
}
开发者ID:vahe,项目名称:lxd,代码行数:8,代码来源:network.go

示例12: doDelete

func doDelete(d *lxd.Client, name string) error {
	resp, err := d.Delete(name)
	if err != nil {
		return err
	}

	return d.WaitForSuccess(resp.Operation)
}
开发者ID:Ramzec,项目名称:lxd,代码行数:8,代码来源:delete.go

示例13: resourceLxdContainerRefresh

func resourceLxdContainerRefresh(client *lxd.Client, name string) resource.StateRefreshFunc {
	return func() (interface{}, string, error) {
		ct, err := client.ContainerState(name)
		if err != nil {
			return ct, "Error", err
		}

		return ct, ct.Status, nil
	}
}
开发者ID:sl1pm4t,项目名称:terraform-provider-lxd,代码行数:10,代码来源:resource_lxd_container.go

示例14: doNetworkShow

func (c *networkCmd) doNetworkShow(client *lxd.Client, name string) error {
	network, err := client.NetworkGet(name)
	if err != nil {
		return err
	}

	data, err := yaml.Marshal(&network)
	fmt.Printf("%s", data)

	return nil
}
开发者ID:vahe,项目名称:lxd,代码行数:11,代码来源:network.go

示例15: doProfileShow

func doProfileShow(client *lxd.Client, p string) error {
	profile, err := client.ProfileConfig(p)
	if err != nil {
		return err
	}

	data, err := yaml.Marshal(&profile)
	fmt.Printf("%s", data)

	return nil
}
开发者ID:achanda,项目名称:lxd,代码行数:11,代码来源:profile.go


注:本文中的github.com/lxc/lxd.Client类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。