• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang series.GetOSFromSeries函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: SetUpTest

func (s *syslogSuite) SetUpTest(c *gc.C) {
	if runtime.GOOS != "linux" {
		c.Skip(fmt.Sprintf("this test requires a controller, therefore does not support %q", runtime.GOOS))
	}
	currentSeries := series.HostSeries()
	osFromSeries, err := series.GetOSFromSeries(currentSeries)
	c.Assert(err, jc.ErrorIsNil)
	if osFromSeries != os.Ubuntu {
		c.Skip(fmt.Sprintf("this test requires a controller, therefore does not support OS %q only Ubuntu", osFromSeries.String()))
	}
	s.AgentSuite.SetUpTest(c)
	// TODO(perrito666) 200160701:
	// This needs to be done to stop the test from trying to install mongo
	// while running, but it is a huge footprint for such little benefit.
	// This test should not need JujuConnSuite or AgentSuite.
	s.fakeEnsureMongo = agenttest.InstallFakeEnsureMongo(s)

	done := make(chan struct{})
	s.received = make(chan rfc5424test.Message)
	addr := s.createSyslogServer(c, s.received, done)

	// Leave log forwarding disabled initially, it will be enabled
	// via a model config update in the test.
	err = s.State.UpdateModelConfig(map[string]interface{}{
		"syslog-host":        addr,
		"syslog-ca-cert":     coretesting.CACert,
		"syslog-client-cert": coretesting.ServerCert,
		"syslog-client-key":  coretesting.ServerKey,
	}, nil, nil)
	c.Assert(err, jc.ErrorIsNil)

	s.logsCh, err = logsender.InstallBufferedLogWriter(1000)
	c.Assert(err, jc.ErrorIsNil)
}
开发者ID:bac,项目名称:juju,代码行数:34,代码来源:syslog_test.go


示例2: versionInitSystem

func versionInitSystem(ser string) (string, error) {
	seriesos, err := series.GetOSFromSeries(ser)
	if err != nil {
		notFound := errors.NotFoundf("init system for series %q", ser)
		return "", errors.Wrap(err, notFound)
	}

	switch seriesos {
	case os.Windows:
		return InitSystemWindows, nil
	case os.Ubuntu:
		switch ser {
		case "precise", "quantal", "raring", "saucy", "trusty", "utopic":
			return InitSystemUpstart, nil
		default:
			// vivid and later
			if featureflag.Enabled(feature.LegacyUpstart) {
				return InitSystemUpstart, nil
			}
			return InitSystemSystemd, nil
		}
	case os.CentOS:
		return InitSystemSystemd, nil
	}
	return "", errors.NotFoundf("unknown os %q (from series %q), init system", seriesos, ser)
}
开发者ID:imoapps,项目名称:juju,代码行数:26,代码来源:discovery.go


示例3: validateUploadAllowed

// validateUploadAllowed returns an error if an attempt to upload tools should
// not be allowed.
func validateUploadAllowed(env environs.Environ, toolsArch, toolsSeries *string, validator constraints.Validator) error {
	// Now check that the architecture and series for which we are setting up an
	// environment matches that from which we are bootstrapping.
	hostArch := arch.HostArch()
	// We can't build tools for a different architecture if one is specified.
	if toolsArch != nil && *toolsArch != hostArch {
		return fmt.Errorf("cannot use agent built for %q using a machine running on %q", *toolsArch, hostArch)
	}
	hostOS := jujuos.HostOS()
	if toolsSeries != nil {
		toolsSeriesOS, err := series.GetOSFromSeries(*toolsSeries)
		if err != nil {
			return errors.Trace(err)
		}
		if !toolsSeriesOS.EquivalentTo(hostOS) {
			return errors.Errorf("cannot use agent built for %q using a machine running %q", *toolsSeries, hostOS)
		}
	}
	// If no architecture is specified, ensure the target provider supports instances matching our architecture.
	if _, err := validator.Validate(constraints.Value{Arch: &hostArch}); err != nil {
		return errors.Errorf(
			"model %q of type %s does not support instances running on %q",
			env.Config().Name(), env.Config().Type(), hostArch,
		)
	}
	return nil
}
开发者ID:bac,项目名称:juju,代码行数:29,代码来源:tools.go


示例4: newRole

// newRole creates a gwacl.Role object (an Azure Virtual Machine) which uses
// the given Virtual Hard Drive.
//
// roleSize is the name of one of Azure's machine types, e.g. ExtraSmall,
// Large, A6 etc.
func (env *azureEnviron) newRole(roleSize string, vhd *gwacl.OSVirtualHardDisk, stateServer bool, userdata, ser string, snapshot *azureEnviron) (*gwacl.Role, error) {
	// Do some common initialization
	roleName := gwacl.MakeRandomRoleName("juju")
	hostname := roleName
	password := gwacl.MakeRandomPassword()

	os, err := series.GetOSFromSeries(ser)
	if err != nil {
		return nil, errors.Trace(err)
	}
	// Generate a Network Configuration with the initially required ports open.
	networkConfigurationSet := gwacl.NewNetworkConfigurationSet(env.getInitialEndpoints(stateServer), nil)

	var role *gwacl.Role
	switch os {
	case jujuos.Windows:
		role, err = makeWindowsRole(password, roleSize, roleName, userdata, vhd, networkConfigurationSet, snapshot)
	default:
		role, err = makeLinuxRole(hostname, password, roleSize, roleName, userdata, vhd, networkConfigurationSet)
	}
	if err != nil {
		return nil, errors.Trace(err)
	}
	role.AvailabilitySetName = "juju"
	return role, nil
}
开发者ID:kakamessi99,项目名称:juju,代码行数:31,代码来源:environ.go


示例5: NewUserdataConfig

// UserdataConfig is supposed to take in an instanceConfig as well as a
// cloudinit.cloudConfig and add attributes in the cloudinit structure based on
// the values inside instanceConfig and on the series
func NewUserdataConfig(icfg *instancecfg.InstanceConfig, conf cloudinit.CloudConfig) (UserdataConfig, error) {
	// TODO(ericsnow) bug #1426217
	// Protect icfg and conf better.
	operatingSystem, err := series.GetOSFromSeries(icfg.Series)
	if err != nil {
		return nil, err
	}

	base := baseConfigure{
		tag:  names.NewMachineTag(icfg.MachineId),
		icfg: icfg,
		conf: conf,
		os:   operatingSystem,
	}

	switch operatingSystem {
	case os.Ubuntu:
		return &unixConfigure{base}, nil
	case os.CentOS:
		return &unixConfigure{base}, nil
	case os.Windows:
		return &windowsConfigure{base}, nil
	default:
		return nil, errors.NotSupportedf("OS %s", icfg.Series)
	}
}
开发者ID:imoapps,项目名称:juju,代码行数:29,代码来源:userdatacfg.go


示例6: TestCurrentSeries

func (*CurrentSuite) TestCurrentSeries(c *gc.C) {
	s := series.HostSeries()
	if s == "unknown" {
		s = "n/a"
	}
	out, err := exec.Command("lsb_release", "-c").CombinedOutput()

	if err != nil {
		// If the command fails (for instance if we're running on some other
		// platform) then CurrentSeries should be unknown.
		switch runtime.GOOS {
		case "darwin":
			c.Check(s, gc.Matches, `mavericks|mountainlion|lion|snowleopard`)
		case "windows":
			c.Check(s, gc.Matches, `win2012hvr2|win2012hv|win2012|win2012r2|win8|win81|win7`)
		default:
			current_os, err := series.GetOSFromSeries(s)
			c.Assert(err, gc.IsNil)
			if s != "n/a" {
				// There is no lsb_release command on CentOS.
				if current_os == os.CentOS {
					c.Check(s, gc.Matches, `centos7`)
				}
			}
		}
	} else {
		c.Assert(string(out), gc.Equals, "Codename:\t"+s+"\n")
	}
}
开发者ID:imoapps,项目名称:juju,代码行数:29,代码来源:current_test.go


示例7: getDisks

// getDisks builds the raw spec for the disks that should be attached to
// the new instances and returns it. This will always include a root
// disk with characteristics determined by the provides args and
// constraints.
func getDisks(spec *instances.InstanceSpec, cons constraints.Value, ser, eUUID string) ([]google.DiskSpec, error) {
	size := common.MinRootDiskSizeGiB(ser)
	if cons.RootDisk != nil && *cons.RootDisk > size {
		size = common.MiBToGiB(*cons.RootDisk)
	}
	var imageURL string
	os, err := series.GetOSFromSeries(ser)
	if err != nil {
		return nil, errors.Trace(err)
	}
	switch os {
	case jujuos.Ubuntu:
		imageURL = ubuntuImageBasePath
	case jujuos.Windows:
		imageURL = windowsImageBasePath
	default:
		return nil, errors.Errorf("os %s is not supported on the gce provider", os.String())
	}
	dSpec := google.DiskSpec{
		Series:      ser,
		SizeHintGB:  size,
		ImageURL:    imageURL + spec.Image.Id,
		Boot:        true,
		AutoDelete:  true,
		Description: eUUID,
	}
	if cons.RootDisk != nil && dSpec.TooSmall() {
		msg := "Ignoring root-disk constraint of %dM because it is smaller than the GCE image size of %dG"
		logger.Infof(msg, *cons.RootDisk, google.MinDiskSizeGB(ser))
	}
	return []google.DiskSpec{dSpec}, nil
}
开发者ID:exekias,项目名称:juju,代码行数:36,代码来源:environ_broker.go


示例8: getContainerInstance

func getContainerInstance() (cont []ContainerInstance, err error) {
	current_os, err := series.GetOSFromSeries(series.HostSeries())
	if err != nil {
		return nil, err
	}

	switch current_os {
	case jujuos.CentOS:
		cont = []ContainerInstance{
			{instance.LXC, [][]string{
				{"lxc"},
				{"cloud-image-utils"},
			}},
			{instance.KVM, [][]string{
				{"uvtool-libvirt"},
				{"uvtool"},
			}},
		}
	default:
		cont = []ContainerInstance{
			{instance.LXC, [][]string{
				{"--target-release", "precise-updates/cloud-tools", "lxc"},
				{"--target-release", "precise-updates/cloud-tools", "cloud-image-utils"},
			}},
			{instance.KVM, [][]string{
				{"uvtool-libvirt"},
				{"uvtool"},
			}},
		}
	}

	return cont, nil
}
开发者ID:snailwalker,项目名称:juju,代码行数:33,代码来源:container_initialisation_test.go


示例9: TestGetDisks

func (s *environBrokerSuite) TestGetDisks(c *gc.C) {
	for _, test := range getDisksTests {
		diskSpecs, err := gce.GetDisks(s.spec, s.StartInstArgs.Constraints, test.Series, "32f7d570-5bac-4b72-b169-250c24a94b2b", false)
		if test.error != nil {
			c.Assert(err, gc.Equals, err)
		} else {
			c.Assert(err, jc.ErrorIsNil)
			c.Assert(diskSpecs, gc.HasLen, 1)

			diskSpec := diskSpecs[0]

			os, err := series.GetOSFromSeries(test.Series)
			c.Assert(err, jc.ErrorIsNil)
			switch os {
			case jujuos.Ubuntu:
				c.Check(diskSpec.SizeHintGB, gc.Equals, uint64(8))
			case jujuos.Windows:
				c.Check(diskSpec.SizeHintGB, gc.Equals, uint64(40))
			default:
				c.Check(diskSpec.SizeHintGB, gc.Equals, uint64(8))
			}
			c.Check(diskSpec.ImageURL, gc.Equals, test.basePath+s.spec.Image.Id)
		}
	}

	diskSpecs, err := gce.GetDisks(s.spec, s.StartInstArgs.Constraints, "trusty", "32f7d570-5bac-4b72-b169-250c24a94b2b", true)
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(diskSpecs, gc.HasLen, 1)
	spec := diskSpecs[0]
	c.Assert(spec.ImageURL, gc.Equals, gce.UbuntuDailyImageBasePath+s.spec.Image.Id)
}
开发者ID:bac,项目名称:juju,代码行数:31,代码来源:environ_broker_test.go


示例10: ComposeUserData

// ComposeUserData fills out the provided cloudinit configuration structure
// so it is suitable for initialising a machine with the given configuration,
// and then renders it and encodes it using the supplied renderer.
// When calling ComposeUserData a encoding implementation must be chosen from
// the providerinit/encoders package according to the need of the provider.
//
// If the provided cloudcfg is nil, a new one will be created internally.
func ComposeUserData(icfg *instancecfg.InstanceConfig, cloudcfg cloudinit.CloudConfig, renderer renderers.ProviderRenderer) ([]byte, error) {
	if cloudcfg == nil {
		var err error
		cloudcfg, err = cloudinit.New(icfg.Series)
		if err != nil {
			return nil, errors.Trace(err)
		}
	}
	_, err := configureCloudinit(icfg, cloudcfg)
	if err != nil {
		return nil, errors.Trace(err)
	}
	operatingSystem, err := series.GetOSFromSeries(icfg.Series)
	if err != nil {
		return nil, errors.Trace(err)
	}
	// This might get replaced by a renderer.RenderUserdata which will either
	// render it as YAML or Bash since some CentOS images might ship without cloudnit
	udata, err := cloudcfg.RenderYAML()
	if err != nil {
		return nil, errors.Trace(err)
	}
	udata, err = renderer.EncodeUserdata(udata, operatingSystem)
	if err != nil {
		return nil, errors.Trace(err)
	}
	logger.Tracef("Generated cloud init:\n%s", string(udata))
	return udata, err
}
开发者ID:kakamessi99,项目名称:juju,代码行数:36,代码来源:providerinit.go


示例11: populateTools

// populateTools stores uploaded tools in provider storage
// and updates the tools metadata.
func (c *BootstrapCommand) populateTools(st *state.State, env environs.Environ) error {
	agentConfig := c.CurrentConfig()
	dataDir := agentConfig.DataDir()

	current := version.Binary{
		Number: jujuversion.Current,
		Arch:   arch.HostArch(),
		Series: series.HostSeries(),
	}
	tools, err := agenttools.ReadTools(dataDir, current)
	if err != nil {
		return errors.Trace(err)
	}

	data, err := ioutil.ReadFile(filepath.Join(
		agenttools.SharedToolsDir(dataDir, current),
		"tools.tar.gz",
	))
	if err != nil {
		return errors.Trace(err)
	}

	toolstorage, err := st.ToolsStorage()
	if err != nil {
		return errors.Trace(err)
	}
	defer toolstorage.Close()

	var toolsVersions []version.Binary
	if strings.HasPrefix(tools.URL, "file://") {
		// Tools were uploaded: clone for each series of the same OS.
		os, err := series.GetOSFromSeries(tools.Version.Series)
		if err != nil {
			return errors.Trace(err)
		}
		osSeries := series.OSSupportedSeries(os)
		for _, series := range osSeries {
			toolsVersion := tools.Version
			toolsVersion.Series = series
			toolsVersions = append(toolsVersions, toolsVersion)
		}
	} else {
		// Tools were downloaded from an external source: don't clone.
		toolsVersions = []version.Binary{tools.Version}
	}

	for _, toolsVersion := range toolsVersions {
		metadata := binarystorage.Metadata{
			Version: toolsVersion.String(),
			Size:    tools.Size,
			SHA256:  tools.SHA256,
		}
		logger.Debugf("Adding tools: %v", toolsVersion)
		if err := toolstorage.Add(bytes.NewReader(data), metadata); err != nil {
			return errors.Trace(err)
		}
	}
	return nil
}
开发者ID:AlexisBruemmer,项目名称:juju,代码行数:61,代码来源:bootstrap.go


示例12: shouldWarnJuju1x

func shouldWarnJuju1x() bool {
	// this code only applies to Ubuntu, where we renamed Juju 1.x to juju-1.
	ostype, err := series.GetOSFromSeries(series.HostSeries())
	if err != nil || ostype != utilsos.Ubuntu {
		return false
	}
	return osenv.Juju1xEnvConfigExists() && !juju2xConfigDataExists()
}
开发者ID:bac,项目名称:juju,代码行数:8,代码来源:main.go


示例13: setDataDirPermissions

func (w *unixConfigure) setDataDirPermissions() string {
	seriesos, _ := series.GetOSFromSeries(w.icfg.Series)
	var user string
	switch seriesos {
	case os.CentOS:
		user = "root"
	default:
		user = "syslog"
	}
	return fmt.Sprintf("chown %s:adm %s", user, w.icfg.LogDir)
}
开发者ID:kakamessi99,项目名称:juju,代码行数:11,代码来源:userdatacfg_unix.go


示例14: TestGetOSFromSeries

func (s *supportedSeriesSuite) TestGetOSFromSeries(c *gc.C) {
	for _, t := range getOSFromSeriesTests {
		got, err := series.GetOSFromSeries(t.series)
		if t.err != "" {
			c.Assert(err, gc.ErrorMatches, t.err)
		} else {
			c.Check(err, jc.ErrorIsNil)
			c.Assert(got, gc.Equals, t.want)
		}
	}
}
开发者ID:anastasiamac,项目名称:utils,代码行数:11,代码来源:supportedseries_test.go


示例15: osVal

// osVal will lookup the value of the key valname
// in the apropriate map, based on the series. This will
// help reduce boilerplate code
func osVal(ser string, valname osVarType) (string, error) {
	os, err := series.GetOSFromSeries(ser)
	if err != nil {
		return "", err
	}
	switch os {
	case jujuos.Windows:
		return winVals[valname], nil
	default:
		return nixVals[valname], nil
	}
}
开发者ID:makyo,项目名称:juju,代码行数:15,代码来源:paths.go


示例16: SeriesImage

// SeriesImage gets an instances.Image for the specified series, image stream
// and location. The resulting Image's ID is in the URN format expected by
// Azure Resource Manager.
//
// For Ubuntu, we query the SKUs to determine the most recent point release
// for a series.
func SeriesImage(
	series, stream, location string,
	client compute.VirtualMachineImagesClient,
) (*instances.Image, error) {
	seriesOS, err := jujuseries.GetOSFromSeries(series)
	if err != nil {
		return nil, errors.Trace(err)
	}

	var publisher, offering, sku string
	switch seriesOS {
	case os.Ubuntu:
		publisher = ubuntuPublisher
		offering = ubuntuOffering
		sku, err = ubuntuSKU(series, stream, location, client)
		if err != nil {
			return nil, errors.Annotatef(err, "selecting SKU for %s", series)
		}

	case os.Windows:
		publisher = windowsPublisher
		offering = windowsOffering
		switch series {
		case "win2012":
			sku = "2012-Datacenter"
		case "win2012r2":
			sku = "2012-R2-Datacenter"
		default:
			return nil, errors.NotSupportedf("deploying %s", series)
		}

	case os.CentOS:
		publisher = centOSPublisher
		offering = centOSOffering
		switch series {
		case "centos7":
			sku = "7.1"
		default:
			return nil, errors.NotSupportedf("deploying %s", series)
		}

	default:
		// TODO(axw) CentOS
		return nil, errors.NotSupportedf("deploying %s", seriesOS)
	}

	return &instances.Image{
		Id:       fmt.Sprintf("%s:%s:%s:latest", publisher, offering, sku),
		Arch:     arch.AMD64,
		VirtType: "Hyper-V",
	}, nil
}
开发者ID:imoapps,项目名称:juju,代码行数:58,代码来源:images.go


示例17: writeEnvironment

func (w *proxyWorker) writeEnvironment() error {
	// TODO(dfc) this should be replaced with a switch on os.HostOS()
	osystem, err := series.GetOSFromSeries(series.HostSeries())
	if err != nil {
		return err
	}
	switch osystem {
	case os.Windows:
		return w.writeEnvironmentToRegistry()
	default:
		return w.writeEnvironmentFile()
	}
}
开发者ID:pmatulis,项目名称:juju,代码行数:13,代码来源:proxyupdater.go


示例18: formatApplication

func (sf *statusFormatter) formatApplication(name string, application params.ApplicationStatus) applicationStatus {
	appOS, _ := series.GetOSFromSeries(application.Series)
	var (
		charmOrigin = ""
		charmName   = ""
		charmRev    = 0
	)
	if curl, err := charm.ParseURL(application.Charm); err != nil {
		// We should never fail to parse a charm url sent back
		// but if we do, don't crash.
		logger.Errorf("failed to parse charm: %v", err)
	} else {
		switch curl.Schema {
		case "cs":
			charmOrigin = "jujucharms"
		case "local":
			charmOrigin = "local"
		default:
			charmOrigin = "unknown"
		}
		charmName = curl.Name
		charmRev = curl.Revision
	}

	out := applicationStatus{
		Err:           application.Err,
		Charm:         application.Charm,
		Series:        application.Series,
		OS:            strings.ToLower(appOS.String()),
		CharmOrigin:   charmOrigin,
		CharmName:     charmName,
		CharmRev:      charmRev,
		Exposed:       application.Exposed,
		Life:          application.Life,
		Relations:     application.Relations,
		CanUpgradeTo:  application.CanUpgradeTo,
		SubordinateTo: application.SubordinateTo,
		Units:         make(map[string]unitStatus),
		StatusInfo:    sf.getServiceStatusInfo(application),
		Version:       application.WorkloadVersion,
	}
	for k, m := range application.Units {
		out.Units[k] = sf.formatUnit(unitFormatInfo{
			unit:            m,
			unitName:        k,
			applicationName: name,
			meterStatuses:   application.MeterStatuses,
		})
	}
	return out
}
开发者ID:kat-co,项目名称:juju,代码行数:51,代码来源:formatter.go


示例19: newOSProfile

func newOSProfile(
	vmName string,
	instanceConfig *instancecfg.InstanceConfig,
	randomAdminPassword func() string,
) (*compute.OSProfile, os.OSType, error) {
	logger.Debugf("creating OS profile for %q", vmName)

	customData, err := providerinit.ComposeUserData(instanceConfig, nil, AzureRenderer{})
	if err != nil {
		return nil, os.Unknown, errors.Annotate(err, "composing user data")
	}

	osProfile := &compute.OSProfile{
		ComputerName: to.StringPtr(vmName),
		CustomData:   to.StringPtr(string(customData)),
	}

	seriesOS, err := jujuseries.GetOSFromSeries(instanceConfig.Series)
	if err != nil {
		return nil, os.Unknown, errors.Trace(err)
	}
	switch seriesOS {
	case os.Ubuntu, os.CentOS:
		// SSH keys are handled by custom data, but must also be
		// specified in order to forego providing a password, and
		// disable password authentication.
		publicKeys := []compute.SSHPublicKey{{
			Path:    to.StringPtr("/home/ubuntu/.ssh/authorized_keys"),
			KeyData: to.StringPtr(instanceConfig.AuthorizedKeys),
		}}
		osProfile.AdminUsername = to.StringPtr("ubuntu")
		osProfile.LinuxConfiguration = &compute.LinuxConfiguration{
			DisablePasswordAuthentication: to.BoolPtr(true),
			SSH: &compute.SSHConfiguration{PublicKeys: &publicKeys},
		}
	case os.Windows:
		osProfile.AdminUsername = to.StringPtr("JujuAdministrator")
		// A password is required by Azure, but we will never use it.
		// We generate something sufficiently long and random that it
		// should be infeasible to guess.
		osProfile.AdminPassword = to.StringPtr(randomAdminPassword())
		osProfile.WindowsConfiguration = &compute.WindowsConfiguration{
			ProvisionVMAgent:       to.BoolPtr(true),
			EnableAutomaticUpdates: to.BoolPtr(true),
			// TODO(?) add WinRM configuration here.
		}
	default:
		return nil, os.Unknown, errors.NotSupportedf("%s", seriesOS)
	}
	return osProfile, seriesOS, nil
}
开发者ID:bac,项目名称:juju,代码行数:51,代码来源:environ.go


示例20: newRawInstance

// newRawInstance is where the new physical instance is actually
// provisioned, relative to the provided args and spec. Info for that
// low-level instance is returned.
func (env *environ) newRawInstance(args environs.StartInstanceParams, spec *instances.InstanceSpec) (*google.Instance, error) {
	machineID := common.MachineFullName(env, args.InstanceConfig.MachineId)

	os, err := series.GetOSFromSeries(args.InstanceConfig.Series)
	if err != nil {
		return nil, errors.Trace(err)
	}

	metadata, err := getMetadata(args, os)
	if err != nil {
		return nil, errors.Trace(err)
	}
	tags := []string{
		env.globalFirewallName(),
		machineID,
	}

	cfg := env.Config()
	eUUID, ok := cfg.UUID()
	if !ok {
		return nil, errors.NotFoundf("UUID necessary to create the instance disk")
	}

	disks, err := getDisks(spec, args.Constraints, args.InstanceConfig.Series, eUUID)
	if err != nil {
		return nil, errors.Trace(err)
	}

	// TODO(ericsnow) Use the env ID for the network name (instead of default)?
	// TODO(ericsnow) Make the network name configurable?
	// TODO(ericsnow) Support multiple networks?
	// TODO(ericsnow) Use a different net interface name? Configurable?
	instSpec := google.InstanceSpec{
		ID:                machineID,
		Type:              spec.InstanceType.Name,
		Disks:             disks,
		NetworkInterfaces: []string{"ExternalNAT"},
		Metadata:          metadata,
		Tags:              tags,
		// Network is omitted (left empty).
	}

	zones, err := env.parseAvailabilityZones(args)
	if err != nil {
		return nil, errors.Trace(err)
	}

	inst, err := env.gce.AddInstance(instSpec, zones...)
	return inst, errors.Trace(err)
}
开发者ID:exekias,项目名称:juju,代码行数:53,代码来源:environ_broker.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang series.HostSeries函数代码示例发布时间:2022-05-23
下一篇:
Golang proxy.Settings类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap