本文整理汇总了Golang中github.com/toliaqat/photon-controller/cli/photon/client.GetClient函数的典型用法代码示例。如果您正苦于以下问题:Golang GetClient函数的具体用法?Golang GetClient怎么用?Golang GetClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetClient函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: monitorTask
// Track the progress of the task, returns an error if one occurred
func monitorTask(c *cli.Context) error {
err := checkArgCount(c, 1)
if err != nil {
return err
}
id := c.Args()[0]
client.Esxclient, err = client.GetClient(c)
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:toliaqat,项目名称:photon-controller,代码行数:36,代码来源:tasks.go
示例2: detachDisk
func detachDisk(c *cli.Context, w io.Writer) error {
err := checkArgCount(c, 1)
if err != nil {
return err
}
id := c.Args().First()
diskID := c.String("disk")
client.Esxclient, err = client.GetClient(c)
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
}
err = formatHelper(c, w, client.Esxclient, id)
return err
}
开发者ID:toliaqat,项目名称:photon-controller,代码行数:32,代码来源:vms.go
示例3: triggerMaintenance
// Sends a cluster trigger_maintenance request to the API client based on the cli.Context.
// Returns an error if one occurred.
func triggerMaintenance(c *cli.Context) error {
err := checkArgCount(c, 1)
if err != nil {
return nil
}
clusterId := c.Args().First()
if len(clusterId) == 0 {
return fmt.Errorf("Please provide a valid cluster ID")
}
client.Esxclient, err = client.GetClient(c)
if err != nil {
return err
}
if !c.GlobalIsSet("non-interactive") {
fmt.Printf("Maintenance triggered for cluster %s\n", clusterId)
}
task, err := client.Esxclient.Clusters.TriggerMaintenance(clusterId)
if err != nil {
return err
}
_, err = waitOnTaskOperation(task.ID, c)
if err != nil {
return err
}
return nil
}
开发者ID:toliaqat,项目名称:photon-controller,代码行数:35,代码来源:clusters.go
示例4: showPhysicalNetwork
func showPhysicalNetwork(c *cli.Context, w io.Writer) error {
err := checkArgCount(c, 1)
if err != nil {
return err
}
id := c.Args().First()
client.Esxclient, err = client.GetClient(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:toliaqat,项目名称:photon-controller,代码行数:34,代码来源:physical-networks.go
示例5: deleteProject
// Sends a delete project task to client based on the cli.Context
// Returns an error if one occurred
func deleteProject(c *cli.Context) error {
err := checkArgCount(c, 1)
if err != nil {
return err
}
id := c.Args().First()
client.Esxclient, err = client.GetClient(c)
if err != nil {
return err
}
deleteTask, err := client.Esxclient.Projects.Delete(id)
if err != nil {
return err
}
_, err = waitOnTaskOperation(deleteTask.ID, c)
if err != nil {
return err
}
err = clearConfigProject(id)
if err != nil {
return err
}
return nil
}
开发者ID:toliaqat,项目名称:photon-controller,代码行数:30,代码来源:projects.go
示例6: deploymentMigrationPrepareDeprecated
// Starts the recurring copy state of source system into destination
func deploymentMigrationPrepareDeprecated(c *cli.Context) error {
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
}
initializeMigrationSpec := photon.InitializeMigrationOperation{}
initializeMigrationSpec.SourceNodeGroupReference = 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:toliaqat,项目名称:photon-controller,代码行数:35,代码来源:system.go
示例7: showMigrationStatusDeprecated
// displays the migration status
func showMigrationStatusDeprecated(c *cli.Context) error {
err := checkArgCount(c, 0)
if err != nil {
return err
}
client.Esxclient, err = client.GetClient(c)
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:toliaqat,项目名称:photon-controller,代码行数:33,代码来源:system.go
示例8: detachIso
func detachIso(c *cli.Context, w io.Writer) error {
err := checkArgCount(c, 1)
if err != nil {
return err
}
id := c.Args().First()
client.Esxclient, err = client.GetClient(c)
if err != nil {
return err
}
task, err := client.Esxclient.VMs.DetachISO(id)
if err != nil {
return err
}
_, err = waitOnTaskOperation(task.ID, c)
if err != nil {
return err
}
err = formatHelper(c, w, client.Esxclient, id)
return err
}
开发者ID:toliaqat,项目名称:photon-controller,代码行数:27,代码来源:vms.go
示例9: listVMNetworks
func listVMNetworks(c *cli.Context, w io.Writer) error {
err := checkArgCount(c, 1)
if err != nil {
return err
}
id := c.Args().First()
client.Esxclient, err = client.GetClient(c)
if err != nil {
return err
}
networks, err := getVMNetworks(id, c)
if err != nil {
return err
}
if !utils.NeedsFormatting(c) {
err = printVMNetworks(networks, c.GlobalIsSet("non-interactive"))
if err != nil {
return err
}
} else {
utils.FormatObjects(networks, w, c)
}
return nil
}
开发者ID:toliaqat,项目名称:photon-controller,代码行数:28,代码来源:vms.go
示例10: pauseBackgroundTasks
// Sends a pause background task to client
func pauseBackgroundTasks(c *cli.Context) error {
id, err := getDeploymentId(c)
if err != nil {
return err
}
client.Esxclient, err = client.GetClient(c)
if err != nil {
return err
}
pauseBackgroundTask, err := client.Esxclient.Deployments.PauseBackgroundTasks(id)
if err != nil {
return err
}
_, err = waitOnTaskOperation(pauseBackgroundTask.ID, c)
if err != nil {
return err
}
err = deploymentJsonHelper(c, id, client.Esxclient)
if err != nil {
return err
}
return nil
}
开发者ID:toliaqat,项目名称:photon-controller,代码行数:29,代码来源:deployments.go
示例11: resumeSystem
// Sends a resume system task to client
func resumeSystem(c *cli.Context) error {
id, err := getDeploymentId(c)
if err != nil {
return err
}
client.Esxclient, err = client.GetClient(c)
if err != nil {
return err
}
resumeSystemTask, err := client.Esxclient.Deployments.ResumeSystem(id)
if err != nil {
return err
}
_, err = waitOnTaskOperation(resumeSystemTask.ID, c)
if err != nil {
return err
}
err = deploymentJsonHelper(c, id, client.Esxclient)
if err != nil {
return err
}
return nil
}
开发者ID:toliaqat,项目名称:photon-controller,代码行数:29,代码来源:deployments.go
示例12: syncHostsConfig
// Synchronizes hosts configurations
func syncHostsConfig(c *cli.Context) error {
id, err := getDeploymentId(c)
if err != nil {
return err
}
client.Esxclient, err = client.GetClient(c)
if err != nil {
return err
}
task, err := client.Esxclient.Deployments.SyncHostsConfig(id)
if err != nil {
return err
}
_, err = waitOnTaskOperation(task.ID, c)
if err != nil {
return err
}
err = deploymentJsonHelper(c, id, client.Esxclient)
if err != nil {
return err
}
return nil
}
开发者ID:toliaqat,项目名称:photon-controller,代码行数:29,代码来源:deployments.go
示例13: listDeploymentVms
// Lists all the hosts associated with the deployment
func listDeploymentVms(c *cli.Context, w io.Writer) error {
id, err := getDeploymentId(c)
if err != nil {
return err
}
client.Esxclient, err = client.GetClient(c)
if err != nil {
return err
}
vms, err := client.Esxclient.Deployments.GetVms(id)
if err != nil {
return err
}
if utils.NeedsFormatting(c) {
utils.FormatObjects(vms, w, c)
} else {
err = printVMList(vms.Items, os.Stdout, c, false)
if err != nil {
return err
}
}
return nil
}
开发者ID:toliaqat,项目名称:photon-controller,代码行数:28,代码来源:deployments.go
示例14: listTasks
// Retrieves a list of tasks, returns an error if one occurred
func listTasks(c *cli.Context) error {
err := checkArgCount(c, 0)
if err != nil {
return err
}
entityId := c.String("entityId")
entityKind := c.String("entityKind")
state := c.String("state")
client.Esxclient, err = client.GetClient(c)
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:toliaqat,项目名称:photon-controller,代码行数:31,代码来源:tasks.go
示例15: deploy
// Deploy Photon Controller based on DC_map
func deploy(c *cli.Context) error {
err := checkArgCount(c, 1)
if err != nil {
return err
}
file := c.Args().First()
dcMap, err := manifest.LoadInstallation(file)
if err != nil {
return err
}
client.Esxclient, err = client.GetClient(c)
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:toliaqat,项目名称:photon-controller,代码行数:36,代码来源:system.go
示例16: setVMTag
func setVMTag(c *cli.Context, w io.Writer) error {
err := checkArgCount(c, 1)
if err != nil {
return err
}
id := c.Args().First()
tag := c.String("tag")
vmTag := &photon.VmTag{}
if len(tag) == 0 {
return fmt.Errorf("Please input a tag")
}
vmTag.Tag = tag
client.Esxclient, err = client.GetClient(c)
if err != nil {
return err
}
task, err := client.Esxclient.VMs.SetTag(id, vmTag)
if err != nil {
return err
}
_, err = waitOnTaskOperation(task.ID, c)
if err != nil {
return err
}
err = formatHelper(c, w, client.Esxclient, id)
return err
}
开发者ID:toliaqat,项目名称:photon-controller,代码行数:35,代码来源:vms.go
示例17: addHosts
// Add most hosts in batch mode
func addHosts(c *cli.Context) error {
err := checkArgCount(c, 0)
if err != nil {
return err
}
file := c.Args().First()
dcMap, err := manifest.LoadInstallation(file)
if err != nil {
return err
}
client.Esxclient, err = client.GetClient(c)
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:toliaqat,项目名称:photon-controller,代码行数:28,代码来源:system.go
示例18: acquireFloatingIp
func acquireFloatingIp(c *cli.Context, w io.Writer) error {
err := checkArgCount(c, 1)
if err != nil {
return err
}
id := c.Args().First()
networkId := c.String("network_id")
options := &photon.VmFloatingIpSpec{
NetworkId: networkId,
}
client.Esxclient, err = client.GetClient(c)
if err != nil {
return err
}
task, err := client.Esxclient.VMs.AcquireFloatingIp(id, options)
if err != nil {
return err
}
_, err = waitOnTaskOperation(task.ID, c)
if err != nil {
return err
}
err = formatHelper(c, w, client.Esxclient, id)
return err
}
开发者ID:toliaqat,项目名称:photon-controller,代码行数:32,代码来源:vms.go
示例19: 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 := 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
}
开发者ID:toliaqat,项目名称:photon-controller,代码行数:35,代码来源:system.go
示例20: getVMTasks
// Retrieves tasks for VM
func getVMTasks(c *cli.Context, w io.Writer) error {
err := checkArgCount(c, 1)
if err != nil {
return err
}
id := c.Args().First()
state := c.String("state")
client.Esxclient, err = client.GetClient(c)
if err != nil {
return err
}
options := &photon.TaskGetOptions{
State: state,
}
taskList, err := client.Esxclient.VMs.GetTasks(id, options)
if err != nil {
return err
}
if !utils.NeedsFormatting(c) {
err = printTaskList(taskList.Items, c)
if err != nil {
return err
}
} else {
utils.FormatObjects(taskList, w, c)
}
return nil
}
开发者ID:toliaqat,项目名称:photon-controller,代码行数:35,代码来源:vms.go
注:本文中的github.com/toliaqat/photon-controller/cli/photon/client.GetClient函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论