本文整理汇总了Golang中github.com/vmware/photon-controller-cli/photon/client.GetClient函数的典型用法代码示例。如果您正苦于以下问题:Golang GetClient函数的具体用法?Golang GetClient怎么用?Golang GetClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetClient函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: deploymentMigrationFinalizeDeprecated
// 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 := checkArgNum(c.Args(), 1, "system migration finalize <old_management_endpoint>")
if err != nil {
return err
}
sourceAddress := c.Args().First()
client.Esxclient, err = client.GetClient(c.GlobalIsSet("non-interactive"))
if err != nil {
return err
}
deployments, err := client.Esxclient.Deployments.GetAll()
if err != nil {
return err
}
finalizeMigrationSpec := photon.FinalizeMigrationOperation{}
finalizeMigrationSpec.SourceLoadBalancerAddress = 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
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:35,代码来源:system.go
示例2: addHosts
// Add most hosts in batch mode
func addHosts(c *cli.Context) error {
err := checkArgNum(c.Args(), 1, "system addHosts <file>")
if err != nil {
return err
}
file := c.Args().First()
dcMap, err := manifest.LoadInstallation(file)
if err != nil {
return err
}
client.Esxclient, err = client.GetClient(false)
if err != nil {
return err
}
deployments, err := client.Esxclient.Deployments.GetAll()
deploymentID := deployments.Items[0].ID
// Create Hosts
err = createHostsInBatch(dcMap, deploymentID)
if err != nil {
return err
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:28,代码来源:system.go
示例3: deploymentMigrationPrepareDeprecated
// Starts the recurring copy state of source system into destination
func deploymentMigrationPrepareDeprecated(c *cli.Context) error {
err := checkArgNum(c.Args(), 1, "system migration prepare <old_management_endpoint>")
if err != nil {
return err
}
sourceAddress := c.Args().First()
client.Esxclient, err = client.GetClient(c.GlobalIsSet("non-interactive"))
if err != nil {
return err
}
deployments, err := client.Esxclient.Deployments.GetAll()
if err != nil {
return err
}
initializeMigrationSpec := photon.InitializeMigrationOperation{}
initializeMigrationSpec.SourceLoadBalancerAddress = sourceAddress
// Initialize deployment migration
for _, deployment := range deployments.Items {
initializeMigrate, err := client.Esxclient.Deployments.InitializeDeploymentMigration(&initializeMigrationSpec, deployment.ID)
if err != nil {
return err
}
_, err = pollTask(initializeMigrate.ID)
if err != nil {
return err
}
fmt.Printf("Deployment '%s' migration started [source management endpoint: '%s'].\n", deployment.ID, sourceAddress)
return nil
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:35,代码来源:system.go
示例4: listTasks
// Retrieves a list of tasks, returns an error if one occurred
func listTasks(c *cli.Context) error {
err := checkArgNum(c.Args(), 0, "task list <options>")
if err != nil {
return err
}
entityId := c.String("entityId")
entityKind := c.String("entityKind")
state := c.String("state")
client.Esxclient, err = client.GetClient(c.GlobalIsSet("non-interactive"))
if err != nil {
return err
}
options := &photon.TaskGetOptions{
State: state,
EntityID: entityId,
EntityKind: entityKind,
}
taskList, err := client.Esxclient.Tasks.GetAll(options)
if err != nil {
return err
}
err = printTaskList(taskList.Items, c)
if err != nil {
return err
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:31,代码来源:tasks.go
示例5: deploy
// Deploy Photon Controller based on DC_map
func deploy(c *cli.Context) error {
err := checkArgNum(c.Args(), 1, "system deploy <file>")
if err != nil {
return err
}
file := c.Args().First()
dcMap, err := manifest.LoadInstallation(file)
if err != nil {
return err
}
client.Esxclient, err = client.GetClient(false)
if err != nil {
return err
}
deploymentID, err := createDeploymentFromDcMap(dcMap)
if err != nil {
return err
}
// Create Hosts
err = createHostsFromDcMap(dcMap, deploymentID)
if err != nil {
return err
}
// Deploy
err = doDeploy(dcMap, deploymentID)
if err != nil {
return err
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:36,代码来源:system.go
示例6: monitorTask
// Track the progress of the task, returns an error if one occurred
func monitorTask(c *cli.Context) error {
err := checkArgNum(c.Args(), 1, "task monitor <task id>")
if err != nil {
return err
}
id := c.Args()[0]
client.Esxclient, err = client.GetClient(c.GlobalIsSet("non-interactive"))
if err != nil {
return err
}
if c.GlobalIsSet("non-interactive") {
task, err := client.Esxclient.Tasks.Wait(id)
if err != nil {
return err
}
fmt.Printf("%s\t%s\t%s\t%s\n", task.ID, task.State, task.Entity.ID, task.Entity.Kind)
} else {
task, err := pollTask(id)
if err != nil {
return err
}
w := new(tabwriter.Writer)
w.Init(os.Stdout, 4, 4, 2, ' ', 0)
fmt.Fprintf(w, "Task:\t%s\n", task.ID)
fmt.Fprintf(w, "Entity:\t%s %s\n", task.Entity.Kind, task.Entity.ID)
fmt.Fprintf(w, "State:\t%s\n", task.State)
err = w.Flush()
if err != nil {
return err
}
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:36,代码来源:tasks.go
示例7: setHostAvailabilityZone
// Set host's availability zone with the specified host ID, returns an error if one occurred
func setHostAvailabilityZone(c *cli.Context, w io.Writer) error {
err := checkArgNum(c.Args(), 2, "host set-availability-zone <id> <availability-zone-id>")
if err != nil {
return err
}
id := c.Args().First()
availabilityZoneId := c.Args()[1]
client.Esxclient, err = client.GetClient(utils.IsNonInteractive(c))
if err != nil {
return err
}
setAvailabilityZoneSpec := photon.HostSetAvailabilityZoneOperation{}
setAvailabilityZoneSpec.AvailabilityZoneId = availabilityZoneId
setTask, err := client.Esxclient.Hosts.SetAvailabilityZone(id, &setAvailabilityZoneSpec)
if err != nil {
return err
}
id, err = waitOnTaskOperation(setTask.ID, c)
if err != nil {
return err
}
if utils.NeedsFormatting(c) {
host, err := client.Esxclient.Hosts.Get(id)
if err != nil {
return err
}
utils.FormatObject(host, w, c)
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:34,代码来源:hosts.go
示例8: listHosts
// List all the hosts in the current deployment
// This uses the same back-end code as "deployments list-hosts", but we look up the
// deployment ID so that users don't have to specify it. In most or all installations,
// there will not be more than one deployment ID.
func listHosts(c *cli.Context, w io.Writer) error {
err := checkArgNum(c.Args(), 0, "host list")
if err != nil {
return err
}
client.Esxclient, err = client.GetClient(utils.IsNonInteractive(c))
if err != nil {
return err
}
// Find the current deployment
deployments, err := client.Esxclient.Deployments.GetAll()
if err != nil {
return err
}
numDeployments := len(deployments.Items)
if numDeployments == 0 {
return fmt.Errorf("There are no deployments, so the hosts cannot be listed.")
} else if numDeployments > 1 {
return fmt.Errorf("There are multiple deployments, which normally should not happen. Use deployments list-hosts.")
}
id := deployments.Items[0].ID
hosts, err := client.Esxclient.Deployments.GetHosts(id)
if err != nil {
return err
}
err = printHostList(hosts.Items, w, c)
if err != nil {
return err
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:39,代码来源:hosts.go
示例9: showMigrationStatusDeprecated
// displays the migration status
func showMigrationStatusDeprecated(c *cli.Context) error {
err := checkArgNum(c.Args(), 0, "migration status")
if err != nil {
return err
}
client.Esxclient, err = client.GetClient(c.GlobalIsSet("non-interactive"))
if err != nil {
return err
}
deployments, err := client.Esxclient.Deployments.GetAll()
if err != nil {
return err
}
for _, deployment := range deployments.Items {
if deployment.Migration != nil {
migration := deployment.Migration
if c.GlobalIsSet("non-interactive") {
fmt.Printf("%d\t%d\t%d\t%d\t%d\n", migration.CompletedDataMigrationCycles, migration.DataMigrationCycleProgress,
migration.DataMigrationCycleSize, migration.VibsUploaded, migration.VibsUploading+migration.VibsUploaded)
} else {
fmt.Printf(" Migration status:\n")
fmt.Printf(" Completed data migration cycles: %d\n", migration.CompletedDataMigrationCycles)
fmt.Printf(" Current data migration cycles progress: %d / %d\n", migration.DataMigrationCycleProgress,
migration.DataMigrationCycleSize)
fmt.Printf(" VIB upload progress: %d / %d\n", migration.VibsUploaded, migration.VibsUploading+migration.VibsUploaded)
}
}
return nil
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:33,代码来源:system.go
示例10: showNetwork
func showNetwork(c *cli.Context, w io.Writer) error {
err := checkArgNum(c.Args(), 1, "network show <id>")
if err != nil {
return err
}
id := c.Args().First()
client.Esxclient, err = client.GetClient(utils.IsNonInteractive(c))
if err != nil {
return err
}
network, err := client.Esxclient.Subnets.Get(id)
if err != nil {
return err
}
if c.GlobalIsSet("non-interactive") {
portGroups := getCommaSeparatedStringFromStringArray(network.PortGroups)
fmt.Printf("%s\t%s\t%s\t%s\t%s\t%t\n", network.ID, network.Name, network.State, portGroups,
network.Description, network.IsDefault)
} else if utils.NeedsFormatting(c) {
utils.FormatObject(network, w, c)
} else {
fmt.Printf("Network ID: %s\n", network.ID)
fmt.Printf(" Name: %s\n", network.Name)
fmt.Printf(" State: %s\n", network.State)
fmt.Printf(" Description: %s\n", network.Description)
fmt.Printf(" Port Groups: %s\n", network.PortGroups)
fmt.Printf(" Is Default: %t\n", network.IsDefault)
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:34,代码来源:networks.go
示例11: getFlavorTasks
// Retrieves tasks from specified flavor
func getFlavorTasks(c *cli.Context, w io.Writer) error {
err := checkArgNum(c.Args(), 1, "flavor tasks <id> [<options>]")
if err != nil {
return err
}
id := c.Args().First()
state := c.String("state")
options := &photon.TaskGetOptions{
State: state,
}
client.Esxclient, err = client.GetClient(utils.IsNonInteractive(c))
if err != nil {
return err
}
taskList, err := client.Esxclient.Flavors.GetTasks(id, options)
if err != nil {
return err
}
err = printTaskList(taskList.Items, c)
if err != nil {
return err
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:29,代码来源:flavors.go
示例12: detachDisk
func detachDisk(c *cli.Context) error {
err := checkArgNum(c.Args(), 1, "vm detach-disk --disk <id> <vm-id>")
if err != nil {
return err
}
id := c.Args().First()
diskID := c.String("disk")
client.Esxclient, err = client.GetClient(c.GlobalIsSet("non-interactive"))
if err != nil {
return err
}
operation := &photon.VmDiskOperation{
DiskID: diskID,
}
task, err := client.Esxclient.VMs.DetachDisk(id, operation)
if err != nil {
return err
}
_, err = waitOnTaskOperation(task.ID, c)
if err != nil {
return err
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:30,代码来源:vms.go
示例13: showMigrationStatus
// displays the migration status
func showMigrationStatus(c *cli.Context) error {
id, err := getDeploymentId(c)
if err != nil {
return err
}
client.Esxclient, err = client.GetClient(c.GlobalIsSet("non-interactive"))
if err != nil {
return err
}
deployment, err := client.Esxclient.Deployments.Get(id)
if err != nil {
return err
}
if deployment.Migration == nil {
fmt.Print("No migration information available")
return nil
}
migration := deployment.Migration
if c.GlobalIsSet("non-interactive") {
fmt.Printf("%d\t%d\t%d\t%d\t%d\n", migration.CompletedDataMigrationCycles, migration.DataMigrationCycleProgress,
migration.DataMigrationCycleSize, migration.VibsUploaded, migration.VibsUploading+migration.VibsUploaded)
} else {
fmt.Printf(" Migration status:\n")
fmt.Printf(" Completed data migration cycles: %d\n", migration.CompletedDataMigrationCycles)
fmt.Printf(" Current data migration cycles progress: %d / %d\n", migration.DataMigrationCycleProgress,
migration.DataMigrationCycleSize)
fmt.Printf(" VIB upload progress: %d / %d\n", migration.VibsUploaded, migration.VibsUploading+migration.VibsUploaded)
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:36,代码来源:deployments.go
示例14: getVMTasks
// Retrieves tasks for VM
func getVMTasks(c *cli.Context) error {
err := checkArgNum(c.Args(), 1, "vm tasks <id> [<options>]")
if err != nil {
return err
}
id := c.Args().First()
state := c.String("state")
client.Esxclient, err = client.GetClient(c.GlobalIsSet("non-interactive"))
if err != nil {
return err
}
options := &photon.TaskGetOptions{
State: state,
}
taskList, err := client.Esxclient.VMs.GetTasks(id, options)
if err != nil {
return err
}
err = printTaskList(taskList.Items, c)
if err != nil {
return err
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:31,代码来源:vms.go
示例15: restartVM
func restartVM(c *cli.Context) error {
err := checkArgNum(c.Args(), 1, "vm restart <id>")
if err != nil {
return err
}
id := c.Args().First()
client.Esxclient, err = client.GetClient(c.GlobalIsSet("non-interactive"))
if err != nil {
return err
}
opTask, err := client.Esxclient.VMs.Restart(id)
if err != nil {
return err
}
_, err = waitOnTaskOperation(opTask.ID, c)
if err != nil {
return err
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:25,代码来源:vms.go
示例16: deleteTenant
// Sends a delete tenant task to client based on the cli.Context
// Returns an error if one occurred
func deleteTenant(c *cli.Context) error {
err := checkArgNum(c.Args(), 1, "tenant delete <id>")
if err != nil {
return err
}
id := c.Args().First()
client.Esxclient, err = client.GetClient(utils.IsNonInteractive(c))
if err != nil {
return err
}
deleteTask, err := client.Esxclient.Tenants.Delete(id)
if err != nil {
return err
}
_, err = waitOnTaskOperation(deleteTask.ID, c)
if err != nil {
return err
}
err = clearConfigTenant(id)
if err != nil {
return err
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:31,代码来源:tenants.go
示例17: getVMMksTicket
func getVMMksTicket(c *cli.Context) error {
err := checkArgNum(c.Args(), 1, "vm mks-ticket <id>")
if err != nil {
return err
}
id := c.Args().First()
client.Esxclient, err = client.GetClient(c.GlobalIsSet("non-interactive"))
if err != nil {
return err
}
task, err := client.Esxclient.VMs.GetMKSTicket(id)
if err != nil {
return err
}
if c.GlobalIsSet("non-interactive") {
task, err := client.Esxclient.Tasks.Wait(task.ID)
if err != nil {
return err
}
mksTicket := task.ResourceProperties.(map[string]interface{})
fmt.Printf("%s\t%v\n", task.Entity.ID, mksTicket["ticket"])
} else {
task, err = pollTask(task.ID)
if err != nil {
return err
}
mksTicket := task.ResourceProperties.(map[string]interface{})
fmt.Printf("VM ID: %s \nMks ticket ID is %v\n", task.Entity.ID, mksTicket["ticket"])
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:35,代码来源:vms.go
示例18: setSecurityGroups
// Set security groups for a tenant
func setSecurityGroups(c *cli.Context) error {
err := checkArgNum(c.Args(), 2, "tenant set_security_groups <id> <comma-separated security group names>")
if err != nil {
return err
}
id := c.Args().First()
items := []string{}
if c.Args()[1] != "" {
items = regexp.MustCompile(`\s*,\s*`).Split(c.Args()[1], -1)
}
securityGroups := &photon.SecurityGroupsSpec{
Items: items,
}
client.Esxclient, err = client.GetClient(utils.IsNonInteractive(c))
if err != nil {
return err
}
task, err := client.Esxclient.Tenants.SetSecurityGroups(id, securityGroups)
if err != nil {
return err
}
_, err = waitOnTaskOperation(task.ID, c)
if err != nil {
return err
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:32,代码来源:tenants.go
示例19: setDefaultNetwork
func setDefaultNetwork(c *cli.Context, w io.Writer) error {
err := checkArgNum(c.Args(), 1, "network set-default <id>")
if err != nil {
return err
}
id := c.Args().First()
client.Esxclient, err = client.GetClient(utils.IsNonInteractive(c))
if err != nil {
return err
}
task, err := client.Esxclient.Subnets.SetDefault(id)
if err != nil {
return err
}
if confirmed(utils.IsNonInteractive(c)) {
id, err := waitOnTaskOperation(task.ID, c)
if err != nil {
return err
}
if utils.NeedsFormatting(c) {
network, err := client.Esxclient.Subnets.Get(id)
if err != nil {
return err
}
utils.FormatObject(network, w, c)
}
} else {
fmt.Println("OK. Canceled")
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:35,代码来源:networks.go
示例20: showAvailabilityZone
// Retrieves availability zone against specified id.
func showAvailabilityZone(c *cli.Context, w io.Writer) error {
err := checkArgNum(c.Args(), 1, "availability-zone show <id>")
if err != nil {
return err
}
id := c.Args().First()
client.Esxclient, err = client.GetClient(utils.IsNonInteractive(c))
if err != nil {
return err
}
zone, err := client.Esxclient.AvailabilityZones.Get(id)
if err != nil {
return err
}
if c.GlobalIsSet("non-interactive") {
fmt.Printf("%s\t%s\t%s\t%s\n", zone.ID, zone.Name, zone.Kind, zone.State)
} else if utils.NeedsFormatting(c) {
utils.FormatObject(zone, w, c)
} else {
fmt.Printf("AvailabilityZone ID: %s\n", zone.ID)
fmt.Printf(" Name: %s\n", zone.Name)
fmt.Printf(" Kind: %s\n", zone.Kind)
fmt.Printf(" State: %s\n", zone.State)
}
return nil
}
开发者ID:vmware,项目名称:photon-controller-cli,代码行数:31,代码来源:availability-zone.go
注:本文中的github.com/vmware/photon-controller-cli/photon/client.GetClient函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论