Exemple #1
0
func DeployEtcdWithInstanceCount(count int, client bosh.Client, config Config) (manifest destiny.Manifest, err error) {
	guid, err := NewGUID()
	if err != nil {
		return
	}

	info, err := client.Info()
	if err != nil {
		return
	}

	manifestConfig := destiny.Config{
		DirectorUUID: info.UUID,
		Name:         fmt.Sprintf("etcd-%s", guid),
	}

	switch info.CPI {
	case "aws_cpi":
		manifestConfig.IAAS = destiny.AWS
		if config.AWS.Subnet != "" {
			manifestConfig.AWS.Subnet = config.AWS.Subnet
		} else {
			err = errors.New("AWSSubnet is required for AWS IAAS deployment")
			return
		}
	case "warden_cpi":
		manifestConfig.IAAS = destiny.Warden
	default:
		err = errors.New("unknown infrastructure type")
		return
	}

	manifest = destiny.NewEtcd(manifestConfig)

	manifest.Jobs[0], manifest.Properties = destiny.SetJobInstanceCount(manifest.Jobs[0], manifest.Networks[0], manifest.Properties, count)

	yaml, err := manifest.ToYAML()
	if err != nil {
		return
	}

	yaml, err = client.ResolveManifestVersions(yaml)
	if err != nil {
		return
	}

	manifest, err = destiny.FromYAML(yaml)
	if err != nil {
		return
	}

	err = client.Deploy(yaml)
	if err != nil {
		return
	}

	return
}
		Password:         config.BOSH.Password,
		AllowInsecureSSL: true,
	})

	By("deploying turbulence", func() {
		info, err := client.Info()
		Expect(err).NotTo(HaveOccurred())

		guid, err := helpers.NewGUID()
		Expect(err).NotTo(HaveOccurred())

		manifestConfig := destiny.Config{
			DirectorUUID: info.UUID,
			Name:         "turbulence-etcd-" + guid,
			BOSH: destiny.ConfigBOSH{
				Target:         config.BOSH.Target,
				Username:       config.BOSH.Username,
				Password:       config.BOSH.Password,
				DirectorCACert: config.BOSH.DirectorCACert,
			},
		}

		switch info.CPI {
		case "aws_cpi":
			manifestConfig.IAAS = destiny.AWS

			if config.AWS.Subnet == "" {
				Fail("aws.subnet is required for AWS IAAS deployment")
			}

			manifestConfig.AWS = destiny.ConfigAWS{
				AccessKeyID:           config.AWS.AccessKeyID,