diff --git a/lib/fog/compute/google/models/address.rb b/lib/fog/compute/google/models/address.rb index d03d60cd27..901d0049f0 100755 --- a/lib/fog/compute/google/models/address.rb +++ b/lib/fog/compute/google/models/address.rb @@ -74,7 +74,15 @@ def ready? private - def associate(nic_name, async = true) + # Associates the ip address to a given server + # + # @param [String] server - GCE instance name + # @param [String] nic_name - NIC interface name, defaults to GCE + # standard primary nic - "nic0" + # @param [Boolean] async - whether to run the operation asynchronously + # + # @return [Fog::Compute::Google::Operation] + def associate(server, nic_name = "nic0", async = false) requires :address data = service.add_server_access_config( @@ -86,7 +94,12 @@ def associate(nic_name, async = true) operation.wait_for { ready? } unless async end - def disassociate + # Disassociates the ip address from a resource it's attached to + # + # @param [Boolean] async - whether to run the operation asynchronously + # + # @return [Fog::Compute::Google::Operation] + def disassociate(async = false) requires :address return nil if !in_use? || users.nil? || users.empty? diff --git a/test/integration/compute/core_networking/test_addresses.rb b/test/integration/compute/core_networking/test_addresses.rb index 7e1b33c760..019e2d95fa 100644 --- a/test/integration/compute/core_networking/test_addresses.rb +++ b/test/integration/compute/core_networking/test_addresses.rb @@ -32,6 +32,29 @@ def test_run_instance @subject.get(address.name, TEST_REGION).status, "Address should now be in use" ) + + address.reload + + assert_equal( + server, + address.server, + "Address.server should return an associated server object" + ) + + address.server = nil + address.reload + assert_nil( + address.server, + "Address should not be associated with a server after disassociation" + ) + + address.server = server + address.reload + assert_equal( + server, + address.server, + "Address should be associated with a server after association" + ) end def test_bad_get diff --git a/test/integration/monitoring/test_metric_descriptors.rb b/test/integration/monitoring/test_metric_descriptors.rb index e49eb07e14..7c2ab3a559 100644 --- a/test/integration/monitoring/test_metric_descriptors.rb +++ b/test/integration/monitoring/test_metric_descriptors.rb @@ -104,6 +104,10 @@ def test_metric_descriptors_all descriptors = @client.metric_descriptors.all assert_operator(descriptors.size, :>, 0, "metric descriptor count should be positive") + end + + def test_metric_descriptors_all_page_size + skip("Skipping until API-side issue is resolved, see #451") descriptors = @client.metric_descriptors.all( :filter => 'metric.type = starts_with("compute.googleapis.com")',