本文整理匯總了Golang中github.com/cloudfoundry/bosh-init/ui.Stage.PerformComplex方法的典型用法代碼示例。如果您正苦於以下問題:Golang Stage.PerformComplex方法的具體用法?Golang Stage.PerformComplex怎麽用?Golang Stage.PerformComplex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-init/ui.Stage
的用法示例。
在下文中一共展示了Stage.PerformComplex方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: installCpiRelease
func (i CpiInstaller) installCpiRelease(installer biinstall.Installer, installationManifest biinstallmanifest.Manifest, target biinstall.Target, stage biui.Stage) (biinstall.Installation, error) {
var installation biinstall.Installation
var err error
err = stage.PerformComplex("installing CPI", func(installStage biui.Stage) error {
installation, err = installer.Install(installationManifest, installStage)
return err
})
if err != nil {
return installation, bosherr.WrapError(err, "Installing CPI")
}
return installation, nil
}
示例2: findCurrentDeploymentAndDelete
func (c *deploymentDeleter) findCurrentDeploymentAndDelete(stage biui.Stage, deploymentManager bidepl.Manager) error {
c.logger.Debug(c.logTag, "Finding current deployment...")
deployment, found, err := deploymentManager.FindCurrent()
if err != nil {
return bosherr.WrapError(err, "Finding current deployment")
}
return stage.PerformComplex("deleting deployment", func(deleteStage biui.Stage) error {
if !found {
//TODO: skip? would require adding skip support to PerformComplex
c.logger.Debug(c.logTag, "No current deployment found...")
return nil
}
return deployment.Delete(deleteStage)
})
}
示例3: PrepareDeployment
func (c *DeploymentPreparer) PrepareDeployment(stage biui.Stage) (err error) {
c.ui.PrintLinef("Deployment state: '%s'", c.deploymentStateService.Path())
if !c.deploymentStateService.Exists() {
migrated, err := c.legacyDeploymentStateMigrator.MigrateIfExists(biconfig.LegacyDeploymentStatePath(c.deploymentManifestPath))
if err != nil {
return bosherr.WrapError(err, "Migrating legacy deployment state file")
}
if migrated {
c.ui.PrintLinef("Migrated legacy deployments file: '%s'", biconfig.LegacyDeploymentStatePath(c.deploymentManifestPath))
}
}
deploymentState, err := c.deploymentStateService.Load()
if err != nil {
return bosherr.WrapError(err, "Loading deployment state")
}
target, err := c.targetProvider.NewTarget()
if err != nil {
return bosherr.WrapError(err, "Determining installation target")
}
err = c.tempRootConfigurator.PrepareAndSetTempRoot(target.TmpPath(), c.logger)
if err != nil {
return bosherr.WrapError(err, "Setting temp root")
}
defer func() {
err := c.releaseManager.DeleteAll()
if err != nil {
c.logger.Warn(c.logTag, "Deleting all extracted releases: %s", err.Error())
}
}()
var (
extractedStemcell bistemcell.ExtractedStemcell
deploymentManifest bideplmanifest.Manifest
installationManifest biinstallmanifest.Manifest
)
err = stage.PerformComplex("validating", func(stage biui.Stage) error {
var releaseSetManifest birelsetmanifest.Manifest
releaseSetManifest, installationManifest, err = c.releaseSetAndInstallationManifestParser.ReleaseSetAndInstallationManifest(c.deploymentManifestPath)
if err != nil {
return err
}
for _, releaseRef := range releaseSetManifest.Releases {
err = c.releaseFetcher.DownloadAndExtract(releaseRef, stage)
if err != nil {
return err
}
}
err := c.cpiInstaller.ValidateCpiRelease(installationManifest, stage)
if err != nil {
return err
}
deploymentManifest, err = c.deploymentManifestParser.GetDeploymentManifest(c.deploymentManifestPath, releaseSetManifest, stage)
if err != nil {
return err
}
extractedStemcell, err = c.stemcellFetcher.GetStemcell(deploymentManifest, stage)
nonCpiReleasesMap, _ := deploymentManifest.GetListOfTemplateReleases()
delete(nonCpiReleasesMap, installationManifest.Template.Release) // remove CPI release from nonCpiReleasesMap
for _, release := range c.releaseManager.List() {
if _, ok := nonCpiReleasesMap[release.Name()]; ok {
if release.IsCompiled() {
compilationOsAndVersion := release.Packages()[0].Stemcell
if strings.ToLower(compilationOsAndVersion) != strings.ToLower(extractedStemcell.OsAndVersion()) {
return bosherr.Errorf("OS/Version mismatch between deployment stemcell and compiled package stemcell for release '%s'", release.Name())
}
}
} else {
// It is a CPI release, check if it is compiled
if release.IsCompiled() {
return bosherr.Errorf("CPI is not allowed to be a compiled release. The provided CPI release '%s' is compiled", release.Name())
}
}
}
return err
})
if err != nil {
return err
}
defer func() {
deleteErr := extractedStemcell.Delete()
if deleteErr != nil {
c.logger.Warn(c.logTag, "Failed to delete extracted stemcell: %s", deleteErr.Error())
}
}()
isDeployed, err := c.deploymentRecord.IsDeployed(c.deploymentManifestPath, c.releaseManager.List(), extractedStemcell)
if err != nil {
return bosherr.WrapError(err, "Checking if deployment has changed")
//.........這裏部分代碼省略.........
示例4: deploy
func (c *DeploymentPreparer) deploy(
installation biinstall.Installation,
deploymentState biconfig.DeploymentState,
extractedStemcell bistemcell.ExtractedStemcell,
installationManifest biinstallmanifest.Manifest,
deploymentManifest bideplmanifest.Manifest,
stage biui.Stage,
) (err error) {
cloud, err := c.cloudFactory.NewCloud(installation, deploymentState.DirectorID)
if err != nil {
return bosherr.WrapError(err, "Creating CPI client from CPI installation")
}
stemcellManager := c.stemcellManagerFactory.NewManager(cloud)
cloudStemcell, err := stemcellManager.Upload(extractedStemcell, stage)
if err != nil {
return err
}
agentClient := c.agentClientFactory.NewAgentClient(deploymentState.DirectorID, installationManifest.Mbus)
vmManager := c.vmManagerFactory.NewManager(cloud, agentClient)
blobstore, err := c.blobstoreFactory.Create(installationManifest.Mbus)
if err != nil {
return bosherr.WrapError(err, "Creating blobstore client")
}
err = stage.PerformComplex("deploying", func(deployStage biui.Stage) error {
err = c.deploymentRecord.Clear()
if err != nil {
return bosherr.WrapError(err, "Clearing deployment record")
}
_, err = c.deployer.Deploy(
cloud,
deploymentManifest,
cloudStemcell,
installationManifest.Registry,
vmManager,
blobstore,
deployStage,
)
if err != nil {
return bosherr.WrapError(err, "Deploying")
}
err = c.deploymentRecord.Update(c.deploymentManifestPath, c.releaseManager.List())
if err != nil {
return bosherr.WrapError(err, "Updating deployment record")
}
return nil
})
if err != nil {
return err
}
// TODO: cleanup unused disks here?
err = stemcellManager.DeleteUnused(stage)
if err != nil {
return err
}
return nil
}
示例5: DeleteDeployment
func (c *deploymentDeleter) DeleteDeployment(stage biui.Stage) (err error) {
c.ui.PrintLinef("Deployment state: '%s'", c.deploymentStateService.Path())
if !c.deploymentStateService.Exists() {
c.ui.PrintLinef("No deployment state file found.")
return nil
}
deploymentState, err := c.deploymentStateService.Load()
if err != nil {
return bosherr.WrapError(err, "Loading deployment state")
}
target, err := c.targetProvider.NewTarget()
if err != nil {
return bosherr.WrapError(err, "Determining installation target")
}
err = c.tempRootConfigurator.PrepareAndSetTempRoot(target.TmpPath(), c.logger)
if err != nil {
return bosherr.WrapError(err, "Setting temp root")
}
defer func() {
err := c.releaseManager.DeleteAll()
if err != nil {
c.logger.Warn(c.logTag, "Deleting all extracted releases: %s", err.Error())
}
}()
var installationManifest biinstallmanifest.Manifest
err = stage.PerformComplex("validating", func(stage biui.Stage) error {
var releaseSetManifest birelsetmanifest.Manifest
releaseSetManifest, installationManifest, err = c.releaseSetAndInstallationManifestParser.ReleaseSetAndInstallationManifest(c.deploymentManifestPath)
if err != nil {
return err
}
cpiReleaseName := installationManifest.Template.Release
cpiReleaseRef, found := releaseSetManifest.FindByName(cpiReleaseName)
if !found {
return bosherr.Errorf("installation release '%s' must refer to a release in releases", cpiReleaseName)
}
err = c.releaseFetcher.DownloadAndExtract(cpiReleaseRef, stage)
if err != nil {
return err
}
err = c.cpiInstaller.ValidateCpiRelease(installationManifest, stage)
return err
})
if err != nil {
return err
}
err = c.cpiInstaller.WithInstalledCpiRelease(installationManifest, target, stage, func(localCpiInstallation biinstall.Installation) error {
return localCpiInstallation.WithRunningRegistry(c.logger, stage, func() error {
err = c.findAndDeleteDeployment(stage, localCpiInstallation, deploymentState.DirectorID, installationManifest.Mbus)
if err != nil {
return err
}
return stage.Perform("Uninstalling local artifacts for CPI and deployment", func() error {
err := c.cpiUninstaller.Uninstall(localCpiInstallation.Target())
if err != nil {
return err
}
return c.deploymentStateService.Cleanup()
})
})
})
return err
}
示例6: PrepareDeployment
func (c *DeploymentPreparer) PrepareDeployment(stage biui.Stage) (err error) {
c.ui.PrintLinef("Deployment state: '%s'", c.deploymentStateService.Path())
if !c.deploymentStateService.Exists() {
migrated, err := c.legacyDeploymentStateMigrator.MigrateIfExists(biconfig.LegacyDeploymentStatePath(c.deploymentManifestPath))
if err != nil {
return bosherr.WrapError(err, "Migrating legacy deployment state file")
}
if migrated {
c.ui.PrintLinef("Migrated legacy deployments file: '%s'", biconfig.LegacyDeploymentStatePath(c.deploymentManifestPath))
}
}
deploymentState, err := c.deploymentStateService.Load()
if err != nil {
return bosherr.WrapError(err, "Loading deployment state")
}
target, err := c.targetProvider.NewTarget()
if err != nil {
return bosherr.WrapError(err, "Determining installation target")
}
err = c.tempRootConfigurator.PrepareAndSetTempRoot(target.TmpPath(), c.logger)
if err != nil {
return bosherr.WrapError(err, "Setting temp root")
}
defer func() {
err := c.releaseManager.DeleteAll()
if err != nil {
c.logger.Warn(c.logTag, "Deleting all extracted releases: %s", err.Error())
}
}()
var (
extractedStemcell bistemcell.ExtractedStemcell
deploymentManifest bideplmanifest.Manifest
installationManifest biinstallmanifest.Manifest
)
err = stage.PerformComplex("validating", func(stage biui.Stage) error {
var releaseSetManifest birelsetmanifest.Manifest
releaseSetManifest, installationManifest, err = c.releaseSetAndInstallationManifestParser.ReleaseSetAndInstallationManifest(c.deploymentManifestPath)
if err != nil {
return err
}
for _, releaseRef := range releaseSetManifest.Releases {
err = c.releaseFetcher.DownloadAndExtract(releaseRef, stage)
if err != nil {
return err
}
}
err := c.cpiInstaller.ValidateCpiRelease(installationManifest, stage)
if err != nil {
return err
}
deploymentManifest, err = c.deploymentManifestParser.GetDeploymentManifest(c.deploymentManifestPath, releaseSetManifest, stage)
if err != nil {
return err
}
extractedStemcell, err = c.stemcellFetcher.GetStemcell(deploymentManifest, stage)
return err
})
if err != nil {
return err
}
defer func() {
deleteErr := extractedStemcell.Delete()
if deleteErr != nil {
c.logger.Warn(c.logTag, "Failed to delete extracted stemcell: %s", deleteErr.Error())
}
}()
isDeployed, err := c.deploymentRecord.IsDeployed(c.deploymentManifestPath, c.releaseManager.List(), extractedStemcell)
if err != nil {
return bosherr.WrapError(err, "Checking if deployment has changed")
}
if isDeployed {
c.ui.PrintLinef("No deployment, stemcell or release changes. Skipping deploy.")
return nil
}
err = c.cpiInstaller.WithInstalledCpiRelease(installationManifest, target, stage, func(installation biinstall.Installation) error {
return installation.WithRunningRegistry(c.logger, stage, func() error {
return c.deploy(
installation,
deploymentState,
extractedStemcell,
installationManifest,
deploymentManifest,
stage)
})
})
return err
//.........這裏部分代碼省略.........