本文整理汇总了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)
}