本文整理匯總了Golang中os.Instances函數的典型用法代碼示例。如果您正苦於以下問題:Golang Instances函數的具體用法?Golang Instances怎麽用?Golang Instances使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Instances函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestInstances
func TestInstances(t *testing.T) {
cfg, ok := configFromEnv()
if !ok {
t.Skipf("No config found in environment")
}
os, err := newRackspace(cfg)
if err != nil {
t.Fatalf("Failed to construct/authenticate Rackspace: %s", err)
}
i, ok := os.Instances()
if !ok {
t.Fatalf("Instances() returned false")
}
srvs, err := i.List(".")
if err != nil {
t.Fatalf("Instances.List() failed: %s", err)
}
if len(srvs) == 0 {
t.Fatalf("Instances.List() returned zero servers")
}
t.Logf("Found servers (%d): %s\n", len(srvs), srvs)
addrs, err := i.NodeAddresses(srvs[0])
if err != nil {
t.Fatalf("Instances.NodeAddresses(%s) failed: %s", srvs[0], err)
}
t.Logf("Found NodeAddresses(%s) = %s\n", srvs[0], addrs)
}
示例2: TestInstances
func TestInstances(t *testing.T) {
cfg, ok := configFromEnv()
if !ok {
t.Skipf("No config found in environment")
}
os, err := newOpenStack(cfg)
if err != nil {
t.Fatalf("Failed to construct/authenticate OpenStack: %s", err)
}
i, ok := os.Instances()
if !ok {
t.Fatalf("Instances() returned false")
}
srvs, err := i.List(".")
if err != nil {
t.Fatalf("Instances.List() failed: %s", err)
}
if len(srvs) == 0 {
t.Fatalf("Instances.List() returned zero servers")
}
t.Logf("Found servers (%d): %s\n", len(srvs), srvs)
srvExternalId, err := i.ExternalID(srvs[0])
if err != nil {
t.Fatalf("Instances.ExternalId(%s) failed: %s", srvs[0], err)
}
t.Logf("Found server (%s), with external id: %s\n", srvs[0], srvExternalId)
srvInstanceId, err := i.InstanceID(srvs[0])
if err != nil {
t.Fatalf("Instance.InstanceId(%s) failed: %s", srvs[0], err)
}
t.Logf("Found server (%s), with instance id: %s\n", srvs[0], srvInstanceId)
addrs, err := i.NodeAddresses(srvs[0])
if err != nil {
t.Fatalf("Instances.NodeAddresses(%s) failed: %s", srvs[0], err)
}
t.Logf("Found NodeAddresses(%s) = %s\n", srvs[0], addrs)
}
示例3: TestInstances
func TestInstances(t *testing.T) {
cfg, ok := configFromEnv()
if !ok {
t.Skipf("No config found in environment")
}
os, err := newOpenStack(cfg)
if err != nil {
t.Fatalf("Failed to construct/authenticate OpenStack: %s", err)
}
i, ok := os.Instances()
if !ok {
t.Fatalf("Instances() returned false")
}
srvs, err := i.List(".")
if err != nil {
t.Fatalf("Instances.List() failed: %s", err)
}
if len(srvs) == 0 {
t.Fatalf("Instances.List() returned zero servers")
}
t.Logf("Found servers (%d): %s\n", len(srvs), srvs)
ip, err := i.IPAddress(srvs[0])
if err != nil {
t.Fatalf("Instances.IPAddress(%s) failed: %s", srvs[0], err)
}
t.Logf("Found IPAddress(%s) = %s\n", srvs[0], ip)
rsrcs, err := i.GetNodeResources(srvs[0])
if err != nil {
t.Fatalf("Instances.GetNodeResources(%s) failed: %s", srvs[0], err)
}
t.Logf("Found GetNodeResources(%s) = %s\n", srvs[0], rsrcs)
}