示例#1
0
// Finishes the copy state of source system into destination and makes this system the active one
func deploymentMigrationFinalizeDeprecated(c *cli.Context) error {
	fmt.Printf("'%d'", len(c.Args()))
	err := checkArgCount(c, 1)
	if err != nil {
		return err
	}
	sourceAddress := c.Args().First()
	client.Esxclient, err = client.GetClient(c)
	if err != nil {
		return err
	}
	deployments, err := client.Esxclient.Deployments.GetAll()
	if err != nil {
		return err
	}
	finalizeMigrationSpec := photon.FinalizeMigrationOperation{}
	finalizeMigrationSpec.SourceNodeGroupReference = sourceAddress

	// Finalize deployment migration
	for _, deployment := range deployments.Items {
		finalizeMigrate, err := client.Esxclient.Deployments.FinalizeDeploymentMigration(&finalizeMigrationSpec, deployment.ID)
		if err != nil {
			return err
		}
		_, err = pollTask(finalizeMigrate.ID)
		if err != nil {
			return err
		}

		return nil
	}

	return nil
}
示例#2
0
// Finishes the copy state of source system into destination and makes this system the active one
func deploymentMigrationFinalize(c *cli.Context) error {
	id, err := getDeploymentId(c)
	if err != nil {
		return err
	}

	sourceAddress := c.String("endpoint")
	if len(sourceAddress) == 0 {
		return fmt.Errorf("Please provide the API endpoint of the old control plane")
	}

	client.Esxclient, err = client.GetClient(c)
	if err != nil {
		return err
	}

	deployment, err := client.Esxclient.Deployments.Get(id)
	if err != nil {
		return err
	}
	finalizeMigrationSpec := photon.FinalizeMigrationOperation{}
	finalizeMigrationSpec.SourceNodeGroupReference = sourceAddress

	// Finalize deployment migration
	finalizeMigrate, err := client.Esxclient.Deployments.FinalizeDeploymentMigration(&finalizeMigrationSpec, deployment.ID)
	if err != nil {
		return err
	}

	_, err = waitOnTaskOperation(finalizeMigrate.ID, c)
	if err != nil {
		return err
	}

	err = deploymentJsonHelper(c, id, client.Esxclient)
	if err != nil {
		return err
	}

	return nil
}