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) }
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) }
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) }