本文整理汇总了Golang中github.com/pivotal-cf-experimental/bosh-test/bosh.Client.ResolveManifestVersions方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.ResolveManifestVersions方法的具体用法?Golang Client.ResolveManifestVersions怎么用?Golang Client.ResolveManifestVersions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/pivotal-cf-experimental/bosh-test/bosh.Client
的用法示例。
在下文中一共展示了Client.ResolveManifestVersions方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: DeployEtcdWithInstanceCount
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
}
示例2:
Port: config.Registry.Port,
Username: config.Registry.Username,
Password: config.Registry.Password,
}
case "warden_cpi":
manifestConfig.IAAS = destiny.Warden
default:
Fail("unknown infrastructure type")
}
turbulenceManifest = destiny.NewTurbulence(manifestConfig)
yaml, err := turbulenceManifest.ToYAML()
Expect(err).NotTo(HaveOccurred())
yaml, err = client.ResolveManifestVersions(yaml)
Expect(err).NotTo(HaveOccurred())
turbulenceManifest, err = destiny.FromYAML(yaml)
Expect(err).NotTo(HaveOccurred())
err = client.Deploy(yaml)
Expect(err).NotTo(HaveOccurred())
Eventually(func() ([]bosh.VM, error) {
return client.DeploymentVMs(turbulenceManifest.Name)
}, "1m", "10s").Should(ConsistOf([]bosh.VM{
{"running"},
}))
})
示例3: DeployTurbulence
func DeployTurbulence(client bosh.Client, config Config) (turbulence.Manifest, error) {
info, err := client.Info()
if err != nil {
return turbulence.Manifest{}, err
}
guid, err := NewGUID()
if err != nil {
return turbulence.Manifest{}, err
}
manifestConfig := turbulence.Config{
DirectorUUID: info.UUID,
Name: "turbulence-consul-" + guid,
BOSH: turbulence.ConfigBOSH{
Target: config.BOSH.Target,
Username: config.BOSH.Username,
Password: config.BOSH.Password,
DirectorCACert: config.BOSH.DirectorCACert,
},
}
var iaasConfig iaas.Config
switch info.CPI {
case "aws_cpi":
awsConfig := iaas.AWSConfig{
AccessKeyID: config.AWS.AccessKeyID,
SecretAccessKey: config.AWS.SecretAccessKey,
DefaultKeyName: config.AWS.DefaultKeyName,
DefaultSecurityGroups: config.AWS.DefaultSecurityGroups,
Region: config.AWS.Region,
RegistryHost: config.Registry.Host,
RegistryPassword: config.Registry.Password,
RegistryPort: config.Registry.Port,
RegistryUsername: config.Registry.Username,
}
manifestConfig.BOSH.PersistentDiskType = config.BOSH.Errand.DefaultPersistentDiskType
manifestConfig.BOSH.VMType = config.BOSH.Errand.DefaultVMType
if len(config.AWS.Subnets) > 0 {
subnet := config.AWS.Subnets[0]
var cidrBlock string
cidrPool := NewCIDRPool(subnet.Range, 24, 27)
cidrBlock, err = cidrPool.Last()
if err != nil {
return turbulence.Manifest{}, err
}
awsConfig.Subnets = append(awsConfig.Subnets, iaas.AWSConfigSubnet{ID: subnet.ID, Range: cidrBlock, AZ: subnet.AZ, SecurityGroup: subnet.SecurityGroup})
manifestConfig.IPRange = cidrBlock
} else {
return turbulence.Manifest{}, errors.New("aws.subnet is required for AWS IAAS deployment")
}
iaasConfig = awsConfig
case "warden_cpi":
var cidrBlock string
cidrPool := NewCIDRPool("10.244.4.0", 24, 27)
cidrBlock, err = cidrPool.Last()
if err != nil {
return turbulence.Manifest{}, err
}
manifestConfig.IPRange = cidrBlock
iaasConfig = iaas.NewWardenConfig()
default:
return turbulence.Manifest{}, errors.New("unknown infrastructure type")
}
turbulenceManifest, err := turbulence.NewManifest(manifestConfig, iaasConfig)
if err != nil {
return turbulence.Manifest{}, err
}
yaml, err := turbulenceManifest.ToYAML()
if err != nil {
return turbulence.Manifest{}, err
}
yaml, err = client.ResolveManifestVersions(yaml)
if err != nil {
return turbulence.Manifest{}, err
}
turbulenceManifest, err = turbulence.FromYAML(yaml)
if err != nil {
return turbulence.Manifest{}, err
}
_, err = client.Deploy(yaml)
if err != nil {
return turbulence.Manifest{}, err
}
return turbulenceManifest, nil
}
示例4: deployConsul
func deployConsul(deploymentPrefix string, count int, client bosh.Client, config Config, releaseVersion string, manifestGenerator ManifestGenerator) (manifest consul.ManifestV2, kv consulclient.HTTPKV, err error) {
guid, err := NewGUID()
if err != nil {
return
}
info, err := client.Info()
if err != nil {
return
}
manifestConfig := consul.ConfigV2{
DirectorUUID: info.UUID,
Name: fmt.Sprintf("consul-%s-%s", deploymentPrefix, guid),
TurbulenceHost: config.TurbulenceHost,
WindowsClients: config.WindowsClients,
}
var iaasConfig iaas.Config
switch info.CPI {
case "aws_cpi":
manifestConfig.PersistentDiskType = config.BOSH.Errand.DefaultPersistentDiskType
manifestConfig.VMType = config.BOSH.Errand.DefaultVMType
awsConfig := buildAWSConfig(config)
if len(config.AWS.Subnets) > 0 {
subnet := config.AWS.Subnets[0]
var cidrBlock string
cidrPool := NewCIDRPool(subnet.Range, 24, 27)
cidrBlock, err = cidrPool.Get(ginkgoConfig.GinkgoConfig.ParallelNode)
if err != nil {
return
}
awsConfig.Subnets = append(awsConfig.Subnets, iaas.AWSConfigSubnet{ID: subnet.ID, Range: cidrBlock, AZ: subnet.AZ, SecurityGroup: subnet.SecurityGroup})
manifestConfig.AZs = append(manifestConfig.AZs, consul.ConfigAZ{IPRange: cidrBlock, Nodes: count, Name: "z1"})
} else {
err = errors.New("AWSSubnet is required for AWS IAAS deployment")
return
}
iaasConfig = awsConfig
case "warden_cpi":
iaasConfig = iaas.NewWardenConfig()
var cidrBlock string
cidrPool := NewCIDRPool("10.244.4.0", 24, 27)
cidrBlock, err = cidrPool.Get(ginkgoConfig.GinkgoConfig.ParallelNode)
if err != nil {
return
}
manifestConfig.AZs = []consul.ConfigAZ{
{
IPRange: cidrBlock,
Nodes: count,
Name: "z1",
},
}
default:
err = errors.New("unknown infrastructure type")
return
}
manifest, err = manifestGenerator(manifestConfig, iaasConfig)
if err != nil {
return
}
for i := range manifest.Releases {
if manifest.Releases[i].Name == "consul" {
manifest.Releases[i].Version = releaseVersion
}
}
yaml, err := manifest.ToYAML()
if err != nil {
return
}
yaml, err = client.ResolveManifestVersions(yaml)
if err != nil {
return
}
err = consul.FromYAML(yaml, &manifest)
if err != nil {
return
}
_, err = client.Deploy(yaml)
if err != nil {
return
}
err = VerifyDeploymentRelease(client, manifestConfig.Name, releaseVersion)
if err != nil {
return
}
//.........这里部分代码省略.........
示例5: DeployMultiAZConsul
func DeployMultiAZConsul(deploymentPrefix string, client bosh.Client, config Config) (manifest consul.Manifest, err error) {
guid, err := NewGUID()
if err != nil {
return
}
info, err := client.Info()
if err != nil {
return
}
manifestConfig := consul.Config{
DirectorUUID: info.UUID,
Name: fmt.Sprintf("consul-%s-%s", deploymentPrefix, guid),
}
var iaasConfig iaas.Config
switch info.CPI {
case "aws_cpi":
awsConfig := buildAWSConfig(config)
if len(config.AWS.Subnets) >= 2 {
subnet := config.AWS.CloudConfigSubnets[0]
awsConfig.Subnets = append(awsConfig.Subnets, iaas.AWSConfigSubnet{ID: subnet.ID, Range: subnet.Range, AZ: subnet.AZ, SecurityGroup: subnet.SecurityGroup})
manifestConfig.Networks = append(manifestConfig.Networks, consul.ConfigNetwork{IPRange: subnet.Range, Nodes: 2})
subnet = config.AWS.CloudConfigSubnets[1]
awsConfig.Subnets = append(awsConfig.Subnets, iaas.AWSConfigSubnet{ID: subnet.ID, Range: subnet.Range, AZ: subnet.AZ, SecurityGroup: subnet.SecurityGroup})
manifestConfig.Networks = append(manifestConfig.Networks, consul.ConfigNetwork{IPRange: subnet.Range, Nodes: 1})
} else {
err = errors.New("AWSSubnet is required for AWS IAAS deployment")
return
}
iaasConfig = awsConfig
case "warden_cpi":
iaasConfig = iaas.NewWardenConfig()
manifestConfig.Networks = []consul.ConfigNetwork{
{IPRange: "10.244.4.0/24", Nodes: 2},
{IPRange: "10.244.5.0/24", Nodes: 1},
}
default:
err = errors.New("unknown infrastructure type")
return
}
manifest, err = consul.NewManifest(manifestConfig, iaasConfig)
if err != nil {
return
}
for i := range manifest.Releases {
if manifest.Releases[i].Name == "consul" {
manifest.Releases[i].Version = ConsulReleaseVersion()
}
}
yaml, err := manifest.ToYAML()
if err != nil {
return
}
yaml, err = client.ResolveManifestVersions(yaml)
if err != nil {
return
}
err = consul.FromYAML(yaml, &manifest)
if err != nil {
return
}
_, err = client.Deploy(yaml)
if err != nil {
return
}
err = VerifyDeploymentRelease(client, manifestConfig.Name, ConsulReleaseVersion())
if err != nil {
return
}
return
}
示例6:
- 10.244.4.44
stemcell: default
vm_type: default
properties:
consul:
agent:
datacenter: dc1
domain: cf.internal
releases:
- name: consul
version: 2.0.0
- name: consats
version: latest
`
resolvedManifest, err := client.ResolveManifestVersions([]byte(manifest))
Expect(err).NotTo(HaveOccurred())
Expect(resolvedManifest).To(gomegamatchers.MatchYAML(`---
director_uuid: some-director-uuid
name: some-name
stemcells:
- alias: default
name: some-stemcell-name
version: "2"
instance_groups:
- azs:
- z1
instances: 3
jobs:
- name: consul_agent
release: consul