Acceptance Test Updates (#218)
* compute: don't pass choices
* blockstorage: don't pass choices
* DumpResource Function
This function prints a resource in JSON format but retains the actual
field name rather than using the name specified in the JSON tag.
* New DumpResource
This version just converts the resource into JSON. The original is
being left in git history for posterity.
* Renaming DumpResource to PrintResource
* Removing all print functions in favor of PrintResource
* Rebase reconcilliation
diff --git a/acceptance/openstack/blockstorage/extensions/volumeactions_test.go b/acceptance/openstack/blockstorage/extensions/volumeactions_test.go
index 83d1571..a088dd6 100644
--- a/acceptance/openstack/blockstorage/extensions/volumeactions_test.go
+++ b/acceptance/openstack/blockstorage/extensions/volumeactions_test.go
@@ -23,12 +23,7 @@
t.Fatalf("Unable to create a compute client: %v", err)
}
- choices, err := clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
- server, err := compute.CreateServer(t, computeClient, choices)
+ server, err := compute.CreateServer(t, computeClient)
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
diff --git a/acceptance/openstack/blockstorage/v1/blockstorage.go b/acceptance/openstack/blockstorage/v1/blockstorage.go
index 3d4c9f1..41f24e1 100644
--- a/acceptance/openstack/blockstorage/v1/blockstorage.go
+++ b/acceptance/openstack/blockstorage/v1/blockstorage.go
@@ -140,44 +140,3 @@
t.Logf("Deleted volume type: %s", volumeType.ID)
}
-
-// PrintVolume will print a volume and all of its attributes.
-func PrintVolume(t *testing.T, volume *volumes.Volume) {
- t.Logf("ID: %s", volume.ID)
- t.Logf("Status: %s", volume.Status)
- t.Logf("Name: %s", volume.Name)
- t.Logf("AvailabilityZone: %s", volume.AvailabilityZone)
- t.Logf("Bootable: %s", volume.Bootable)
- t.Logf("CreatedAt: %v", volume.CreatedAt)
- t.Logf("Description: %s", volume.Description)
- t.Logf("VolumeType: %s", volume.VolumeType)
- t.Logf("SnapshotID: %s", volume.SnapshotID)
- t.Logf("SourceVolID: %s", volume.SourceVolID)
- t.Logf("Size: %d", volume.Size)
- t.Logf("Metadata: %#v", volume.Metadata)
- t.Logf("Attachments: %#v", volume.Attachments)
-}
-
-// PrintVolumeType will print a volume type and all of its attributes.
-func PrintVolumeType(t *testing.T, volumeType *volumetypes.VolumeType) {
- t.Logf("ID: %s", volumeType.ID)
- t.Logf("Name: %s", volumeType.Name)
- t.Logf("ExtraSpecs: %#v", volumeType.ExtraSpecs)
-}
-
-// PrintSnapshot will print a snapshot and all of its attributes.
-func PrintSnapshot(t *testing.T, snapshot *snapshots.Snapshot) {
- t.Logf("ID: %s", snapshot.ID)
- t.Logf("Status: %s", snapshot.Status)
- t.Logf("Name: %s", snapshot.Name)
- t.Logf("AvailabilityZone: %s", snapshot.AvailabilityZone)
- t.Logf("Bootable: %s", snapshot.Bootable)
- t.Logf("CreatedAt: %v", snapshot.CreatedAt)
- t.Logf("Description: %s", snapshot.Description)
- t.Logf("VolumeType: %s", snapshot.VolumeType)
- t.Logf("SnapshotID: %s", snapshot.SnapshotID)
- t.Logf("VolumeID: %s", snapshot.VolumeID)
- t.Logf("Size: %d", snapshot.Size)
- t.Logf("Metadata: %#v", snapshot.Metadata)
- t.Logf("Attachments: %#v", snapshot.Attachments)
-}
diff --git a/acceptance/openstack/blockstorage/v1/snapshots_test.go b/acceptance/openstack/blockstorage/v1/snapshots_test.go
index 2dc58db..3545371 100644
--- a/acceptance/openstack/blockstorage/v1/snapshots_test.go
+++ b/acceptance/openstack/blockstorage/v1/snapshots_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/blockstorage/v1/snapshots"
)
@@ -26,7 +27,7 @@
}
for _, snapshot := range allSnapshots {
- PrintSnapshot(t, &snapshot)
+ tools.PrintResource(t, snapshot)
}
}
@@ -53,5 +54,5 @@
t.Errorf("Unable to retrieve snapshot: %v", err)
}
- PrintSnapshot(t, newSnapshot)
+ tools.PrintResource(t, newSnapshot)
}
diff --git a/acceptance/openstack/blockstorage/v1/volumes_test.go b/acceptance/openstack/blockstorage/v1/volumes_test.go
index e375c59..9a55500 100644
--- a/acceptance/openstack/blockstorage/v1/volumes_test.go
+++ b/acceptance/openstack/blockstorage/v1/volumes_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/blockstorage/v1/volumes"
)
@@ -26,7 +27,7 @@
}
for _, volume := range allVolumes {
- PrintVolume(t, &volume)
+ tools.PrintResource(t, volume)
}
}
@@ -47,5 +48,5 @@
t.Errorf("Unable to retrieve volume: %v", err)
}
- PrintVolume(t, newVolume)
+ tools.PrintResource(t, newVolume)
}
diff --git a/acceptance/openstack/blockstorage/v1/volumetypes_test.go b/acceptance/openstack/blockstorage/v1/volumetypes_test.go
index 843ea21..ace09bc 100644
--- a/acceptance/openstack/blockstorage/v1/volumetypes_test.go
+++ b/acceptance/openstack/blockstorage/v1/volumetypes_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/blockstorage/v1/volumetypes"
)
@@ -26,7 +27,7 @@
}
for _, volumeType := range allVolumeTypes {
- PrintVolumeType(t, &volumeType)
+ tools.PrintResource(t, volumeType)
}
}
@@ -42,5 +43,5 @@
}
defer DeleteVolumeType(t, client, volumeType)
- PrintVolumeType(t, volumeType)
+ tools.PrintResource(t, volumeType)
}
diff --git a/acceptance/openstack/blockstorage/v2/blockstorage.go b/acceptance/openstack/blockstorage/v2/blockstorage.go
index 555bdcd..39fb7da 100644
--- a/acceptance/openstack/blockstorage/v2/blockstorage.go
+++ b/acceptance/openstack/blockstorage/v2/blockstorage.go
@@ -42,11 +42,16 @@
// CreateVolumeFromImage will create a volume from with a random name and size of
// 1GB. An error will be returned if the volume was unable to be created.
-func CreateVolumeFromImage(t *testing.T, client *gophercloud.ServiceClient, choices *clients.AcceptanceTestChoices) (*volumes.Volume, error) {
+func CreateVolumeFromImage(t *testing.T, client *gophercloud.ServiceClient) (*volumes.Volume, error) {
if testing.Short() {
t.Skip("Skipping test that requires volume creation in short mode.")
}
+ choices, err := clients.AcceptanceTestChoicesFromEnv()
+ if err != nil {
+ t.Fatal(err)
+ }
+
volumeName := tools.RandomString("ACPTTEST", 16)
t.Logf("Attempting to create volume: %s", volumeName)
@@ -79,26 +84,3 @@
t.Logf("Deleted volume: %s", volume.ID)
}
-
-// PrintVolume will print a volume and all of its attributes.
-func PrintVolume(t *testing.T, volume *volumes.Volume) {
- t.Logf("ID: %s", volume.ID)
- t.Logf("Status: %s", volume.Status)
- t.Logf("Size: %d", volume.Size)
- t.Logf("AvailabilityZone: %s", volume.AvailabilityZone)
- t.Logf("CreatedAt: %v", volume.CreatedAt)
- t.Logf("UpdatedAt: %v", volume.CreatedAt)
- t.Logf("Attachments: %#v", volume.Attachments)
- t.Logf("Name: %s", volume.Name)
- t.Logf("Description: %s", volume.Description)
- t.Logf("VolumeType: %s", volume.VolumeType)
- t.Logf("SnapshotID: %s", volume.SnapshotID)
- t.Logf("SourceVolID: %s", volume.SourceVolID)
- t.Logf("Metadata: %#v", volume.Metadata)
- t.Logf("UserID: %s", volume.UserID)
- t.Logf("Bootable: %s", volume.Bootable)
- t.Logf("Encrypted: %s", volume.Encrypted)
- t.Logf("ReplicationStatus: %s", volume.ReplicationStatus)
- t.Logf("ConsistencyGroupID: %s", volume.ConsistencyGroupID)
- t.Logf("Multiattach: %t", volume.Multiattach)
-}
diff --git a/acceptance/openstack/blockstorage/v2/volumes_test.go b/acceptance/openstack/blockstorage/v2/volumes_test.go
index 3508bc5..9003ca7 100644
--- a/acceptance/openstack/blockstorage/v2/volumes_test.go
+++ b/acceptance/openstack/blockstorage/v2/volumes_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/blockstorage/v2/volumes"
)
@@ -26,7 +27,7 @@
}
for _, volume := range allVolumes {
- PrintVolume(t, &volume)
+ tools.PrintResource(t, volume)
}
}
@@ -47,5 +48,5 @@
t.Errorf("Unable to retrieve volume: %v", err)
}
- PrintVolume(t, newVolume)
+ tools.PrintResource(t, newVolume)
}
diff --git a/acceptance/openstack/compute/v2/bootfromvolume_test.go b/acceptance/openstack/compute/v2/bootfromvolume_test.go
index 54719d0..2ba8888 100644
--- a/acceptance/openstack/compute/v2/bootfromvolume_test.go
+++ b/acceptance/openstack/compute/v2/bootfromvolume_test.go
@@ -7,6 +7,7 @@
"github.com/gophercloud/gophercloud/acceptance/clients"
blockstorage "github.com/gophercloud/gophercloud/acceptance/openstack/blockstorage/v2"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
)
@@ -35,13 +36,13 @@
},
}
- server, err := CreateBootableVolumeServer(t, client, blockDevices, choices)
+ server, err := CreateBootableVolumeServer(t, client, blockDevices)
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
defer DeleteServer(t, client, server)
- PrintServer(t, server)
+ tools.PrintResource(t, server)
}
func TestBootFromNewVolume(t *testing.T) {
@@ -69,13 +70,13 @@
},
}
- server, err := CreateBootableVolumeServer(t, client, blockDevices, choices)
+ server, err := CreateBootableVolumeServer(t, client, blockDevices)
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
defer DeleteServer(t, client, server)
- PrintServer(t, server)
+ tools.PrintResource(t, server)
}
func TestBootFromExistingVolume(t *testing.T) {
@@ -93,12 +94,7 @@
t.Fatalf("Unable to create a block storage client: %v", err)
}
- choices, err := clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
- volume, err := blockstorage.CreateVolumeFromImage(t, blockStorageClient, choices)
+ volume, err := blockstorage.CreateVolumeFromImage(t, blockStorageClient)
if err != nil {
t.Fatal(err)
}
@@ -112,13 +108,13 @@
},
}
- server, err := CreateBootableVolumeServer(t, computeClient, blockDevices, choices)
+ server, err := CreateBootableVolumeServer(t, computeClient, blockDevices)
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
defer DeleteServer(t, computeClient, server)
- PrintServer(t, server)
+ tools.PrintResource(t, server)
}
func TestBootFromMultiEphemeralServer(t *testing.T) {
@@ -163,13 +159,13 @@
},
}
- server, err := CreateMultiEphemeralServer(t, client, blockDevices, choices)
+ server, err := CreateMultiEphemeralServer(t, client, blockDevices)
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
defer DeleteServer(t, client, server)
- PrintServer(t, server)
+ tools.PrintResource(t, server)
}
func TestAttachNewVolume(t *testing.T) {
@@ -204,13 +200,13 @@
},
}
- server, err := CreateBootableVolumeServer(t, client, blockDevices, choices)
+ server, err := CreateBootableVolumeServer(t, client, blockDevices)
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
defer DeleteServer(t, client, server)
- PrintServer(t, server)
+ tools.PrintResource(t, server)
}
func TestAttachExistingVolume(t *testing.T) {
@@ -255,11 +251,11 @@
},
}
- server, err := CreateBootableVolumeServer(t, computeClient, blockDevices, choices)
+ server, err := CreateBootableVolumeServer(t, computeClient, blockDevices)
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
defer DeleteServer(t, computeClient, server)
- PrintServer(t, server)
+ tools.PrintResource(t, server)
}
diff --git a/acceptance/openstack/compute/v2/compute.go b/acceptance/openstack/compute/v2/compute.go
index 97d61f6..1f3dc16 100644
--- a/acceptance/openstack/compute/v2/compute.go
+++ b/acceptance/openstack/compute/v2/compute.go
@@ -23,8 +23,6 @@
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/tenantnetworks"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/volumeattach"
- "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors"
- "github.com/gophercloud/gophercloud/openstack/compute/v2/images"
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
"golang.org/x/crypto/ssh"
@@ -67,13 +65,18 @@
// CreateBootableVolumeServer works like CreateServer but is configured with
// one or more block devices defined by passing in []bootfromvolume.BlockDevice.
// An error will be returned if a server was unable to be created.
-func CreateBootableVolumeServer(t *testing.T, client *gophercloud.ServiceClient, blockDevices []bootfromvolume.BlockDevice, choices *clients.AcceptanceTestChoices) (*servers.Server, error) {
+func CreateBootableVolumeServer(t *testing.T, client *gophercloud.ServiceClient, blockDevices []bootfromvolume.BlockDevice) (*servers.Server, error) {
if testing.Short() {
t.Skip("Skipping test that requires server creation in short mode.")
}
var server *servers.Server
+ choices, err := clients.AcceptanceTestChoicesFromEnv()
+ if err != nil {
+ t.Fatal(err)
+ }
+
networkID, err := GetNetworkIDFromTenantNetworks(t, client, choices.NetworkName)
if err != nil {
return server, err
@@ -135,7 +138,12 @@
// CreateFloatingIP will allocate a floating IP.
// An error will be returend if one was unable to be allocated.
-func CreateFloatingIP(t *testing.T, client *gophercloud.ServiceClient, choices *clients.AcceptanceTestChoices) (*floatingips.FloatingIP, error) {
+func CreateFloatingIP(t *testing.T, client *gophercloud.ServiceClient) (*floatingips.FloatingIP, error) {
+ choices, err := clients.AcceptanceTestChoicesFromEnv()
+ if err != nil {
+ t.Fatal(err)
+ }
+
createOpts := floatingips.CreateOpts{
Pool: choices.FloatingIPPoolName,
}
@@ -189,13 +197,18 @@
// These block devices act like block devices when booting from a volume but
// are actually local ephemeral disks.
// An error will be returned if a server was unable to be created.
-func CreateMultiEphemeralServer(t *testing.T, client *gophercloud.ServiceClient, blockDevices []bootfromvolume.BlockDevice, choices *clients.AcceptanceTestChoices) (*servers.Server, error) {
+func CreateMultiEphemeralServer(t *testing.T, client *gophercloud.ServiceClient, blockDevices []bootfromvolume.BlockDevice) (*servers.Server, error) {
if testing.Short() {
t.Skip("Skipping test that requires server creation in short mode.")
}
var server *servers.Server
+ choices, err := clients.AcceptanceTestChoicesFromEnv()
+ if err != nil {
+ t.Fatal(err)
+ }
+
networkID, err := GetNetworkIDFromTenantNetworks(t, client, choices.NetworkName)
if err != nil {
return server, err
@@ -274,13 +287,18 @@
// The image will be the value of the OS_IMAGE_ID environment variable.
// The instance will be launched on the network specified in OS_NETWORK_NAME.
// An error will be returned if the instance was unable to be created.
-func CreateServer(t *testing.T, client *gophercloud.ServiceClient, choices *clients.AcceptanceTestChoices) (*servers.Server, error) {
+func CreateServer(t *testing.T, client *gophercloud.ServiceClient) (*servers.Server, error) {
if testing.Short() {
t.Skip("Skipping test that requires server creation in short mode.")
}
var server *servers.Server
+ choices, err := clients.AcceptanceTestChoicesFromEnv()
+ if err != nil {
+ t.Fatal(err)
+ }
+
networkID, err := GetNetworkIDFromTenantNetworks(t, client, choices.NetworkName)
if err != nil {
return server, err
@@ -325,13 +343,18 @@
// The image is intentionally missing to trigger an error.
// The instance will be launched on the network specified in OS_NETWORK_NAME.
// An error will be returned if the instance was unable to be created.
-func CreateServerWithoutImageRef(t *testing.T, client *gophercloud.ServiceClient, choices *clients.AcceptanceTestChoices) (*servers.Server, error) {
+func CreateServerWithoutImageRef(t *testing.T, client *gophercloud.ServiceClient) (*servers.Server, error) {
if testing.Short() {
t.Skip("Skipping test that requires server creation in short mode.")
}
var server *servers.Server
+ choices, err := clients.AcceptanceTestChoicesFromEnv()
+ if err != nil {
+ t.Fatal(err)
+ }
+
networkID, err := GetNetworkIDFromTenantNetworks(t, client, choices.NetworkName)
if err != nil {
return server, err
@@ -384,13 +407,18 @@
// CreateServerInServerGroup works like CreateServer but places the instance in
// a specified Server Group.
-func CreateServerInServerGroup(t *testing.T, client *gophercloud.ServiceClient, choices *clients.AcceptanceTestChoices, serverGroup *servergroups.ServerGroup) (*servers.Server, error) {
+func CreateServerInServerGroup(t *testing.T, client *gophercloud.ServiceClient, serverGroup *servergroups.ServerGroup) (*servers.Server, error) {
if testing.Short() {
t.Skip("Skipping test that requires server creation in short mode.")
}
var server *servers.Server
+ choices, err := clients.AcceptanceTestChoicesFromEnv()
+ if err != nil {
+ t.Fatal(err)
+ }
+
networkID, err := GetNetworkIDFromTenantNetworks(t, client, choices.NetworkName)
if err != nil {
return server, err
@@ -427,13 +455,18 @@
// CreateServerWithPublicKey works the same as CreateServer, but additionally
// configures the server with a specified Key Pair name.
-func CreateServerWithPublicKey(t *testing.T, client *gophercloud.ServiceClient, choices *clients.AcceptanceTestChoices, keyPairName string) (*servers.Server, error) {
+func CreateServerWithPublicKey(t *testing.T, client *gophercloud.ServiceClient, keyPairName string) (*servers.Server, error) {
if testing.Short() {
t.Skip("Skipping test that requires server creation in short mode.")
}
var server *servers.Server
+ choices, err := clients.AcceptanceTestChoicesFromEnv()
+ if err != nil {
+ t.Fatal(err)
+ }
+
networkID, err := GetNetworkIDFromTenantNetworks(t, client, choices.NetworkName)
if err != nil {
return server, err
@@ -673,7 +706,12 @@
// ResizeServer performs a resize action on an instance. An error will be
// returned if the instance failed to resize.
// The new flavor that the instance will be resized to is specified in OS_FLAVOR_ID_RESIZE.
-func ResizeServer(t *testing.T, client *gophercloud.ServiceClient, server *servers.Server, choices *clients.AcceptanceTestChoices) error {
+func ResizeServer(t *testing.T, client *gophercloud.ServiceClient, server *servers.Server) error {
+ choices, err := clients.AcceptanceTestChoicesFromEnv()
+ if err != nil {
+ t.Fatal(err)
+ }
+
opts := &servers.ResizeOpts{
FlavorRef: choices.FlavorIDResize,
}
@@ -711,7 +749,7 @@
}
//Convenience method to fill an QuotaSet-UpdateOpts-struct from a QuotaSet-struct
-func FillUpdateOptsFromQuotaSet(src quotasets.QuotaSet,dest *quotasets.UpdateOpts) {
+func FillUpdateOptsFromQuotaSet(src quotasets.QuotaSet, dest *quotasets.UpdateOpts) {
dest.FixedIps = &src.FixedIps
dest.FloatingIps = &src.FloatingIps
dest.InjectedFileContentBytes = &src.InjectedFileContentBytes
@@ -727,171 +765,3 @@
dest.ServerGroupMembers = &src.ServerGroupMembers
dest.MetadataItems = &src.MetadataItems
}
-
-// PrintServer will print an instance and all of its attributes.
-func PrintServer(t *testing.T, server *servers.Server) {
- t.Logf("ID: %s", server.ID)
- t.Logf("TenantID: %s", server.TenantID)
- t.Logf("UserID: %s", server.UserID)
- t.Logf("Name: %s", server.Name)
- t.Logf("Updated: %s", server.Updated)
- t.Logf("Created: %s", server.Created)
- t.Logf("HostID: %s", server.HostID)
- t.Logf("Status: %s", server.Status)
- t.Logf("Progress: %d", server.Progress)
- t.Logf("AccessIPv4: %s", server.AccessIPv4)
- t.Logf("AccessIPv6: %s", server.AccessIPv6)
- t.Logf("Image: %s", server.Image)
- t.Logf("Flavor: %s", server.Flavor)
- t.Logf("Addresses: %#v", server.Addresses)
- t.Logf("Metadata: %#v", server.Metadata)
- t.Logf("Links: %#v", server.Links)
- t.Logf("KeyName: %s", server.KeyName)
- t.Logf("AdminPass: %s", server.AdminPass)
- t.Logf("SecurityGroups: %#v", server.SecurityGroups)
-}
-
-// PrintDefaultRule will print a default security group rule and all of its attributes.
-func PrintDefaultRule(t *testing.T, defaultRule *dsr.DefaultRule) {
- t.Logf("\tID: %s", defaultRule.ID)
- t.Logf("\tFrom Port: %d", defaultRule.FromPort)
- t.Logf("\tTo Port: %d", defaultRule.ToPort)
- t.Logf("\tIP Protocol: %s", defaultRule.IPProtocol)
- t.Logf("\tIP Range: %s", defaultRule.IPRange.CIDR)
- t.Logf("\tParent Group ID: %s", defaultRule.ParentGroupID)
- t.Logf("\tGroup Tenant ID: %s", defaultRule.Group.TenantID)
- t.Logf("\tGroup Name: %s", defaultRule.Group.Name)
-}
-
-// PrintFlavor will print a flavor and all of its attributes.
-func PrintFlavor(t *testing.T, flavor *flavors.Flavor) {
- t.Logf("ID: %s", flavor.ID)
- t.Logf("Name: %s", flavor.Name)
- t.Logf("RAM: %d", flavor.RAM)
- t.Logf("Disk: %d", flavor.Disk)
- t.Logf("Swap: %d", flavor.Swap)
- t.Logf("RxTxFactor: %f", flavor.RxTxFactor)
-}
-
-// PrintFloatingIP will print a floating IP and all of its attributes.
-func PrintFloatingIP(t *testing.T, floatingIP *floatingips.FloatingIP) {
- t.Logf("ID: %s", floatingIP.ID)
- t.Logf("Fixed IP: %s", floatingIP.FixedIP)
- t.Logf("Instance ID: %s", floatingIP.InstanceID)
- t.Logf("IP: %s", floatingIP.IP)
- t.Logf("Pool: %s", floatingIP.Pool)
-}
-
-// PrintImage will print an image and all of its attributes.
-func PrintImage(t *testing.T, image images.Image) {
- t.Logf("ID: %s", image.ID)
- t.Logf("Name: %s", image.Name)
- t.Logf("MinDisk: %d", image.MinDisk)
- t.Logf("MinRAM: %d", image.MinRAM)
- t.Logf("Status: %s", image.Status)
- t.Logf("Progress: %d", image.Progress)
- t.Logf("Metadata: %#v", image.Metadata)
- t.Logf("Created: %s", image.Created)
- t.Logf("Updated: %s", image.Updated)
-}
-
-// PrintKeyPair will print keypair and all of its attributes.
-func PrintKeyPair(t *testing.T, keypair *keypairs.KeyPair) {
- t.Logf("Name: %s", keypair.Name)
- t.Logf("Fingerprint: %s", keypair.Fingerprint)
- t.Logf("Public Key: %s", keypair.PublicKey)
- t.Logf("Private Key: %s", keypair.PrivateKey)
- t.Logf("UserID: %s", keypair.UserID)
-}
-
-// PrintNetwork will print an os-networks based network and all of its attributes.
-func PrintNetwork(t *testing.T, network *networks.Network) {
- t.Logf("Bridge: %s", network.Bridge)
- t.Logf("BridgeInterface: %s", network.BridgeInterface)
- t.Logf("Broadcast: %s", network.Broadcast)
- t.Logf("CIDR: %s", network.CIDR)
- t.Logf("CIDRv6: %s", network.CIDRv6)
- t.Logf("CreatedAt: %v", network.CreatedAt)
- t.Logf("Deleted: %t", network.Deleted)
- t.Logf("DeletedAt: %v", network.DeletedAt)
- t.Logf("DHCPStart: %s", network.DHCPStart)
- t.Logf("DNS1: %s", network.DNS1)
- t.Logf("DNS2: %s", network.DNS2)
- t.Logf("Gateway: %s", network.Gateway)
- t.Logf("Gatewayv6: %s", network.Gatewayv6)
- t.Logf("Host: %s", network.Host)
- t.Logf("ID: %s", network.ID)
- t.Logf("Injected: %t", network.Injected)
- t.Logf("Label: %s", network.Label)
- t.Logf("MultiHost: %t", network.MultiHost)
- t.Logf("Netmask: %s", network.Netmask)
- t.Logf("Netmaskv6: %s", network.Netmaskv6)
- t.Logf("Priority: %d", network.Priority)
- t.Logf("ProjectID: %s", network.ProjectID)
- t.Logf("RXTXBase: %d", network.RXTXBase)
- t.Logf("UpdatedAt: %v", network.UpdatedAt)
- t.Logf("VLAN: %d", network.VLAN)
- t.Logf("VPNPrivateAddress: %s", network.VPNPrivateAddress)
- t.Logf("VPNPublicAddress: %s", network.VPNPublicAddress)
- t.Logf("VPNPublicPort: %d", network.VPNPublicPort)
-}
-
-// PrintQuotaSet will print a quota set and all of its attributes.
-func PrintQuotaSet(t *testing.T, quotaSet *quotasets.QuotaSet) {
- t.Logf("instances: %d\n", quotaSet.Instances)
- t.Logf("cores: %d\n", quotaSet.Cores)
- t.Logf("ram: %d\n", quotaSet.Ram)
- t.Logf("key_pairs: %d\n", quotaSet.KeyPairs)
- t.Logf("metadata_items: %d\n", quotaSet.MetadataItems)
- t.Logf("security_groups: %d\n", quotaSet.SecurityGroups)
- t.Logf("security_group_rules: %d\n", quotaSet.SecurityGroupRules)
- t.Logf("fixed_ips: %d\n", quotaSet.FixedIps)
- t.Logf("floating_ips: %d\n", quotaSet.FloatingIps)
- t.Logf("injected_file_content_bytes: %d\n", quotaSet.InjectedFileContentBytes)
- t.Logf("injected_file_path_bytes: %d\n", quotaSet.InjectedFilePathBytes)
- t.Logf("injected_files: %d\n", quotaSet.InjectedFiles)
-}
-
-// PrintSecurityGroup will print a security group and all of its attributes and rules.
-func PrintSecurityGroup(t *testing.T, securityGroup *secgroups.SecurityGroup) {
- t.Logf("ID: %s", securityGroup.ID)
- t.Logf("Name: %s", securityGroup.Name)
- t.Logf("Description: %s", securityGroup.Description)
- t.Logf("Tenant ID: %s", securityGroup.TenantID)
- t.Logf("Rules:")
-
- for _, rule := range securityGroup.Rules {
- t.Logf("\tID: %s", rule.ID)
- t.Logf("\tFrom Port: %d", rule.FromPort)
- t.Logf("\tTo Port: %d", rule.ToPort)
- t.Logf("\tIP Protocol: %s", rule.IPProtocol)
- t.Logf("\tIP Range: %s", rule.IPRange.CIDR)
- t.Logf("\tParent Group ID: %s", rule.ParentGroupID)
- t.Logf("\tGroup Tenant ID: %s", rule.Group.TenantID)
- t.Logf("\tGroup Name: %s", rule.Group.Name)
- }
-}
-
-// PrintServerGroup will print a server group and all of its attributes.
-func PrintServerGroup(t *testing.T, serverGroup *servergroups.ServerGroup) {
- t.Logf("ID: %s", serverGroup.ID)
- t.Logf("Name: %s", serverGroup.Name)
- t.Logf("Policies: %#v", serverGroup.Policies)
- t.Logf("Members: %#v", serverGroup.Members)
- t.Logf("Metadata: %#v", serverGroup.Metadata)
-}
-
-// PrintTenantNetwork will print an os-tenant-networks based network and all of its attributes.
-func PrintTenantNetwork(t *testing.T, network *tenantnetworks.Network) {
- t.Logf("ID: %s", network.ID)
- t.Logf("Name: %s", network.Name)
- t.Logf("CIDR: %s", network.CIDR)
-}
-
-// PrintVolumeAttachment will print a volume attachment and all of its attributes.
-func PrintVolumeAttachment(t *testing.T, volumeAttachment *volumeattach.VolumeAttachment) {
- t.Logf("ID: %s", volumeAttachment.ID)
- t.Logf("Device: %s", volumeAttachment.Device)
- t.Logf("VolumeID: %s", volumeAttachment.VolumeID)
- t.Logf("ServerID: %s", volumeAttachment.ServerID)
-}
diff --git a/acceptance/openstack/compute/v2/defsecrules_test.go b/acceptance/openstack/compute/v2/defsecrules_test.go
index ca221be..16c43f4 100644
--- a/acceptance/openstack/compute/v2/defsecrules_test.go
+++ b/acceptance/openstack/compute/v2/defsecrules_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
dsr "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/defsecrules"
)
@@ -26,7 +27,7 @@
}
for _, defaultRule := range allDefaultRules {
- PrintDefaultRule(t, &defaultRule)
+ tools.PrintResource(t, defaultRule)
}
}
@@ -42,7 +43,7 @@
}
defer DeleteDefaultRule(t, client, defaultRule)
- PrintDefaultRule(t, &defaultRule)
+ tools.PrintResource(t, defaultRule)
}
func TestDefSecRulesGet(t *testing.T) {
@@ -62,5 +63,5 @@
t.Fatalf("Unable to get default rule %s: %v", defaultRule.ID, err)
}
- PrintDefaultRule(t, newDefaultRule)
+ tools.PrintResource(t, newDefaultRule)
}
diff --git a/acceptance/openstack/compute/v2/extension_test.go b/acceptance/openstack/compute/v2/extension_test.go
index 5de715d..5b2cf4a 100644
--- a/acceptance/openstack/compute/v2/extension_test.go
+++ b/acceptance/openstack/compute/v2/extension_test.go
@@ -6,7 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
- "github.com/gophercloud/gophercloud/acceptance/openstack"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/common/extensions"
)
@@ -27,7 +27,7 @@
}
for _, extension := range allExtensions {
- openstack.PrintExtension(t, &extension)
+ tools.PrintResource(t, extension)
}
}
@@ -42,5 +42,5 @@
t.Fatalf("Unable to get extension os-admin-actions: %v", err)
}
- openstack.PrintExtension(t, extension)
+ tools.PrintResource(t, extension)
}
diff --git a/acceptance/openstack/compute/v2/flavors_test.go b/acceptance/openstack/compute/v2/flavors_test.go
index 6f6490e..ee698cc 100644
--- a/acceptance/openstack/compute/v2/flavors_test.go
+++ b/acceptance/openstack/compute/v2/flavors_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/compute/v2/flavors"
)
@@ -26,7 +27,7 @@
}
for _, flavor := range allFlavors {
- PrintFlavor(t, &flavor)
+ tools.PrintResource(t, flavor)
}
}
@@ -36,7 +37,7 @@
t.Fatalf("Unable to create a compute client: %v", err)
}
- choices, err :=clients.AcceptanceTestChoicesFromEnv()
+ choices, err := clients.AcceptanceTestChoicesFromEnv()
if err != nil {
t.Fatal(err)
}
@@ -46,5 +47,5 @@
t.Fatalf("Unable to get flavor information: %v", err)
}
- PrintFlavor(t, flavor)
+ tools.PrintResource(t, flavor)
}
diff --git a/acceptance/openstack/compute/v2/floatingip_test.go b/acceptance/openstack/compute/v2/floatingip_test.go
index 001dc9f..26b7bfe 100644
--- a/acceptance/openstack/compute/v2/floatingip_test.go
+++ b/acceptance/openstack/compute/v2/floatingip_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/floatingips"
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
)
@@ -27,7 +28,7 @@
}
for _, floatingIP := range allFloatingIPs {
- PrintFloatingIP(t, &floatingIP)
+ tools.PrintResource(t, floatingIP)
}
}
@@ -37,18 +38,13 @@
t.Fatalf("Unable to create a compute client: %v", err)
}
- choices, err := clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
- floatingIP, err := CreateFloatingIP(t, client, choices)
+ floatingIP, err := CreateFloatingIP(t, client)
if err != nil {
t.Fatalf("Unable to create floating IP: %v", err)
}
defer DeleteFloatingIP(t, client, floatingIP)
- PrintFloatingIP(t, floatingIP)
+ tools.PrintResource(t, floatingIP)
}
func TestFloatingIPsAssociate(t *testing.T) {
@@ -61,24 +57,19 @@
t.Fatalf("Unable to create a compute client: %v", err)
}
- choices, err := clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
- server, err := CreateServer(t, client, choices)
+ server, err := CreateServer(t, client)
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
defer DeleteServer(t, client, server)
- floatingIP, err := CreateFloatingIP(t, client, choices)
+ floatingIP, err := CreateFloatingIP(t, client)
if err != nil {
t.Fatalf("Unable to create floating IP: %v", err)
}
defer DeleteFloatingIP(t, client, floatingIP)
- PrintFloatingIP(t, floatingIP)
+ tools.PrintResource(t, floatingIP)
err = AssociateFloatingIP(t, client, floatingIP, server)
if err != nil {
@@ -93,7 +84,7 @@
t.Logf("Floating IP %s is associated with Fixed IP %s", floatingIP.IP, newFloatingIP.FixedIP)
- PrintFloatingIP(t, newFloatingIP)
+ tools.PrintResource(t, newFloatingIP)
}
func TestFloatingIPsFixedIPAssociate(t *testing.T) {
@@ -111,7 +102,7 @@
t.Fatal(err)
}
- server, err := CreateServer(t, client, choices)
+ server, err := CreateServer(t, client)
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
@@ -122,13 +113,13 @@
t.Fatalf("Unable to get server %s: %v", server.ID, err)
}
- floatingIP, err := CreateFloatingIP(t, client, choices)
+ floatingIP, err := CreateFloatingIP(t, client)
if err != nil {
t.Fatalf("Unable to create floating IP: %v", err)
}
defer DeleteFloatingIP(t, client, floatingIP)
- PrintFloatingIP(t, floatingIP)
+ tools.PrintResource(t, floatingIP)
var fixedIP string
for _, networkAddresses := range newServer.Addresses[choices.NetworkName].([]interface{}) {
@@ -153,5 +144,5 @@
t.Logf("Floating IP %s is associated with Fixed IP %s", floatingIP.IP, newFloatingIP.FixedIP)
- PrintFloatingIP(t, newFloatingIP)
+ tools.PrintResource(t, newFloatingIP)
}
diff --git a/acceptance/openstack/compute/v2/images_test.go b/acceptance/openstack/compute/v2/images_test.go
index 53291dd..a34ce3e 100644
--- a/acceptance/openstack/compute/v2/images_test.go
+++ b/acceptance/openstack/compute/v2/images_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/compute/v2/images"
)
@@ -26,7 +27,7 @@
}
for _, image := range allImages {
- PrintImage(t, image)
+ tools.PrintResource(t, image)
}
}
@@ -46,5 +47,5 @@
t.Fatalf("Unable to get image information: %v", err)
}
- PrintImage(t, *image)
+ tools.PrintResource(t, image)
}
diff --git a/acceptance/openstack/compute/v2/keypairs_test.go b/acceptance/openstack/compute/v2/keypairs_test.go
index 3c6abb4..c4b91ec 100644
--- a/acceptance/openstack/compute/v2/keypairs_test.go
+++ b/acceptance/openstack/compute/v2/keypairs_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs"
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
)
@@ -29,7 +30,7 @@
}
for _, keypair := range allKeys {
- PrintKeyPair(t, &keypair)
+ tools.PrintResource(t, keypair)
}
}
@@ -45,7 +46,7 @@
}
defer DeleteKeyPair(t, client, keyPair)
- PrintKeyPair(t, keyPair)
+ tools.PrintResource(t, keyPair)
}
func TestKeypairsImportPublicKey(t *testing.T) {
@@ -65,7 +66,7 @@
}
defer DeleteKeyPair(t, client, keyPair)
- PrintKeyPair(t, keyPair)
+ tools.PrintResource(t, keyPair)
}
func TestKeypairsServerCreateWithKey(t *testing.T) {
@@ -78,11 +79,6 @@
t.Fatalf("Unable to create a compute client: %v", err)
}
- choices, err := clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
publicKey, err := createKey()
if err != nil {
t.Fatalf("Unable to create public key: %s", err)
@@ -94,7 +90,7 @@
}
defer DeleteKeyPair(t, client, keyPair)
- server, err := CreateServerWithPublicKey(t, client, choices, keyPair.Name)
+ server, err := CreateServerWithPublicKey(t, client, keyPair.Name)
if err != nil {
t.Fatalf("Unable to create server: %s", err)
}
diff --git a/acceptance/openstack/compute/v2/network_test.go b/acceptance/openstack/compute/v2/network_test.go
index 38a6d54..7451518 100644
--- a/acceptance/openstack/compute/v2/network_test.go
+++ b/acceptance/openstack/compute/v2/network_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/networks"
)
@@ -26,7 +27,7 @@
}
for _, network := range allNetworks {
- PrintNetwork(t, &network)
+ tools.PrintResource(t, network)
}
}
@@ -51,5 +52,5 @@
t.Fatalf("Unable to get network %s: %v", networkID, err)
}
- PrintNetwork(t, network)
+ tools.PrintResource(t, network)
}
diff --git a/acceptance/openstack/compute/v2/quotaset_test.go b/acceptance/openstack/compute/v2/quotaset_test.go
index 2fb7c99..e0c4bae 100644
--- a/acceptance/openstack/compute/v2/quotaset_test.go
+++ b/acceptance/openstack/compute/v2/quotaset_test.go
@@ -8,6 +8,7 @@
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/quotasets"
"github.com/gophercloud/gophercloud/openstack/identity/v2/tenants"
th "github.com/gophercloud/gophercloud/testhelper"
@@ -35,7 +36,7 @@
t.Fatal(err)
}
- PrintQuotaSet(t, quotaSet)
+ tools.PrintResource(t, quotaSet)
}
func getTenantID(t *testing.T, client *gophercloud.ServiceClient) (string, error) {
@@ -182,4 +183,4 @@
}`
FillUpdateOptsFromQuotaSet(UpdatedQuotas,op)
th.AssertJSONEquals(t,expected,op)
-}
\ No newline at end of file
+}
diff --git a/acceptance/openstack/compute/v2/secgroup_test.go b/acceptance/openstack/compute/v2/secgroup_test.go
index 9ec7ba4..c0d0230 100644
--- a/acceptance/openstack/compute/v2/secgroup_test.go
+++ b/acceptance/openstack/compute/v2/secgroup_test.go
@@ -27,7 +27,7 @@
}
for _, secgroup := range allSecGroups {
- PrintSecurityGroup(t, &secgroup)
+ tools.PrintResource(t, secgroup)
}
}
@@ -85,6 +85,14 @@
t.Fatalf("Unable to create rule: %v", err)
}
defer DeleteSecurityGroupRule(t, client, rule)
+
+ newSecurityGroup, err := secgroups.Get(client, securityGroup.ID).Extract()
+ if err != nil {
+ t.Fatalf("Unable to obtain security group: %v", err)
+ }
+
+ tools.PrintResource(t, newSecurityGroup)
+
}
func TestSecGroupsAddGroupToServer(t *testing.T) {
@@ -97,12 +105,7 @@
t.Fatalf("Unable to create a compute client: %v", err)
}
- choices, err := clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
- server, err := CreateServer(t, client, choices)
+ server, err := CreateServer(t, client)
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
diff --git a/acceptance/openstack/compute/v2/servergroup_test.go b/acceptance/openstack/compute/v2/servergroup_test.go
index 5921014..ac1915f 100644
--- a/acceptance/openstack/compute/v2/servergroup_test.go
+++ b/acceptance/openstack/compute/v2/servergroup_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/servergroups"
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
)
@@ -27,7 +28,7 @@
}
for _, serverGroup := range allServerGroups {
- PrintServerGroup(t, &serverGroup)
+ tools.PrintResource(t, serverGroup)
}
}
@@ -48,7 +49,7 @@
t.Fatalf("Unable to get server group: %v", err)
}
- PrintServerGroup(t, serverGroup)
+ tools.PrintResource(t, serverGroup)
}
func TestServergroupsAffinityPolicy(t *testing.T) {
@@ -57,18 +58,13 @@
t.Fatalf("Unable to create a compute client: %v", err)
}
- choices, err := clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
serverGroup, err := CreateServerGroup(t, client, "affinity")
if err != nil {
t.Fatalf("Unable to create server group: %v", err)
}
defer DeleteServerGroup(t, client, serverGroup)
- firstServer, err := CreateServerInServerGroup(t, client, choices, serverGroup)
+ firstServer, err := CreateServerInServerGroup(t, client, serverGroup)
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
@@ -76,7 +72,7 @@
firstServer, err = servers.Get(client, firstServer.ID).Extract()
- secondServer, err := CreateServerInServerGroup(t, client, choices, serverGroup)
+ secondServer, err := CreateServerInServerGroup(t, client, serverGroup)
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
diff --git a/acceptance/openstack/compute/v2/servers_test.go b/acceptance/openstack/compute/v2/servers_test.go
index fa6603d..22b6580 100644
--- a/acceptance/openstack/compute/v2/servers_test.go
+++ b/acceptance/openstack/compute/v2/servers_test.go
@@ -30,7 +30,7 @@
}
for _, server := range allServers {
- PrintServer(t, &server)
+ tools.PrintResource(t, server)
}
}
@@ -45,7 +45,7 @@
t.Fatal(err)
}
- server, err := CreateServer(t, client, choices)
+ server, err := CreateServer(t, client)
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
@@ -56,7 +56,7 @@
if err != nil {
t.Errorf("Unable to retrieve server: %v", err)
}
- PrintServer(t, newServer)
+ tools.PrintResource(t, newServer)
allAddressPages, err := servers.ListAddresses(client, server.ID).AllPages()
if err != nil {
@@ -94,12 +94,7 @@
t.Fatalf("Unable to create a compute client: %v", err)
}
- choices, err := clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
- server, err := CreateServerWithoutImageRef(t, client, choices)
+ server, err := CreateServerWithoutImageRef(t, client)
if err != nil {
if err400, ok := err.(*gophercloud.ErrUnexpectedResponseCode); ok {
if !strings.Contains("Missing imageRef attribute", string(err400.Body)) {
@@ -115,12 +110,7 @@
t.Fatalf("Unable to create a compute client: %v", err)
}
- choices, err := clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
- server, err := CreateServer(t, client, choices)
+ server, err := CreateServer(t, client)
if err != nil {
t.Fatal(err)
}
@@ -159,17 +149,12 @@
func TestServersMetadata(t *testing.T) {
t.Parallel()
- choices, err := clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
client, err := clients.NewComputeV2Client()
if err != nil {
t.Fatalf("Unable to create a compute client: %v", err)
}
- server, err := CreateServer(t, client, choices)
+ server, err := CreateServer(t, client)
if err != nil {
t.Fatal(err)
}
@@ -226,12 +211,7 @@
t.Fatalf("Unable to create a compute client: %v", err)
}
- choices, err := clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
- server, err := CreateServer(t, client, choices)
+ server, err := CreateServer(t, client)
if err != nil {
t.Fatal(err)
}
@@ -260,12 +240,7 @@
t.Fatalf("Unable to create a compute client: %v", err)
}
- choices, err := clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
- server, err := CreateServer(t, client, choices)
+ server, err := CreateServer(t, client)
if err != nil {
t.Fatal(err)
}
@@ -303,7 +278,7 @@
t.Fatal(err)
}
- server, err := CreateServer(t, client, choices)
+ server, err := CreateServer(t, client)
if err != nil {
t.Fatal(err)
}
@@ -338,24 +313,19 @@
func TestServersActionResizeConfirm(t *testing.T) {
t.Parallel()
- choices, err := clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
client, err := clients.NewComputeV2Client()
if err != nil {
t.Fatalf("Unable to create a compute client: %v", err)
}
- server, err := CreateServer(t, client, choices)
+ server, err := CreateServer(t, client)
if err != nil {
t.Fatal(err)
}
defer DeleteServer(t, client, server)
t.Logf("Attempting to resize server %s", server.ID)
- ResizeServer(t, client, server, choices)
+ ResizeServer(t, client, server)
t.Logf("Attempting to confirm resize for server %s", server.ID)
if res := servers.ConfirmResize(client, server.ID); res.Err != nil {
@@ -370,24 +340,19 @@
func TestServersActionResizeRevert(t *testing.T) {
t.Parallel()
- choices, err := clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
client, err := clients.NewComputeV2Client()
if err != nil {
t.Fatalf("Unable to create a compute client: %v", err)
}
- server, err := CreateServer(t, client, choices)
+ server, err := CreateServer(t, client)
if err != nil {
t.Fatal(err)
}
defer DeleteServer(t, client, server)
t.Logf("Attempting to resize server %s", server.ID)
- ResizeServer(t, client, server, choices)
+ ResizeServer(t, client, server)
t.Logf("Attempting to revert resize for server %s", server.ID)
if res := servers.RevertResize(client, server.ID); res.Err != nil {
diff --git a/acceptance/openstack/compute/v2/tenantnetworks_test.go b/acceptance/openstack/compute/v2/tenantnetworks_test.go
index 7d9c167..9b6b527 100644
--- a/acceptance/openstack/compute/v2/tenantnetworks_test.go
+++ b/acceptance/openstack/compute/v2/tenantnetworks_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/tenantnetworks"
)
@@ -26,7 +27,7 @@
}
for _, network := range allTenantNetworks {
- PrintTenantNetwork(t, &network)
+ tools.PrintResource(t, network)
}
}
@@ -51,5 +52,5 @@
t.Fatalf("Unable to get network %s: %v", networkID, err)
}
- PrintTenantNetwork(t, network)
+ tools.PrintResource(t, network)
}
diff --git a/acceptance/openstack/compute/v2/volumeattach_test.go b/acceptance/openstack/compute/v2/volumeattach_test.go
index d791992..78d85a9 100644
--- a/acceptance/openstack/compute/v2/volumeattach_test.go
+++ b/acceptance/openstack/compute/v2/volumeattach_test.go
@@ -21,17 +21,12 @@
t.Fatalf("Unable to create a compute client: %v", err)
}
- choices, err :=clients.AcceptanceTestChoicesFromEnv()
- if err != nil {
- t.Fatal(err)
- }
-
blockClient, err := clients.NewBlockStorageV1Client()
if err != nil {
t.Fatalf("Unable to create a blockstorage client: %v", err)
}
- server, err := CreateServer(t, client, choices)
+ server, err := CreateServer(t, client)
if err != nil {
t.Fatalf("Unable to create server: %v", err)
}
@@ -53,7 +48,7 @@
}
defer DeleteVolumeAttachment(t, client, blockClient, server, volumeAttachment)
- PrintVolumeAttachment(t, volumeAttachment)
+ tools.PrintResource(t, volumeAttachment)
}
diff --git a/acceptance/openstack/identity/v2/extension_test.go b/acceptance/openstack/identity/v2/extension_test.go
index 3e526f1..c6a2bde 100644
--- a/acceptance/openstack/identity/v2/extension_test.go
+++ b/acceptance/openstack/identity/v2/extension_test.go
@@ -6,7 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
- "github.com/gophercloud/gophercloud/acceptance/openstack"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/identity/v2/extensions"
)
@@ -27,7 +27,7 @@
}
for _, extension := range allExtensions {
- openstack.PrintExtension(t, &extension)
+ tools.PrintResource(t, extension)
}
}
@@ -42,5 +42,5 @@
t.Fatalf("Unable to get extension OS-KSCRUD: %v", err)
}
- openstack.PrintExtension(t, extension)
+ tools.PrintResource(t, extension)
}
diff --git a/acceptance/openstack/identity/v2/identity.go b/acceptance/openstack/identity/v2/identity.go
index f1c6624..2d3bd09 100644
--- a/acceptance/openstack/identity/v2/identity.go
+++ b/acceptance/openstack/identity/v2/identity.go
@@ -9,7 +9,6 @@
"github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/identity/v2/extensions/admin/roles"
"github.com/gophercloud/gophercloud/openstack/identity/v2/tenants"
- "github.com/gophercloud/gophercloud/openstack/identity/v2/tokens"
"github.com/gophercloud/gophercloud/openstack/identity/v2/users"
)
@@ -145,72 +144,3 @@
return newUser, nil
}
-
-// PrintCatalogEntry will print a catalog entry and all of its attributes.
-func PrintCatalogEntry(t *testing.T, catalogEntry *tokens.CatalogEntry) {
- t.Logf("Name: %s", catalogEntry.Name)
- t.Logf("Type: %s", catalogEntry.Type)
-
- t.Log("Endpoints:")
- for _, endpoint := range catalogEntry.Endpoints {
- t.Logf("\tTenantID: %s", endpoint.TenantID)
- t.Logf("\tPublicURL: %s", endpoint.PublicURL)
- t.Logf("\tInternalURL: %s", endpoint.InternalURL)
- t.Logf("\tAdminURL: %s", endpoint.AdminURL)
- t.Logf("\tRegion: %s", endpoint.Region)
- t.Logf("\tVersionID: %s", endpoint.VersionID)
- t.Logf("\tVersionInfo: %s", endpoint.VersionInfo)
- t.Logf("\tVersionList: %s", endpoint.VersionList)
- }
-}
-
-// PrintRole will print a role and all of its attributes.
-func PrintRole(t *testing.T, role *roles.Role) {
- t.Logf("ID: %s", role.ID)
- t.Logf("Name: %v", role.Name)
- t.Logf("Description: %s", role.Description)
- t.Logf("ServiceID: %s", role.ServiceID)
-}
-
-// PrintTenant will print a tenant and all of its attributes.
-func PrintTenant(t *testing.T, tenant *tenants.Tenant) {
- t.Logf("ID: %s", tenant.ID)
- t.Logf("Name: %s", tenant.Name)
- t.Logf("Description: %s", tenant.Description)
- t.Logf("Enabled: %t", tenant.Enabled)
-}
-
-// PrintToken will print a token and all of its attributes.
-func PrintToken(t *testing.T, token *tokens.Token) {
- t.Logf("ID: %s", token.ID)
- t.Logf("ExpiresAt: %v", token.ExpiresAt)
- t.Logf("TenantID: %s", token.Tenant.ID)
-}
-
-// PrintTokenUser will print the user information of a token and all attributes.
-func PrintTokenUser(t *testing.T, user *tokens.User) {
- t.Logf("ID: %s", user.ID)
- t.Logf("Name: %s", user.Name)
- t.Logf("Username: %s", user.UserName)
-
- t.Log("Roles")
- for _, role := range user.Roles {
- t.Logf("\t%s", role)
- }
-}
-
-// PrintUser will print a user and all of its attributes.
-func PrintUser(t *testing.T, user *users.User) {
- t.Logf("ID: %s", user.ID)
- t.Logf("Name: %s", user.Name)
- t.Logf("Username: %s", user.Username)
- t.Logf("Enabled: %t", user.Enabled)
- t.Logf("Email: %s", user.Email)
- t.Logf("TenantID: %s", user.TenantID)
-}
-
-// PrintUserRole will print the roles that a user has been granted.
-func PrintUserRole(t *testing.T, role *users.Role) {
- t.Logf("ID: %s", role.ID)
- t.Logf("Name: %s", role.Name)
-}
diff --git a/acceptance/openstack/identity/v2/role_test.go b/acceptance/openstack/identity/v2/role_test.go
index 5589b1b..83fbd31 100644
--- a/acceptance/openstack/identity/v2/role_test.go
+++ b/acceptance/openstack/identity/v2/role_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/identity/v2/extensions/admin/roles"
"github.com/gophercloud/gophercloud/openstack/identity/v2/users"
)
@@ -50,7 +51,7 @@
t.Logf("Roles of user %s:", user.Name)
for _, role := range allRoles {
- PrintUserRole(t, &role)
+ tools.PrintResource(t, role)
}
}
@@ -71,6 +72,6 @@
}
for _, r := range allRoles {
- PrintRole(t, &r)
+ tools.PrintResource(t, r)
}
}
diff --git a/acceptance/openstack/identity/v2/tenant_test.go b/acceptance/openstack/identity/v2/tenant_test.go
index ed457d4..2053614 100644
--- a/acceptance/openstack/identity/v2/tenant_test.go
+++ b/acceptance/openstack/identity/v2/tenant_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/identity/v2/tenants"
)
@@ -26,6 +27,6 @@
}
for _, tenant := range allTenants {
- PrintTenant(t, &tenant)
+ tools.PrintResource(t, tenant)
}
}
diff --git a/acceptance/openstack/identity/v2/token_test.go b/acceptance/openstack/identity/v2/token_test.go
index 4cd8301..82a317a 100644
--- a/acceptance/openstack/identity/v2/token_test.go
+++ b/acceptance/openstack/identity/v2/token_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack"
"github.com/gophercloud/gophercloud/openstack/identity/v2/tokens"
)
@@ -27,7 +28,7 @@
t.Fatalf("Unable to extract token: %v", err)
}
- PrintToken(t, token)
+ tools.PrintResource(t, token)
catalog, err := result.ExtractServiceCatalog()
if err != nil {
@@ -35,7 +36,7 @@
}
for _, entry := range catalog.Entries {
- PrintCatalogEntry(t, &entry)
+ tools.PrintResource(t, entry)
}
}
@@ -56,7 +57,7 @@
t.Fatalf("Unable to extract token: %v", err)
}
- PrintToken(t, token)
+ tools.PrintResource(t, token)
getResult := tokens.Get(client, token.ID)
user, err := getResult.ExtractUser()
@@ -64,5 +65,5 @@
t.Fatalf("Unable to extract user: %v", err)
}
- PrintTokenUser(t, user)
+ tools.PrintResource(t, user)
}
diff --git a/acceptance/openstack/identity/v2/user_test.go b/acceptance/openstack/identity/v2/user_test.go
index 5c6bfd9..faa5bba 100644
--- a/acceptance/openstack/identity/v2/user_test.go
+++ b/acceptance/openstack/identity/v2/user_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/identity/v2/users"
)
@@ -26,7 +27,7 @@
}
for _, user := range allUsers {
- PrintUser(t, &user)
+ tools.PrintResource(t, user)
}
}
@@ -47,12 +48,12 @@
}
defer DeleteUser(t, client, user)
- PrintUser(t, user)
+ tools.PrintResource(t, user)
newUser, err := UpdateUser(t, client, user)
if err != nil {
t.Fatalf("Unable to update user: %v", err)
}
- PrintUser(t, newUser)
+ tools.PrintResource(t, newUser)
}
diff --git a/acceptance/openstack/identity/v3/endpoint_test.go b/acceptance/openstack/identity/v3/endpoint_test.go
index 6a52f26..a589970 100644
--- a/acceptance/openstack/identity/v3/endpoint_test.go
+++ b/acceptance/openstack/identity/v3/endpoint_test.go
@@ -7,6 +7,7 @@
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/identity/v3/endpoints"
"github.com/gophercloud/gophercloud/openstack/identity/v3/services"
)
@@ -28,7 +29,7 @@
}
for _, endpoint := range allEndpoints {
- PrintEndpoint(t, &endpoint)
+ tools.PrintResource(t, endpoint)
}
}
@@ -58,7 +59,7 @@
}
computeService := allServices[0]
- PrintService(t, &computeService)
+ tools.PrintResource(t, computeService)
// Enumerate the endpoints available for this service.
endpointListOpts := endpoints.ListOpts{
@@ -80,6 +81,6 @@
t.Fatalf("Expected one endpoint, got %d", len(allEndpoints))
}
- PrintEndpoint(t, &allEndpoints[0])
+ tools.PrintResource(t, allEndpoints[0])
}
diff --git a/acceptance/openstack/identity/v3/identity.go b/acceptance/openstack/identity/v3/identity.go
index f7ea48f..3276efc 100644
--- a/acceptance/openstack/identity/v3/identity.go
+++ b/acceptance/openstack/identity/v3/identity.go
@@ -5,10 +5,7 @@
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/acceptance/tools"
- "github.com/gophercloud/gophercloud/openstack/identity/v3/endpoints"
"github.com/gophercloud/gophercloud/openstack/identity/v3/projects"
- "github.com/gophercloud/gophercloud/openstack/identity/v3/services"
- "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens"
)
// CreateProject will create a project with a random name.
@@ -49,38 +46,3 @@
t.Logf("Deleted project: %s", projectID)
}
-
-// PrintEndpoint will print an endpoint and all of its attributes.
-func PrintEndpoint(t *testing.T, endpoint *endpoints.Endpoint) {
- t.Logf("ID: %s", endpoint.ID)
- t.Logf("Availability: %s", endpoint.Availability)
- t.Logf("Name: %s", endpoint.Name)
- t.Logf("Region: %s", endpoint.Region)
- t.Logf("ServiceID: %s", endpoint.ServiceID)
- t.Logf("URL: %s", endpoint.URL)
-}
-
-// PrintProject will print a project and all of its attributes.
-func PrintProject(t *testing.T, project *projects.Project) {
- t.Logf("ID: %s", project.ID)
- t.Logf("IsDomain: %t", project.IsDomain)
- t.Logf("Description: %s", project.Description)
- t.Logf("DomainID: %s", project.DomainID)
- t.Logf("Enabled: %t", project.Enabled)
- t.Logf("Name: %s", project.Name)
- t.Logf("ParentID: %s", project.ParentID)
-}
-
-// PrintService will print a service and all of its attributes.
-func PrintService(t *testing.T, service *services.Service) {
- t.Logf("ID: %s", service.ID)
- t.Logf("Description: %s", service.Description)
- t.Logf("Name: %s", service.Name)
- t.Logf("Type: %s", service.Type)
-}
-
-// PrintToken will print a token and all of its attributes.
-func PrintToken(t *testing.T, token *tokens.Token) {
- t.Logf("ID: %s", token.ID)
- t.Logf("ExpiresAt: %v", token.ExpiresAt)
-}
diff --git a/acceptance/openstack/identity/v3/projects_test.go b/acceptance/openstack/identity/v3/projects_test.go
index ebb5543..8325bee 100644
--- a/acceptance/openstack/identity/v3/projects_test.go
+++ b/acceptance/openstack/identity/v3/projects_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/identity/v3/projects"
)
@@ -31,7 +32,7 @@
}
for _, project := range allProjects {
- PrintProject(t, &project)
+ tools.PrintResource(t, project)
}
}
@@ -57,7 +58,7 @@
t.Fatalf("Unable to get project: %v", err)
}
- PrintProject(t, p)
+ tools.PrintResource(t, p)
}
func TestProjectsCRUD(t *testing.T) {
@@ -72,7 +73,7 @@
}
defer DeleteProject(t, client, project.ID)
- PrintProject(t, project)
+ tools.PrintResource(t, project)
var iFalse bool = false
updateOpts := projects.UpdateOpts{
@@ -84,7 +85,7 @@
t.Fatalf("Unable to update project: %v", err)
}
- PrintProject(t, updatedProject)
+ tools.PrintResource(t, updatedProject)
}
func TestProjectsDomain(t *testing.T) {
@@ -104,7 +105,7 @@
}
defer DeleteProject(t, client, projectDomain.ID)
- PrintProject(t, projectDomain)
+ tools.PrintResource(t, projectDomain)
createOpts = projects.CreateOpts{
DomainID: projectDomain.ID,
@@ -116,7 +117,7 @@
}
defer DeleteProject(t, client, project.ID)
- PrintProject(t, project)
+ tools.PrintResource(t, project)
var iFalse = false
updateOpts := projects.UpdateOpts{
@@ -141,7 +142,7 @@
}
defer DeleteProject(t, client, projectMain.ID)
- PrintProject(t, projectMain)
+ tools.PrintResource(t, projectMain)
createOpts := projects.CreateOpts{
ParentID: projectMain.ID,
@@ -153,5 +154,5 @@
}
defer DeleteProject(t, client, project.ID)
- PrintProject(t, project)
+ tools.PrintResource(t, project)
}
diff --git a/acceptance/openstack/identity/v3/service_test.go b/acceptance/openstack/identity/v3/service_test.go
index 364f69b..7a0c71f 100644
--- a/acceptance/openstack/identity/v3/service_test.go
+++ b/acceptance/openstack/identity/v3/service_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/identity/v3/services"
)
@@ -26,7 +27,7 @@
}
for _, service := range allServices {
- PrintService(t, &service)
+ tools.PrintResource(t, service)
}
}
diff --git a/acceptance/openstack/identity/v3/token_test.go b/acceptance/openstack/identity/v3/token_test.go
index 13b38f8..e0f90d9 100644
--- a/acceptance/openstack/identity/v3/token_test.go
+++ b/acceptance/openstack/identity/v3/token_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack"
"github.com/gophercloud/gophercloud/openstack/identity/v3/tokens"
)
@@ -32,5 +33,5 @@
t.Fatalf("Unable to get token: %v", err)
}
- PrintToken(t, token)
+ tools.PrintResource(t, token)
}
diff --git a/acceptance/openstack/networking/v2/apiversion_test.go b/acceptance/openstack/networking/v2/apiversion_test.go
index 409550c..c6f8f26 100644
--- a/acceptance/openstack/networking/v2/apiversion_test.go
+++ b/acceptance/openstack/networking/v2/apiversion_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/apiversions"
)
@@ -26,7 +27,7 @@
}
for _, apiVersion := range allAPIVersions {
- PrintAPIVersion(t, &apiVersion)
+ tools.PrintResource(t, apiVersion)
}
}
@@ -47,6 +48,6 @@
}
for _, versionResource := range allVersionResources {
- PrintVersionResource(t, &versionResource)
+ tools.PrintResource(t, versionResource)
}
}
diff --git a/acceptance/openstack/networking/v2/extension_test.go b/acceptance/openstack/networking/v2/extension_test.go
index baade1e..5609e85 100644
--- a/acceptance/openstack/networking/v2/extension_test.go
+++ b/acceptance/openstack/networking/v2/extension_test.go
@@ -6,7 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
- "github.com/gophercloud/gophercloud/acceptance/openstack"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/common/extensions"
)
@@ -27,7 +27,7 @@
}
for _, extension := range allExtensions {
- openstack.PrintExtension(t, &extension)
+ tools.PrintResource(t, extension)
}
}
@@ -42,5 +42,5 @@
t.Fatalf("Unable to get extension port-security: %v", err)
}
- openstack.PrintExtension(t, extension)
+ tools.PrintResource(t, extension)
}
diff --git a/acceptance/openstack/networking/v2/extensions/extensions.go b/acceptance/openstack/networking/v2/extensions/extensions.go
index f18e430..154e34e 100644
--- a/acceptance/openstack/networking/v2/extensions/extensions.go
+++ b/acceptance/openstack/networking/v2/extensions/extensions.go
@@ -6,7 +6,6 @@
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/external"
- "github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/provider"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/rules"
"github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
@@ -137,44 +136,3 @@
t.Fatalf("Unable to delete security group rule: %v", err)
}
}
-
-// PrintNetworkExtAttrs prints a network and all of its extra attributes.
-func PrintNetworkExtAttrs(t *testing.T, network *provider.NetworkExtAttrs) {
- t.Logf("ID: %s", network.ID)
- t.Logf("Name: %s", network.Name)
- t.Logf("AdminStateUp: %t", network.AdminStateUp)
- t.Logf("Status: %s", network.Status)
- t.Logf("Subnets: %s", network.Subnets)
- t.Logf("TenantID: %s", network.TenantID)
- t.Logf("Shared: %t", network.Shared)
- t.Logf("NetworkType: %s", network.NetworkType)
- t.Logf("PhysicalNetwork: %s", network.PhysicalNetwork)
- t.Logf("SegmentationID: %d", network.SegmentationID)
-}
-
-// PrintSecurityGroup will print a security group and all of its attributes.
-func PrintSecurityGroup(t *testing.T, secGroup *groups.SecGroup) {
- t.Logf("ID: %s", secGroup.ID)
- t.Logf("Name: %s", secGroup.Name)
- t.Logf("Description: %s", secGroup.Description)
- t.Logf("TenantID: %s", secGroup.TenantID)
- t.Logf("Rules:")
-
- for _, rule := range secGroup.Rules {
- PrintSecurityGroupRule(t, &rule)
- }
-}
-
-// PrintSecurityGroupRule will print a security group rule and all of its attributes.
-func PrintSecurityGroupRule(t *testing.T, rule *rules.SecGroupRule) {
- t.Logf("ID: %s", rule.ID)
- t.Logf("Direction: %s", rule.Direction)
- t.Logf("EtherType: %s", rule.EtherType)
- t.Logf("SecGroupID: %s", rule.SecGroupID)
- t.Logf("PortRangeMin: %d", rule.PortRangeMin)
- t.Logf("PortRangeMax: %d", rule.PortRangeMax)
- t.Logf("Protocol: %s", rule.Protocol)
- t.Logf("RemoteGroupID: %s", rule.RemoteGroupID)
- t.Logf("RemoteIPPrefix: %s", rule.RemoteIPPrefix)
- t.Logf("TenantID: %s", rule.TenantID)
-}
diff --git a/acceptance/openstack/networking/v2/extensions/fwaas/firewall_test.go b/acceptance/openstack/networking/v2/extensions/fwaas/firewall_test.go
index 0b021d3..473013b 100644
--- a/acceptance/openstack/networking/v2/extensions/fwaas/firewall_test.go
+++ b/acceptance/openstack/networking/v2/extensions/fwaas/firewall_test.go
@@ -7,6 +7,7 @@
"github.com/gophercloud/gophercloud/acceptance/clients"
layer3 "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2/extensions/layer3"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/firewalls"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/routerinsertion"
)
@@ -28,7 +29,7 @@
}
for _, firewall := range allFirewalls {
- PrintFirewall(t, &firewall)
+ tools.PrintResource(t, firewall)
}
}
@@ -50,7 +51,7 @@
}
defer DeleteRule(t, client, rule.ID)
- PrintRule(t, rule)
+ tools.PrintResource(t, rule)
policy, err := CreatePolicy(t, client, rule.ID)
if err != nil {
@@ -58,7 +59,7 @@
}
defer DeletePolicy(t, client, policy.ID)
- PrintPolicy(t, policy)
+ tools.PrintResource(t, policy)
firewall, err := CreateFirewallOnRouter(t, client, policy.ID, router.ID)
if err != nil {
@@ -66,7 +67,7 @@
}
defer DeleteFirewall(t, client, firewall.ID)
- PrintFirewall(t, firewall)
+ tools.PrintResource(t, firewall)
router2, err := layer3.CreateExternalRouter(t, client)
if err != nil {
@@ -94,5 +95,5 @@
t.Fatalf("Unable to get firewall: %v", err)
}
- PrintFirewall(t, newFirewall)
+ tools.PrintResource(t, newFirewall)
}
diff --git a/acceptance/openstack/networking/v2/extensions/fwaas/fwaas.go b/acceptance/openstack/networking/v2/extensions/fwaas/fwaas.go
index dd361f9..204565b 100644
--- a/acceptance/openstack/networking/v2/extensions/fwaas/fwaas.go
+++ b/acceptance/openstack/networking/v2/extensions/fwaas/fwaas.go
@@ -20,9 +20,11 @@
t.Logf("Attempting to create firewall %s", firewallName)
+ iTrue := true
createOpts := firewalls.CreateOpts{
- Name: firewallName,
- PolicyID: policyID,
+ Name: firewallName,
+ PolicyID: policyID,
+ AdminStateUp: &iTrue,
}
firewall, err := firewalls.Create(client, createOpts).Extract()
@@ -177,49 +179,6 @@
t.Logf("Deleted rule: %s", ruleID)
}
-// PrintFirewall will print a firewall and all of its attributes.
-func PrintFirewall(t *testing.T, firewall *firewalls.Firewall) {
- t.Logf("ID: %s", firewall.ID)
- t.Logf("Name: %s", firewall.Name)
- t.Logf("Description: %s", firewall.Description)
- t.Logf("AdminStateUp: %t", firewall.AdminStateUp)
- t.Logf("Status: %s", firewall.Status)
- t.Logf("PolicyID: %s", firewall.PolicyID)
- t.Logf("TenantID: %s", firewall.TenantID)
-}
-
-// PrintPolicy will print a policy and all of its attributes.
-func PrintPolicy(t *testing.T, policy *policies.Policy) {
- t.Logf("ID: %s", policy.ID)
- t.Logf("Name: %s", policy.Name)
- t.Logf("Description: %s", policy.Description)
- t.Logf("TenantID: %s", policy.TenantID)
- t.Logf("Audited: %t", policy.Audited)
- t.Logf("Shared: %t", policy.Shared)
- t.Logf("Rules:")
-
- for _, rule := range policy.Rules {
- t.Logf("Rule ID: %s", rule)
- }
-}
-
-// PrintRule will print a rule and all of its attributes.
-func PrintRule(t *testing.T, rule *rules.Rule) {
- t.Logf("ID: %s", rule.ID)
- t.Logf("Name: %s", rule.Name)
- t.Logf("Description: %s", rule.Description)
- t.Logf("Protocol: %s", rule.Protocol)
- t.Logf("Action: %s", rule.Action)
- t.Logf("IPVersion: %d", rule.IPVersion)
- t.Logf("SourceIPAddress: %s", rule.SourceIPAddress)
- t.Logf("DestinationIPAddress: %s", rule.DestinationIPAddress)
- t.Logf("Shared: %t", rule.Shared)
- t.Logf("Enabled: %t", rule.Enabled)
- t.Logf("PolicyID: %s", rule.PolicyID)
- t.Logf("Position: %d", rule.Position)
- t.Logf("TenantID: %s", rule.TenantID)
-}
-
// WaitForFirewallState will wait until a firewall reaches a given state.
func WaitForFirewallState(client *gophercloud.ServiceClient, firewallID, status string, secs int) error {
return gophercloud.WaitFor(secs, func() (bool, error) {
diff --git a/acceptance/openstack/networking/v2/extensions/fwaas/policy_test.go b/acceptance/openstack/networking/v2/extensions/fwaas/policy_test.go
index 9003e54..3220d82 100644
--- a/acceptance/openstack/networking/v2/extensions/fwaas/policy_test.go
+++ b/acceptance/openstack/networking/v2/extensions/fwaas/policy_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/policies"
)
@@ -26,7 +27,7 @@
}
for _, policy := range allPolicies {
- PrintPolicy(t, &policy)
+ tools.PrintResource(t, policy)
}
}
@@ -42,7 +43,7 @@
}
defer DeleteRule(t, client, rule.ID)
- PrintRule(t, rule)
+ tools.PrintResource(t, rule)
policy, err := CreatePolicy(t, client, rule.ID)
if err != nil {
@@ -50,7 +51,7 @@
}
defer DeletePolicy(t, client, policy.ID)
- PrintPolicy(t, policy)
+ tools.PrintResource(t, policy)
updateOpts := policies.UpdateOpts{
Description: "Some policy description",
@@ -66,5 +67,5 @@
t.Fatalf("Unable to get policy: %v", err)
}
- PrintPolicy(t, newPolicy)
+ tools.PrintResource(t, newPolicy)
}
diff --git a/acceptance/openstack/networking/v2/extensions/fwaas/rule_test.go b/acceptance/openstack/networking/v2/extensions/fwaas/rule_test.go
index c8e67dc..4521a60 100644
--- a/acceptance/openstack/networking/v2/extensions/fwaas/rule_test.go
+++ b/acceptance/openstack/networking/v2/extensions/fwaas/rule_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/fwaas/rules"
)
@@ -26,7 +27,7 @@
}
for _, rule := range allRules {
- PrintRule(t, &rule)
+ tools.PrintResource(t, rule)
}
}
@@ -42,7 +43,7 @@
}
defer DeleteRule(t, client, rule.ID)
- PrintRule(t, rule)
+ tools.PrintResource(t, rule)
ruleDescription := "Some rule description"
updateOpts := rules.UpdateOpts{
@@ -59,5 +60,5 @@
t.Fatalf("Unable to get rule: %v", err)
}
- PrintRule(t, newRule)
+ tools.PrintResource(t, newRule)
}
diff --git a/acceptance/openstack/networking/v2/extensions/layer3/floatingips_test.go b/acceptance/openstack/networking/v2/extensions/layer3/floatingips_test.go
index c20b0d1..952213e 100644
--- a/acceptance/openstack/networking/v2/extensions/layer3/floatingips_test.go
+++ b/acceptance/openstack/networking/v2/extensions/layer3/floatingips_test.go
@@ -7,6 +7,7 @@
"github.com/gophercloud/gophercloud/acceptance/clients"
networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/layer3/floatingips"
)
@@ -28,7 +29,7 @@
}
for _, fip := range allFIPs {
- PrintFloatingIP(t, &fip)
+ tools.PrintResource(t, fip)
}
}
@@ -77,7 +78,7 @@
t.Fatalf("Unable to get floating ip: %v", err)
}
- PrintFloatingIP(t, newFip)
+ tools.PrintResource(t, newFip)
// Disassociate the floating IP
updateOpts := floatingips.UpdateOpts{
diff --git a/acceptance/openstack/networking/v2/extensions/layer3/layer3.go b/acceptance/openstack/networking/v2/extensions/layer3/layer3.go
index 3d2d88f..7bc0676 100644
--- a/acceptance/openstack/networking/v2/extensions/layer3/layer3.go
+++ b/acceptance/openstack/networking/v2/extensions/layer3/layer3.go
@@ -177,42 +177,6 @@
t.Logf("Deleted floating IP: %s", floatingIPID)
}
-// PrintFloatingIP prints a floating IP and all of its attributes.
-func PrintFloatingIP(t *testing.T, fip *floatingips.FloatingIP) {
- t.Logf("ID: %s", fip.ID)
- t.Logf("FloatingNetworkID: %s", fip.FloatingNetworkID)
- t.Logf("FloatingIP: %s", fip.FloatingIP)
- t.Logf("PortID: %s", fip.PortID)
- t.Logf("FixedIP: %s", fip.FixedIP)
- t.Logf("TenantID: %s", fip.TenantID)
- t.Logf("Status: %s", fip.Status)
-}
-
-// PrintRouterInterface prints a router interface and all of its attributes.
-func PrintRouterInterface(t *testing.T, routerInterface *routers.InterfaceInfo) {
- t.Logf("ID: %s", routerInterface.ID)
- t.Logf("SubnetID: %s", routerInterface.SubnetID)
- t.Logf("PortID: %s", routerInterface.PortID)
- t.Logf("TenantID: %s", routerInterface.TenantID)
-}
-
-// PrintRouter prints a router and all of its attributes.
-func PrintRouter(t *testing.T, router *routers.Router) {
- t.Logf("ID: %s", router.ID)
- t.Logf("Status: %s", router.Status)
- t.Logf("GatewayInfo: %s", router.GatewayInfo)
- t.Logf("AdminStateUp: %t", router.AdminStateUp)
- t.Logf("Distributed: %t", router.Distributed)
- t.Logf("Name: %s", router.Name)
- t.Logf("TenantID: %s", router.TenantID)
- t.Logf("Routes:")
-
- for _, route := range router.Routes {
- t.Logf("\tNextHop: %s", route.NextHop)
- t.Logf("\tDestinationCIDR: %s", route.DestinationCIDR)
- }
-}
-
func WaitForRouterToCreate(client *gophercloud.ServiceClient, routerID string, secs int) error {
return gophercloud.WaitFor(secs, func() (bool, error) {
r, err := routers.Get(client, routerID).Extract()
diff --git a/acceptance/openstack/networking/v2/extensions/layer3/routers_test.go b/acceptance/openstack/networking/v2/extensions/layer3/routers_test.go
index 67688ec..e0be169 100644
--- a/acceptance/openstack/networking/v2/extensions/layer3/routers_test.go
+++ b/acceptance/openstack/networking/v2/extensions/layer3/routers_test.go
@@ -29,7 +29,7 @@
}
for _, router := range allRouters {
- PrintRouter(t, &router)
+ tools.PrintResource(t, router)
}
}
@@ -45,7 +45,7 @@
}
defer DeleteRouter(t, client, router.ID)
- PrintRouter(t, router)
+ tools.PrintResource(t, router)
newName := tools.RandomString("TESTACC-", 8)
updateOpts := routers.UpdateOpts{
@@ -62,7 +62,7 @@
t.Fatalf("Unable to get router: %v", err)
}
- PrintRouter(t, newRouter)
+ tools.PrintResource(t, newRouter)
}
func TestLayer3RouterInterface(t *testing.T) {
@@ -82,7 +82,7 @@
}
defer networking.DeleteSubnet(t, client, subnet.ID)
- networking.PrintSubnet(t, subnet)
+ tools.PrintResource(t, subnet)
router, err := CreateExternalRouter(t, client)
if err != nil {
@@ -99,8 +99,8 @@
t.Fatalf("Failed to add interface to router: %v", err)
}
- PrintRouter(t, router)
- PrintRouterInterface(t, iface)
+ tools.PrintResource(t, router)
+ tools.PrintResource(t, iface)
riOpts := routers.RemoveInterfaceOpts{
SubnetID: subnet.ID,
diff --git a/acceptance/openstack/networking/v2/extensions/lbaas/lbaas.go b/acceptance/openstack/networking/v2/extensions/lbaas/lbaas.go
index 32bfcd4..1f7b2b0 100644
--- a/acceptance/openstack/networking/v2/extensions/lbaas/lbaas.go
+++ b/acceptance/openstack/networking/v2/extensions/lbaas/lbaas.go
@@ -158,63 +158,3 @@
t.Logf("Successfully deleted vip %s", vipID)
}
-
-// PrintMember will print a member and all of its attributes.
-func PrintMember(t *testing.T, member *members.Member) {
- t.Logf("ID: %s", member.ID)
- t.Logf("TenantID: %s", member.TenantID)
- t.Logf("Status: %s", member.Status)
- t.Logf("Weight: %d", member.Weight)
- t.Logf("AdminStateUp: %t", member.AdminStateUp)
- t.Logf("PoolID: %s", member.PoolID)
- t.Logf("Address: %s", member.Address)
- t.Logf("ProtocolPort: %s", member.ProtocolPort)
-}
-
-// PrintMonitor will print a monitor and all of its attributes.
-func PrintMonitor(t *testing.T, monitor *monitors.Monitor) {
- t.Logf("ID: %s", monitor.ID)
- t.Logf("Name: %s", monitor.Name)
- t.Logf("TenantID: %s", monitor.TenantID)
- t.Logf("Status: %s", monitor.Status)
- t.Logf("Type: %s", monitor.Type)
- t.Logf("Delay: %d", monitor.Delay)
- t.Logf("Timeout: %d", monitor.Timeout)
- t.Logf("MaxRetries: %d", monitor.MaxRetries)
- t.Logf("HTTPMethod: %s", monitor.HTTPMethod)
- t.Logf("URLPath: %s", monitor.URLPath)
- t.Logf("ExpectedCodes: %s", monitor.ExpectedCodes)
- t.Logf("AdminStateUp: %t", monitor.AdminStateUp)
-}
-
-// PrintPool will print a pool and all of its attributes.
-func PrintPool(t *testing.T, pool *pools.Pool) {
- t.Logf("ID: %s", pool.ID)
- t.Logf("Name: %s", pool.Name)
- t.Logf("TenantID: %s", pool.TenantID)
- t.Logf("Status: %s", pool.Status)
- t.Logf("LBMethod: %s", pool.LBMethod)
- t.Logf("Description: %s", pool.Description)
- t.Logf("SubnetID: %s", pool.SubnetID)
- t.Logf("AdminStateUp: %t", pool.AdminStateUp)
- t.Logf("MonitorIDs: %s", pool.MonitorIDs)
- t.Logf("MemberIDs: %s", pool.MemberIDs)
-}
-
-// PrintVIP will print a vip and all of its attributes.
-func PrintVIP(t *testing.T, vip *vips.VirtualIP) {
- t.Logf("ID: %s", vip.ID)
- t.Logf("Name: %s", vip.Name)
- t.Logf("TenantID: %s", vip.TenantID)
- t.Logf("Status: %s", vip.Status)
- t.Logf("Description: %s", vip.Description)
- t.Logf("SubnetID: %s", vip.SubnetID)
- t.Logf("Address: %s", vip.Address)
- t.Logf("Protocol: %s", vip.Protocol)
- t.Logf("ProtocolPort: %d", vip.ProtocolPort)
- t.Logf("PoolID: %s", vip.PoolID)
- t.Logf("PortID: %s", vip.PortID)
- t.Logf("Persistence: %s", vip.Persistence)
- t.Logf("ConnLimit: %d", vip.ConnLimit)
- t.Logf("AdminStateUp: %t", vip.AdminStateUp)
-}
diff --git a/acceptance/openstack/networking/v2/extensions/lbaas/members_test.go b/acceptance/openstack/networking/v2/extensions/lbaas/members_test.go
index 004036e..75dec83 100644
--- a/acceptance/openstack/networking/v2/extensions/lbaas/members_test.go
+++ b/acceptance/openstack/networking/v2/extensions/lbaas/members_test.go
@@ -8,6 +8,7 @@
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/acceptance/clients"
networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/members"
)
@@ -28,7 +29,7 @@
}
for _, member := range allMembers {
- PrintMember(t, &member)
+ tools.PrintResource(t, member)
}
}
@@ -62,7 +63,7 @@
}
defer DeleteMember(t, client, member.ID)
- PrintMember(t, member)
+ tools.PrintResource(t, member)
updateOpts := members.UpdateOpts{
AdminStateUp: gophercloud.Enabled,
@@ -78,5 +79,5 @@
t.Fatalf("Unable to get member: %v")
}
- PrintMember(t, newMember)
+ tools.PrintResource(t, newMember)
}
diff --git a/acceptance/openstack/networking/v2/extensions/lbaas/monitors_test.go b/acceptance/openstack/networking/v2/extensions/lbaas/monitors_test.go
index e9a7dbb..56b413a 100644
--- a/acceptance/openstack/networking/v2/extensions/lbaas/monitors_test.go
+++ b/acceptance/openstack/networking/v2/extensions/lbaas/monitors_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/monitors"
)
@@ -26,7 +27,7 @@
}
for _, monitor := range allMonitors {
- PrintMonitor(t, &monitor)
+ tools.PrintResource(t, monitor)
}
}
@@ -42,7 +43,7 @@
}
defer DeleteMonitor(t, client, monitor.ID)
- PrintMonitor(t, monitor)
+ tools.PrintResource(t, monitor)
updateOpts := monitors.UpdateOpts{
Delay: 999,
@@ -58,5 +59,5 @@
t.Fatalf("Unable to get monitor: %v")
}
- PrintMonitor(t, newMonitor)
+ tools.PrintResource(t, newMonitor)
}
diff --git a/acceptance/openstack/networking/v2/extensions/lbaas/pools_test.go b/acceptance/openstack/networking/v2/extensions/lbaas/pools_test.go
index 8af4d19..b53237c 100644
--- a/acceptance/openstack/networking/v2/extensions/lbaas/pools_test.go
+++ b/acceptance/openstack/networking/v2/extensions/lbaas/pools_test.go
@@ -7,6 +7,7 @@
"github.com/gophercloud/gophercloud/acceptance/clients"
networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas/pools"
)
@@ -27,7 +28,7 @@
}
for _, pool := range allPools {
- PrintPool(t, &pool)
+ tools.PrintResource(t, pool)
}
}
@@ -55,7 +56,7 @@
}
defer DeletePool(t, client, pool.ID)
- PrintPool(t, pool)
+ tools.PrintResource(t, pool)
updateOpts := pools.UpdateOpts{
LBMethod: pools.LBMethodLeastConnections,
@@ -71,7 +72,7 @@
t.Fatalf("Unable to get pool: %v")
}
- PrintPool(t, newPool)
+ tools.PrintResource(t, newPool)
}
func TestPoolsMonitors(t *testing.T) {
diff --git a/acceptance/openstack/networking/v2/extensions/lbaas/vips_test.go b/acceptance/openstack/networking/v2/extensions/lbaas/vips_test.go
index 1f61b36..ba3f9b4 100644
--- a/acceptance/openstack/networking/v2/extensions/lbaas/vips_test.go
+++ b/acceptance/openstack/networking/v2/extensions/lbaas/vips_test.go
@@ -27,7 +27,7 @@
}
for _, vip := range allVIPs {
- PrintVIP(t, &vip)
+ tools.PrintResource(t, vip)
}
}
@@ -61,7 +61,7 @@
}
defer DeleteVIP(t, client, vip.ID)
- PrintVIP(t, vip)
+ tools.PrintResource(t, vip)
connLimit := 100
updateOpts := vips.UpdateOpts{
@@ -78,5 +78,5 @@
t.Fatalf("Unable to get vip: %v")
}
- PrintVIP(t, newVIP)
+ tools.PrintResource(t, newVIP)
}
diff --git a/acceptance/openstack/networking/v2/extensions/lbaas_v2/lbaas_v2.go b/acceptance/openstack/networking/v2/extensions/lbaas_v2/lbaas_v2.go
index d2e7195..093f835 100644
--- a/acceptance/openstack/networking/v2/extensions/lbaas_v2/lbaas_v2.go
+++ b/acceptance/openstack/networking/v2/extensions/lbaas_v2/lbaas_v2.go
@@ -258,116 +258,6 @@
t.Logf("Successfully deleted pool %s", poolID)
}
-// PrintListener will print a listener and all of its attributes.
-func PrintListener(t *testing.T, listener *listeners.Listener) {
- t.Logf("ID: %s", listener.ID)
- t.Logf("TenantID: %s", listener.TenantID)
- t.Logf("Name: %s", listener.Name)
- t.Logf("Description: %s", listener.Description)
- t.Logf("Protocol: %s", listener.Protocol)
- t.Logf("DefaultPoolID: %s", listener.DefaultPoolID)
- t.Logf("ConnLimit: %d", listener.ConnLimit)
- t.Logf("SniContainerRefs: %s", listener.SniContainerRefs)
- t.Logf("DefaultTlsContainerRef: %s", listener.DefaultTlsContainerRef)
- t.Logf("AdminStateUp: %t", listener.AdminStateUp)
-
- t.Logf("Pools:")
- for _, pool := range listener.Pools {
- t.Logf("\t%#v", pool)
- }
-
- t.Logf("LoadBalancers")
- for _, lb := range listener.Loadbalancers {
- t.Logf("\t%#v", lb)
- }
-}
-
-// PrintLoadBalancer will print a load balancer and all of its attributes.
-func PrintLoadBalancer(t *testing.T, lb *loadbalancers.LoadBalancer) {
- t.Logf("ID: %s", lb.ID)
- t.Logf("Name: %s", lb.Name)
- t.Logf("TenantID: %s", lb.TenantID)
- t.Logf("Description: %s", lb.Description)
- t.Logf("ProvisioningStatus: %s", lb.ProvisioningStatus)
- t.Logf("VipAddress: %s", lb.VipAddress)
- t.Logf("VipPortID: %s", lb.VipPortID)
- t.Logf("VipSubnetID: %s", lb.VipSubnetID)
- t.Logf("OperatingStatus: %s", lb.OperatingStatus)
- t.Logf("Flavor: %s", lb.Flavor)
- t.Logf("Provider: %s", lb.Provider)
- t.Logf("AdminStateUp: %t", lb.AdminStateUp)
-
- t.Logf("Listeners")
- for _, listener := range lb.Listeners {
- t.Logf("\t%#v", listener)
- }
-}
-
-// PrintMember will print a member and all of its attributes.
-func PrintMember(t *testing.T, member *pools.Member) {
- t.Logf("ID: %s", member.ID)
- t.Logf("Name: %s", member.Name)
- t.Logf("TenantID: %s", member.TenantID)
- t.Logf("Weight: %d", member.Weight)
- t.Logf("SubnetID: %s", member.SubnetID)
- t.Logf("PoolID: %s", member.PoolID)
- t.Logf("Address: %s", member.Address)
- t.Logf("ProtocolPort: %d", member.ProtocolPort)
- t.Logf("AdminStateUp: %t", member.AdminStateUp)
-}
-
-// PrintMonitor will print a monitor and all of its attributes.
-func PrintMonitor(t *testing.T, monitor *monitors.Monitor) {
- t.Logf("ID: %s", monitor.ID)
- t.Logf("Name: %s", monitor.Name)
- t.Logf("TenantID: %s", monitor.TenantID)
- t.Logf("Type: %s", monitor.Type)
- t.Logf("Delay: %d", monitor.Delay)
- t.Logf("Timeout: %d", monitor.Timeout)
- t.Logf("MaxRetries: %d", monitor.MaxRetries)
- t.Logf("HTTPMethod: %s", monitor.HTTPMethod)
- t.Logf("URLPath: %s", monitor.URLPath)
- t.Logf("ExpectedCodes: %s", monitor.ExpectedCodes)
- t.Logf("AdminStateUp: %t", monitor.AdminStateUp)
- t.Logf("Status: %s", monitor.Status)
-
- t.Logf("Pools")
- for _, pool := range monitor.Pools {
- t.Logf("\t%#v", pool)
- }
-}
-
-// PrintPool will print a pool and all of its attributes.
-func PrintPool(t *testing.T, pool *pools.Pool) {
- t.Logf("ID: %s", pool.ID)
- t.Logf("Name: %s", pool.Name)
- t.Logf("TenantID: %s", pool.TenantID)
- t.Logf("Description: %s", pool.Description)
- t.Logf("LBMethod: %s", pool.LBMethod)
- t.Logf("Protocol: %s", pool.Protocol)
- t.Logf("MonitorID: %s", pool.MonitorID)
- t.Logf("SubnetID: %s", pool.SubnetID)
- t.Logf("AdminStateUp: %t", pool.AdminStateUp)
- t.Logf("Persistence: %s", pool.Persistence)
- t.Logf("Provider: %s", pool.Provider)
- t.Logf("Monitor: %#v", pool.Monitor)
-
- t.Logf("Listeners")
- for _, listener := range pool.Listeners {
- t.Logf("\t%#v", listener)
- }
-
- t.Logf("Members")
- for _, member := range pool.Members {
- t.Logf("\t%#v", member)
- }
-
- t.Logf("Loadbalancers")
- for _, lb := range pool.Loadbalancers {
- t.Logf("\t%#v", lb)
- }
-}
-
// WaitForLoadBalancerState will wait until a loadbalancer reaches a given state.
func WaitForLoadBalancerState(client *gophercloud.ServiceClient, lbID, status string, secs int) error {
return gophercloud.WaitFor(secs, func() (bool, error) {
diff --git a/acceptance/openstack/networking/v2/extensions/lbaas_v2/listeners_test.go b/acceptance/openstack/networking/v2/extensions/lbaas_v2/listeners_test.go
index ac2681e..2d2dd03 100644
--- a/acceptance/openstack/networking/v2/extensions/lbaas_v2/listeners_test.go
+++ b/acceptance/openstack/networking/v2/extensions/lbaas_v2/listeners_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/listeners"
)
@@ -26,6 +27,6 @@
}
for _, listener := range allListeners {
- PrintListener(t, &listener)
+ tools.PrintResource(t, listener)
}
}
diff --git a/acceptance/openstack/networking/v2/extensions/lbaas_v2/loadbalancers_test.go b/acceptance/openstack/networking/v2/extensions/lbaas_v2/loadbalancers_test.go
index 7cd49ed..650eb2c 100644
--- a/acceptance/openstack/networking/v2/extensions/lbaas_v2/loadbalancers_test.go
+++ b/acceptance/openstack/networking/v2/extensions/lbaas_v2/loadbalancers_test.go
@@ -31,7 +31,7 @@
}
for _, lb := range allLoadbalancers {
- PrintLoadBalancer(t, &lb)
+ tools.PrintResource(t, lb)
}
}
@@ -64,7 +64,7 @@
t.Fatalf("Unable to get loadbalancer: %v", err)
}
- PrintLoadBalancer(t, newLB)
+ tools.PrintResource(t, newLB)
// Because of the time it takes to create a loadbalancer,
// this test will include some other resources.
@@ -93,7 +93,7 @@
t.Fatalf("Unable to get listener")
}
- PrintListener(t, newListener)
+ tools.PrintResource(t, newListener)
// Pool
pool, err := CreatePool(t, client, lb)
@@ -119,7 +119,7 @@
t.Fatalf("Unable to get pool")
}
- PrintPool(t, newPool)
+ tools.PrintResource(t, newPool)
// Member
member, err := CreateMember(t, client, lb, newPool, subnet.ID, subnet.CIDR)
@@ -146,7 +146,7 @@
t.Fatalf("Unable to get member")
}
- PrintMember(t, newMember)
+ tools.PrintResource(t, newMember)
// Monitor
monitor, err := CreateMonitor(t, client, lb, newPool)
@@ -173,6 +173,6 @@
t.Fatalf("Unable to get monitor")
}
- PrintMonitor(t, newMonitor)
+ tools.PrintResource(t, newMonitor)
}
diff --git a/acceptance/openstack/networking/v2/extensions/lbaas_v2/monitors_test.go b/acceptance/openstack/networking/v2/extensions/lbaas_v2/monitors_test.go
index 2e587d9..b312370 100644
--- a/acceptance/openstack/networking/v2/extensions/lbaas_v2/monitors_test.go
+++ b/acceptance/openstack/networking/v2/extensions/lbaas_v2/monitors_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/monitors"
)
@@ -26,6 +27,6 @@
}
for _, monitor := range allMonitors {
- PrintMonitor(t, &monitor)
+ tools.PrintResource(t, monitor)
}
}
diff --git a/acceptance/openstack/networking/v2/extensions/lbaas_v2/pools_test.go b/acceptance/openstack/networking/v2/extensions/lbaas_v2/pools_test.go
index 42ba5a2..b4f55a0 100644
--- a/acceptance/openstack/networking/v2/extensions/lbaas_v2/pools_test.go
+++ b/acceptance/openstack/networking/v2/extensions/lbaas_v2/pools_test.go
@@ -6,6 +6,7 @@
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/lbaas_v2/pools"
)
@@ -26,6 +27,6 @@
}
for _, pool := range allPools {
- PrintPool(t, &pool)
+ tools.PrintResource(t, pool)
}
}
diff --git a/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding.go b/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding.go
index b52cd80..a6d75f3 100644
--- a/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding.go
+++ b/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding.go
@@ -36,22 +36,3 @@
return port, nil
}
-
-// PrintPortsbinging will print a port and all of its attributes.
-func PrintPortsbinding(t *testing.T, port *portsbinding.Port) {
- t.Logf("ID: %s", port.ID)
- t.Logf("NetworkID: %s", port.NetworkID)
- t.Logf("Name: %s", port.Name)
- t.Logf("AdminStateUp: %t", port.AdminStateUp)
- t.Logf("Status: %s", port.Status)
- t.Logf("MACAddress: %s", port.MACAddress)
- t.Logf("FixedIPs: %s", port.FixedIPs)
- t.Logf("TenantID: %s", port.TenantID)
- t.Logf("DeviceOwner: %s", port.DeviceOwner)
- t.Logf("SecurityGroups: %s", port.SecurityGroups)
- t.Logf("DeviceID: %s", port.DeviceID)
- t.Logf("DeviceOwner: %s", port.DeviceOwner)
- t.Logf("AllowedAddressPairs: %s", port.AllowedAddressPairs)
- t.Logf("HostID: %s", port.HostID)
- t.Logf("VNICType: %s", port.VNICType)
-}
diff --git a/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding_test.go b/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding_test.go
index 2f2f618..803f62a 100644
--- a/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding_test.go
+++ b/acceptance/openstack/networking/v2/extensions/portsbinding/portsbinding_test.go
@@ -42,7 +42,7 @@
}
defer networking.DeletePort(t, client, port.ID)
- PrintPortsbinding(t, port)
+ tools.PrintResource(t, port)
// Update port
newPortName := tools.RandomString("TESTACC-", 8)
@@ -54,5 +54,5 @@
t.Fatalf("Could not update port: %v", err)
}
- PrintPortsbinding(t, newPort)
+ tools.PrintResource(t, newPort)
}
diff --git a/acceptance/openstack/networking/v2/extensions/provider_test.go b/acceptance/openstack/networking/v2/extensions/provider_test.go
index 8136581..b0d5846 100644
--- a/acceptance/openstack/networking/v2/extensions/provider_test.go
+++ b/acceptance/openstack/networking/v2/extensions/provider_test.go
@@ -7,6 +7,7 @@
"github.com/gophercloud/gophercloud/acceptance/clients"
networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/provider"
"github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
)
@@ -30,5 +31,5 @@
t.Fatalf("Unable to extract network: %v", err)
}
- PrintNetworkExtAttrs(t, newNetwork)
+ tools.PrintResource(t, newNetwork)
}
diff --git a/acceptance/openstack/networking/v2/extensions/security_test.go b/acceptance/openstack/networking/v2/extensions/security_test.go
index 88003e7..c696377 100644
--- a/acceptance/openstack/networking/v2/extensions/security_test.go
+++ b/acceptance/openstack/networking/v2/extensions/security_test.go
@@ -7,6 +7,7 @@
"github.com/gophercloud/gophercloud/acceptance/clients"
networking "github.com/gophercloud/gophercloud/acceptance/openstack/networking/v2"
+ "github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/networking/v2/extensions/security/groups"
)
@@ -28,7 +29,7 @@
}
for _, group := range allGroups {
- PrintSecurityGroup(t, &group)
+ tools.PrintResource(t, group)
}
}
@@ -50,7 +51,7 @@
}
defer DeleteSecurityGroupRule(t, client, rule.ID)
- PrintSecurityGroup(t, group)
+ tools.PrintResource(t, group)
}
func TestSecurityGroupsPort(t *testing.T) {
@@ -89,5 +90,5 @@
}
defer networking.DeletePort(t, client, port.ID)
- networking.PrintPort(t, port)
+ tools.PrintResource(t, port)
}
diff --git a/acceptance/openstack/networking/v2/networking.go b/acceptance/openstack/networking/v2/networking.go
index cc5befb..c5e7ca2 100644
--- a/acceptance/openstack/networking/v2/networking.go
+++ b/acceptance/openstack/networking/v2/networking.go
@@ -6,7 +6,6 @@
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/acceptance/tools"
- "github.com/gophercloud/gophercloud/openstack/networking/v2/apiversions"
"github.com/gophercloud/gophercloud/openstack/networking/v2/networks"
"github.com/gophercloud/gophercloud/openstack/networking/v2/ports"
"github.com/gophercloud/gophercloud/openstack/networking/v2/subnets"
@@ -196,61 +195,6 @@
t.Logf("Deleted subnet: %s", subnetID)
}
-// PrintAPIVersion will print an API version and all of its attributes.
-func PrintAPIVersion(t *testing.T, apiVersion *apiversions.APIVersion) {
- t.Logf("ID: %s", apiVersion.ID)
- t.Logf("Status: %s", apiVersion.Status)
-}
-
-// PrintNetwork will print a network and all of its attributes.
-func PrintNetwork(t *testing.T, network *networks.Network) {
- t.Logf("ID: %s", network.ID)
- t.Logf("Name: %s", network.Name)
- t.Logf("AdminStateUp: %t", network.AdminStateUp)
- t.Logf("Status: %s", network.Status)
- t.Logf("TenantID: %s", network.TenantID)
- t.Logf("Shared: %t", network.Shared)
- t.Logf("Subnets: %s", network.Subnets)
-}
-
-// PrintPort will print a port and all of its attributes.
-func PrintPort(t *testing.T, port *ports.Port) {
- t.Logf("ID: %s", port.ID)
- t.Logf("NetworkID: %s", port.NetworkID)
- t.Logf("Name: %s", port.Name)
- t.Logf("AdminStateUp: %t", port.AdminStateUp)
- t.Logf("Status: %s", port.Status)
- t.Logf("MACAddress: %s", port.MACAddress)
- t.Logf("FixedIPs: %s", port.FixedIPs)
- t.Logf("TenantID: %s", port.TenantID)
- t.Logf("DeviceOwner: %s", port.DeviceOwner)
- t.Logf("SecurityGroups: %s", port.SecurityGroups)
- t.Logf("DeviceID: %s", port.DeviceID)
- t.Logf("DeviceOwner: %s", port.DeviceOwner)
- t.Logf("AllowedAddressPairs: %s", port.AllowedAddressPairs)
-}
-
-// PrintSubnet will print a subnet and all of its attributes.
-func PrintSubnet(t *testing.T, subnet *subnets.Subnet) {
- t.Logf("ID: %s", subnet.ID)
- t.Logf("NetworkID: %s", subnet.NetworkID)
- t.Logf("Name: %s", subnet.Name)
- t.Logf("IPVersion: %d", subnet.IPVersion)
- t.Logf("CIDR: %s", subnet.CIDR)
- t.Logf("GatewayIP: %s", subnet.GatewayIP)
- t.Logf("DNSNameservers: %s", subnet.DNSNameservers)
- t.Logf("AllocationPools: %s", subnet.AllocationPools)
- t.Logf("HostRoutes: %s", subnet.HostRoutes)
- t.Logf("EnableDHCP: %t", subnet.EnableDHCP)
- t.Logf("TenantID: %s", subnet.TenantID)
-}
-
-// PrintVersionResource will print an API version resource and all of its attributes.
-func PrintVersionResource(t *testing.T, versionResource *apiversions.APIVersionResource) {
- t.Logf("Name: %s", versionResource.Name)
- t.Logf("Collection: %s", versionResource.Collection)
-}
-
func WaitForPortToCreate(client *gophercloud.ServiceClient, portID string, secs int) error {
return gophercloud.WaitFor(secs, func() (bool, error) {
p, err := ports.Get(client, portID).Extract()
diff --git a/acceptance/openstack/networking/v2/networks_test.go b/acceptance/openstack/networking/v2/networks_test.go
index a095079..66f42f8 100644
--- a/acceptance/openstack/networking/v2/networks_test.go
+++ b/acceptance/openstack/networking/v2/networks_test.go
@@ -27,7 +27,7 @@
}
for _, network := range allNetworks {
- PrintNetwork(t, &network)
+ tools.PrintResource(t, network)
}
}
@@ -44,7 +44,7 @@
}
defer DeleteNetwork(t, client, network.ID)
- PrintNetwork(t, network)
+ tools.PrintResource(t, network)
newName := tools.RandomString("TESTACC-", 8)
updateOpts := &networks.UpdateOpts{
@@ -61,5 +61,5 @@
t.Fatalf("Unable to retrieve network: %v", err)
}
- PrintNetwork(t, newNetwork)
+ tools.PrintResource(t, newNetwork)
}
diff --git a/acceptance/openstack/networking/v2/ports_test.go b/acceptance/openstack/networking/v2/ports_test.go
index b3b9ecb..fa1b4a4 100644
--- a/acceptance/openstack/networking/v2/ports_test.go
+++ b/acceptance/openstack/networking/v2/ports_test.go
@@ -27,7 +27,7 @@
}
for _, port := range allPorts {
- PrintPort(t, &port)
+ tools.PrintResource(t, port)
}
}
@@ -58,7 +58,7 @@
}
defer DeletePort(t, client, port.ID)
- PrintPort(t, port)
+ tools.PrintResource(t, port)
// Update port
newPortName := tools.RandomString("TESTACC-", 8)
@@ -70,5 +70,5 @@
t.Fatalf("Could not update port: %v", err)
}
- PrintPort(t, newPort)
+ tools.PrintResource(t, newPort)
}
diff --git a/acceptance/openstack/networking/v2/subnets_test.go b/acceptance/openstack/networking/v2/subnets_test.go
index 1d7696c..fd50a1f 100644
--- a/acceptance/openstack/networking/v2/subnets_test.go
+++ b/acceptance/openstack/networking/v2/subnets_test.go
@@ -29,7 +29,7 @@
}
for _, subnet := range allSubnets {
- PrintSubnet(t, &subnet)
+ tools.PrintResource(t, subnet)
}
}
@@ -53,7 +53,7 @@
}
defer DeleteSubnet(t, client, subnet.ID)
- PrintSubnet(t, subnet)
+ tools.PrintResource(t, subnet)
// Update Subnet
newSubnetName := tools.RandomString("TESTACC-", 8)
@@ -71,7 +71,7 @@
t.Fatalf("Unable to get subnet: %v", err)
}
- PrintSubnet(t, newSubnet)
+ tools.PrintResource(t, newSubnet)
}
func TestSubnetsDefaultGateway(t *testing.T) {
@@ -94,7 +94,7 @@
}
defer DeleteSubnet(t, client, subnet.ID)
- PrintSubnet(t, subnet)
+ tools.PrintResource(t, subnet)
if subnet.GatewayIP == "" {
t.Fatalf("A default gateway was not created.")
@@ -135,7 +135,7 @@
}
defer DeleteSubnet(t, client, subnet.ID)
- PrintSubnet(t, subnet)
+ tools.PrintResource(t, subnet)
if subnet.GatewayIP != "" {
t.Fatalf("A gateway exists when it shouldn't.")