本文整理匯總了Golang中github.com/cloudfoundry/bosh-init/deployment/manifest.Manifest.NetworkInterfaces方法的典型用法代碼示例。如果您正苦於以下問題:Golang Manifest.NetworkInterfaces方法的具體用法?Golang Manifest.NetworkInterfaces怎麽用?Golang Manifest.NetworkInterfaces使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-init/deployment/manifest.Manifest
的用法示例。
在下文中一共展示了Manifest.NetworkInterfaces方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: BuildInitialState
func (b *builder) BuildInitialState(jobName string, instanceID int, deploymentManifest bideplmanifest.Manifest) (State, error) {
deploymentJob, found := deploymentManifest.FindJobByName(jobName)
if !found {
return nil, bosherr.Errorf("Job '%s' not found in deployment manifest", jobName)
}
networkInterfaces, err := deploymentManifest.NetworkInterfaces(deploymentJob.Name)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Finding networks for job '%s", jobName)
}
// convert map to array
networkRefs := make([]NetworkRef, 0, len(networkInterfaces))
for networkName, networkInterface := range networkInterfaces {
genericMap := make(map[string]interface{}, len(networkInterface))
for k, v := range networkInterface {
genericMap[k] = v
}
networkRefs = append(networkRefs, NetworkRef{
Name: networkName,
Interface: genericMap,
})
}
return &state{
deploymentName: deploymentManifest.Name,
name: jobName,
id: instanceID,
networks: networkRefs,
}, nil
}
示例2: Create
func (m *manager) Create(stemcell bistemcell.CloudStemcell, deploymentManifest bideplmanifest.Manifest) (VM, error) {
jobName := deploymentManifest.JobName()
networkInterfaces, err := deploymentManifest.NetworkInterfaces(jobName)
m.logger.Debug(m.logTag, "Creating VM with network interfaces: %#v", networkInterfaces)
if err != nil {
return nil, bosherr.WrapError(err, "Getting network spec")
}
resourcePool, err := deploymentManifest.ResourcePool(jobName)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Getting resource pool for job '%s'", jobName)
}
agentID, err := m.uuidGenerator.Generate()
if err != nil {
return nil, bosherr.WrapError(err, "Generating agent ID")
}
cid, err := m.createAndRecordVm(agentID, stemcell, resourcePool, networkInterfaces)
if err != nil {
return nil, err
}
metadata := bicloud.VMMetadata{
Deployment: deploymentManifest.Name,
Job: deploymentManifest.JobName(),
Index: "0",
Director: "bosh-init",
}
err = m.cloud.SetVMMetadata(cid, metadata)
if err != nil {
cloudErr, ok := err.(bicloud.Error)
if ok && cloudErr.Type() == bicloud.NotImplementedError {
//ignore it
} else {
return nil, bosherr.WrapErrorf(err, "Setting VM metadata to %s", metadata)
}
}
vm := NewVM(
cid,
m.vmRepo,
m.stemcellRepo,
m.diskDeployer,
m.agentClient,
m.cloud,
m.fs,
m.logger,
)
return vm, nil
}
示例3: Build
func (b *builder) Build(jobName string, instanceID int, deploymentManifest bideplmanifest.Manifest, stage biui.Stage) (State, error) {
deploymentJob, found := deploymentManifest.FindJobByName(jobName)
if !found {
return nil, bosherr.Errorf("Job '%s' not found in deployment manifest", jobName)
}
releaseJobs, err := b.resolveJobs(deploymentJob.Templates)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Resolving jobs for instance '%s/%d'", jobName, instanceID)
}
renderedJobTemplates, err := b.renderJobTemplates(releaseJobs, deploymentJob.Properties, deploymentManifest.Properties, deploymentManifest.Name, stage)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Rendering job templates for instance '%s/%d'", jobName, instanceID)
}
compiledPackageRefs, err := b.jobDependencyCompiler.Compile(releaseJobs, stage)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Compiling job package dependencies for instance '%s/%d'", jobName, instanceID)
}
networkInterfaces, err := deploymentManifest.NetworkInterfaces(deploymentJob.Name)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Finding networks for job '%s", jobName)
}
// convert map to array
networkRefs := make([]NetworkRef, 0, len(networkInterfaces))
for networkName, networkInterface := range networkInterfaces {
networkRefs = append(networkRefs, NetworkRef{
Name: networkName,
Interface: networkInterface,
})
}
compiledDeploymentPackageRefs := make([]PackageRef, len(compiledPackageRefs), len(compiledPackageRefs))
for i, compiledPackageRef := range compiledPackageRefs {
compiledDeploymentPackageRefs[i] = PackageRef{
Name: compiledPackageRef.Name,
Version: compiledPackageRef.Version,
Archive: BlobRef{
BlobstoreID: compiledPackageRef.BlobstoreID,
SHA1: compiledPackageRef.SHA1,
},
}
}
// convert array to array
renderedJobRefs := make([]JobRef, len(releaseJobs), len(releaseJobs))
for i, releaseJob := range releaseJobs {
renderedJobRefs[i] = JobRef{
Name: releaseJob.Name,
Version: releaseJob.Fingerprint,
}
}
renderedJobListArchiveBlobRef := BlobRef{
BlobstoreID: renderedJobTemplates.BlobstoreID,
SHA1: renderedJobTemplates.Archive.SHA1(),
}
return &state{
deploymentName: deploymentManifest.Name,
name: jobName,
id: instanceID,
networks: networkRefs,
compiledPackages: compiledDeploymentPackageRefs,
renderedJobs: renderedJobRefs,
renderedJobListArchive: renderedJobListArchiveBlobRef,
hash: renderedJobTemplates.Archive.Fingerprint(),
}, nil
}
示例4: Create
func (m *manager) Create(stemcell bistemcell.CloudStemcell, deploymentManifest bideplmanifest.Manifest) (VM, error) {
jobName := deploymentManifest.JobName()
networkInterfaces, err := deploymentManifest.NetworkInterfaces(jobName)
m.logger.Debug(m.logTag, "Creating VM with network interfaces: %#v", networkInterfaces)
if err != nil {
return nil, bosherr.WrapError(err, "Getting network spec")
}
resourcePool, err := deploymentManifest.ResourcePool(jobName)
if err != nil {
return nil, bosherr.WrapErrorf(err, "Getting resource pool for job '%s'", jobName)
}
agentID, found, err := m.vmRepo.FindCurrentAgentId()
if err != nil {
return nil, bosherr.WrapError(err, "Finding currently agent id of deployed vm")
}
if !found {
agentID, err = m.uuidGenerator.Generate()
if err != nil {
return nil, bosherr.WrapError(err, "Generating agent ID")
}
}
currentIP, found, err := m.vmRepo.FindCurrentIP()
if err != nil {
return nil, bosherr.WrapError(err, "Finding currently IP address of deployed vm")
}
ifaceMap := map[string]biproperty.Map{}
if found {
for networkName, networkInterface := range networkInterfaces {
networkInterface["ip"] = currentIP
ifaceMap[networkName] = networkInterface
}
} else {
ifaceMap = networkInterfaces
}
cid, err := m.createAndRecordVm(agentID, stemcell, resourcePool, ifaceMap)
if err != nil {
return nil, err
}
metadata := bicloud.VMMetadata{
Deployment: deploymentManifest.Name,
Job: deploymentManifest.JobName(),
Index: "0",
Director: "bosh-init",
}
err = m.cloud.SetVMMetadata(cid, metadata)
if err != nil {
cloudErr, ok := err.(bicloud.Error)
if ok && cloudErr.Type() == bicloud.NotImplementedError {
//ignore it
} else {
return nil, bosherr.WrapErrorf(err, "Setting VM metadata to %s", metadata)
}
}
vm := NewVM(
cid,
m.vmRepo,
m.stemcellRepo,
m.diskDeployer,
m.agentClient,
m.cloud,
m.fs,
m.logger,
)
return vm, nil
}