本文整理匯總了Golang中github.com/dynport/gocloud/profitbricks.NewFromEnv函數的典型用法代碼示例。如果您正苦於以下問題:Golang NewFromEnv函數的具體用法?Golang NewFromEnv怎麽用?Golang NewFromEnv使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了NewFromEnv函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Run
func (a *RollbackSnapshotHandler) Run() error {
req := &profitbricks.RollbackSnapshotRequest{
StorageId: a.StorageId,
SnapshotId: a.SnapshotId,
}
return profitbricks.NewFromEnv().RollbackSnapshot(req)
}
示例2: Run
func (a *CreateStorage) Run() error {
req := &profitbricks.CreateStorageRequest{
DataCenterId: a.DataCenterId,
StorageName: a.Name,
Size: a.Size,
MountImageId: a.MountImageId,
}
return profitbricks.NewFromEnv().CreateStorage(req)
}
示例3: CreateStorageHandler
func CreateStorageHandler(args *gocli.Args) error {
req := &profitbricks.CreateStorageRequest{
DataCenterId: args.MustGetString(CLI_DATACENTER_ID),
StorageName: args.MustGetString(CLI_NAME),
Size: args.MustGetInt(CLI_SIZE),
MountImageId: args.MustGetString(CLI_IMAGE_ID),
}
logger.Printf("creating storage with %#v", req)
return profitbricks.NewFromEnv().CreateStorage(req)
}
示例4: ListAllDataCentersHandler
func ListAllDataCentersHandler() error {
dcs, e := profitbricks.NewFromEnv().GetAllDataCenters()
if e != nil {
return e
}
table := gocli.NewTable()
table.Add("Id", "Name", "Version")
for _, dc := range dcs {
table.Add(dc.DataCenterId, dc.DataCenterName, dc.DataCenterVersion)
}
fmt.Println(table)
return nil
}
示例5: ListAllStorages
func ListAllStorages() error {
client := profitbricks.NewFromEnv()
storages, e := client.GetAllStorages()
if e != nil {
return e
}
table := gocli.NewTable()
table.Add("Id", "Name", "ProvisioningState", "Servers", "Image Name", "Image ID")
for _, storage := range storages {
table.Add(storage.StorageId, storage.StorageName, storage.ProvisioningState, strings.Join(storage.ServerIds, ","), storage.ImageName, storage.ImageId)
}
fmt.Println(table)
return nil
}
示例6: ListAllServersHandler
func ListAllServersHandler() error {
client := profitbricks.NewFromEnv()
servers, e := client.GetAllServers()
if e != nil {
return e
}
table := gocli.NewTable()
table.Add("Id", "Name", "ProvisioningState", "VmState", "Ips", "Lans")
for _, server := range servers {
table.Add(server.ServerId, server.ServerName, server.ProvisioningState, server.VirtualMachineState, strings.Join(server.Ips, ","), server.Lans())
}
fmt.Println(table)
return nil
}
示例7: ListAllImagesHandler
func ListAllImagesHandler() error {
client := profitbricks.NewFromEnv()
images, e := client.GetAllImages()
if e != nil {
return e
}
table := gocli.NewTable()
table.Add("Id", "Type", "Region", "Name", "Size")
for _, img := range images {
table.Add(img.ImageId, img.ImageType, img.Region, img.ImageName, img.ImageSize)
}
fmt.Println(table)
return nil
}
示例8: ListAllSnapshotsHandler
func ListAllSnapshotsHandler() error {
client := profitbricks.NewFromEnv()
snapshots, e := client.GetAllSnapshots()
if e != nil {
return e
}
table := gocli.NewTable()
table.Add("Id", "OsType", "Name", "Size", "State")
for _, snapshot := range snapshots {
table.Add(snapshot.SnapshotId, snapshot.OsType, snapshot.SnapshotName, snapshot.SnapshotSize, snapshot.ProvisioningState)
}
fmt.Println(table)
return nil
}
示例9: Run
func (a *DescribeDataCenterHandler) Run() error {
client := profitbricks.NewFromEnv()
dc, e := client.GetDataCenter(a.DataCenterId)
if e != nil {
return e
}
table := gocli.NewTable()
table.Add("Id", dc.DataCenterId)
table.Add("Name", dc.DataCenterName)
table.Add("Region", dc.Region)
table.Add("State", dc.ProvisioningState)
table.Add("Version", dc.DataCenterVersion)
fmt.Println(table)
fmt.Println("\nServers:")
if len(dc.Servers) > 0 {
table = gocli.NewTable()
table.Add("Id", "Created", "Name", "Lans", "Ip", "AZ", "ProvState", "VMState", "Ram", "Cores", "Internet")
for _, server := range dc.Servers {
table.Add(server.ServerId, server.CreationTime.Format("2006-01-02T15:04"), server.ServerName, server.Lans(), strings.Join(server.Ips, ","), server.AvailabilityZone, server.ProvisioningState, server.VirtualMachineState, server.Ram, server.Cores, server.InternetAccess)
}
fmt.Println(table)
} else {
fmt.Println("* None *")
}
fmt.Println("\nStorages:")
if len(dc.Storages) > 0 {
table = gocli.NewTable()
table.Add("Id", "Name", "Size")
for _, storage := range dc.Storages {
table.Add(storage.StorageId, storage.StorageName, storage.Size)
}
fmt.Println(table)
} else {
fmt.Println("* None *")
}
return nil
}
示例10: StartServerHandler
func StartServerHandler(args *gocli.Args) error {
return doSomething(args, profitbricks.NewFromEnv().StartServer)
}