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


Golang Client.ProfileCreate方法代码示例

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


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

示例1: doProfileCreate

func (c *profileCmd) 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: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:achanda,项目名称:lxd,代码行数:7,代码来源:profile.go

示例3: cmdCreate

func cmdCreate(c *lxd.Client, args []string) error {
	var wgBatch sync.WaitGroup

	// A path must be provided
	if len(args) < 1 {
		return fmt.Errorf("A path must be passed to create.")
	}

	// Load the simulation
	routersMap, err := importFromCSV(args[0])
	if err != nil {
		return err
	}

	routers := []*Router{}
	for _, v := range routersMap {
		if v.Tier < 1 {
			continue
		}

		routers = append(routers, v)
	}

	// Clear any existing images
	fp := c.GetAlias("internet-router")
	if fp != "" {
		logf("Deleting the existing router image: %s", fp)
		err = c.DeleteImage(fp)
		if err != nil {
			return err
		}
	}

	// Load the image
	logf("Importing the router image")
	_, err = c.PostImage("image/image-meta.tar.xz", "image/image-rootfs.tar.xz", nil, false, []string{"internet-router"}, nil)
	if err != nil {
		return err
	}
	logf("New router image imported: %s", fp)

	// Create the profile
	_, err = c.ProfileConfig("internet-base")
	if err != nil {
		logf("Creating the profile")
		err := c.ProfileCreate("internet-base")
		if err != nil {
			return err
		}
	}

	// Helper function
	createContainer := func(router *Router) {
		defer wgBatch.Done()

		var interfaces string
		var bgpd string

		// Configuration
		config := map[string]string{}
		devices := map[string]map[string]string{}

		config["user.internet.type"] = "router"
		config["user.internet.organization"] = router.Organization
		config["user.internet.priority"] = fmt.Sprintf("%d", router.Priority)
		config["user.internet.tier"] = fmt.Sprintf("%d", router.Tier)
		config["user.internet.location"] = router.Location

		for i, r := range router.DNS {
			config[fmt.Sprintf("user.internet.dns.%d", i)] = r
		}

		config["user.internet.router.fqdn"] = router.Configuration.FQDN
		config["user.internet.router.asn"] = fmt.Sprintf("%d", router.Configuration.ASN)
		config["user.internet.router.password.login"] = router.Configuration.PasswordLogin
		config["user.internet.router.password.enable"] = router.Configuration.PasswordEnable
		if router.Configuration.RouterID != nil {
			config["user.internet.router.routerid"] = router.Configuration.RouterID.String()
		}

		if router.Internal {
			config["user.internet.internal"] = "true"
		} else {
			config["user.internet.internal"] = "false"
		}

		if router.Tier >= 1 && router.Tier <= 3 {
			interfaces = fmt.Sprintf(`auto lo
iface lo inet loopback
    pre-up echo 0 > /proc/sys/net/ipv6/conf/all/accept_dad || true
    post-up echo 1 > /proc/sys/net/ipv6/conf/all/forwarding || true

auto local
iface local inet6 manual
    pre-up ip link add local type dummy || true
    pre-up ip link set local up || true
`)
		}

		for i, r := range router.Configuration.Loopback.Addresses {
//.........这里部分代码省略.........
开发者ID:nsec,项目名称:the-internet,代码行数:101,代码来源:cmd_create.go


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