diff --git a/app/models/manageiq/providers/google/cloud_manager.rb b/app/models/manageiq/providers/google/cloud_manager.rb index b0f8a238..6a14f60c 100644 --- a/app/models/manageiq/providers/google/cloud_manager.rb +++ b/app/models/manageiq/providers/google/cloud_manager.rb @@ -16,15 +16,24 @@ class ManageIQ::Providers::Google::CloudManager < ManageIQ::Providers::CloudMana include ManageIQ::Providers::Google::ManagerMixin supports :provisioning - supports :regions before_create :ensure_managers - before_update :ensure_managers_zone_and_provider_region + before_update :ensure_managers_zone def ensure_network_manager build_network_manager(:type => 'ManageIQ::Providers::Google::NetworkManager') unless network_manager end + def ensure_managers + ensure_network_manager + network_manager.name = "#{name} Network Manager" if network_manager + ensure_managers_zone + end + + def ensure_managers_zone + network_manager.zone_id = zone_id if network_manager + end + def self.ems_type @ems_type ||= "gce".freeze end @@ -58,12 +67,6 @@ def supports_authentication?(authtype) supported_auth_types.include?(authtype.to_s) end - validates :provider_region, :inclusion => {:in => ManageIQ::Providers::Google::Regions.names} - - def description - ManageIQ::Providers::Google::Regions.find_by_name(provider_region)[:description] - end - # Operations def vm_start(vm, _options = {}) diff --git a/app/models/manageiq/providers/google/network_manager.rb b/app/models/manageiq/providers/google/network_manager.rb index f3b39284..957dad92 100644 --- a/app/models/manageiq/providers/google/network_manager.rb +++ b/app/models/manageiq/providers/google/network_manager.rb @@ -47,10 +47,6 @@ def self.hostname_required? false end - def description - ManageIQ::Providers::Google::Regions.find_by_name(provider_region)[:description] - end - def self.display_name(number = 1) n_('Network Provider (Google)', 'Network Providers (Google)', number) end diff --git a/app/models/manageiq/providers/google/regions.rb b/app/models/manageiq/providers/google/regions.rb deleted file mode 100644 index abed8097..00000000 --- a/app/models/manageiq/providers/google/regions.rb +++ /dev/null @@ -1,60 +0,0 @@ -module ManageIQ - module Providers::Google - module Regions - # From https://cloud.google.com/compute/docs/zones - REGIONS = { - "us-east1" => { - :name => "us-east1", - :hostname => "us-east1", - :description => "Eastern US", - }, - "us-central1" => { - :name => "us-central1", - :hostname => "us-central1", - :description => "Central US", - }, - "europe-west1" => { - :name => "europe-west1", - :hostname => "europe-west1", - :description => "Western Europe", - }, - "asia-east1" => { - :name => "asia-east1", - :hostname => "asia-east1", - :description => "East Asia", - }, - "southamerica-east1" => { - :name => "southamerica-east1", - :hostname => "southamerica-east1", - :description => "South America", - }, - } - - # TODO(lwander): hack to make GCE more compatible with other providers - REGIONS_BY_HOSTNAME = - REGIONS.values.each_with_object({}) do |v, h| - h[v[:hostname]] = v - end - - def self.all - REGIONS.values - end - - def self.names - REGIONS.keys - end - - def self.hostnames - REGIONS_BY_HOSTNAME.keys - end - - def self.find_by_name(name) - REGIONS[name] - end - - def self.find_by_hostname(hostname) - REGIONS_BY_HOSTNAME[hostname] - end - end - end -end diff --git a/spec/models/manageiq/providers/google/cloud_manager/refresher_spec.rb b/spec/models/manageiq/providers/google/cloud_manager/refresher_spec.rb index 65065b9e..69023cde 100644 --- a/spec/models/manageiq/providers/google/cloud_manager/refresher_spec.rb +++ b/spec/models/manageiq/providers/google/cloud_manager/refresher_spec.rb @@ -2,7 +2,7 @@ before(:each) do _guid, _server, zone = EvmSpecHelper.create_guid_miq_server_zone @google_json_key = "{\n \"type\": \"service_account\",\n \"project_id\": \"civil-tube-113314\",\n \"private_key_id\": \"bd99fda9d4a1e62f8371b7cd92ffcc6bb21ee453\",\n \"private_key\": \"-----BEGIN PRIVATE KEY-----\\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCR2KaVdHB3sMkm\\n8v8KZCPuKMvbUZ4oswT2ORRgm8hwJkMgvGpGAVnCRTwujXwm7ar7Acbopxzg4Qcm\\nb+DL6liyojrV3flbNiFcQniyMdjJxERyGKCEeLa+fGW9dNG2/v+2WAiQamywKgMA\\nlgR9bgaKZBPoDYIGpcwMqbXfCz/edUrWgf/sPw/EVePn56ARwEGE8azPyflP+tsM\\n2SskpW0SNJnHgwj3dKlH8iRXFTqGBaodM/864yb5IPTFkmR/3TPs9z+vbiyD/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ju\\nltzVxpnWzdK9wGQpMONUv9z379utM5HEZSC3QVKlGWwop0bBvshCqPG43RL9pdr1\\nVpjHBc57W3oYLsWQ0NP/GhTIMRoCPdw+4B7VWWOhAoGAYEdx3cnDpPOTH1179GTv\\ny/q1LXvp8nP50HZ1Yc+wAOnifXBKhSTpjDqgru5OiGT7rggzyK0ui3nyfbwM5AH7\\nyQXmt8q0Nnzo8GdL+YKTfGbnmSwDH0SotEeofwruPuxOr7ows6joo283NOugudsx\\nUAa/tB/piHG/VYQ6dxb8zsg=\\n-----END PRIVATE KEY-----\\n\",\n \"client_email\": \"199203428544-compute@developer.gserviceaccount.com\",\n \"client_id\": \"102455136987689387132\",\n \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\n \"token_uri\": \"https://accounts.google.com/o/oauth2/token\",\n \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\n \"client_x509_cert_url\": \"https://www.googleapis.com/robot/v1/metadata/x509/199203428544-compute%40developer.gserviceaccount.com\"\n}\n" - @ems = FactoryGirl.create(:ems_google, :zone => zone, :provider_region => "us-central1") + @ems = FactoryGirl.create(:ems_google, :zone => zone) @ems.authentications << FactoryGirl.create(:authentication, :userid => "_", :auth_key => @google_json_key) @ems.update_attributes(:project => "civil-tube-113314") diff --git a/spec/models/manageiq/providers/google/cloud_manager_spec.rb b/spec/models/manageiq/providers/google/cloud_manager_spec.rb index edb04c78..3c6fc9e8 100644 --- a/spec/models/manageiq/providers/google/cloud_manager_spec.rb +++ b/spec/models/manageiq/providers/google/cloud_manager_spec.rb @@ -49,23 +49,20 @@ expect(ExtManagementSystem.count).to eq(0) end - it "moves the network_manager to the same zone and provider region as the cloud_manager" do + it "moves the network_manager to the same zone as the cloud_manager" do zone1 = FactoryGirl.create(:zone) zone2 = FactoryGirl.create(:zone) - ems = FactoryGirl.create(:ems_google, :zone => zone1, :provider_region => "us-east1") + ems = FactoryGirl.create(:ems_google, :zone => zone1) expect(ems.network_manager.zone).to eq zone1 expect(ems.network_manager.zone_id).to eq zone1.id - expect(ems.network_manager.provider_region).to eq "us-east1" ems.zone = zone2 - ems.provider_region = "us-central1" ems.save! ems.reload expect(ems.network_manager.zone).to eq zone2 expect(ems.network_manager.zone_id).to eq zone2.id - expect(ems.network_manager.provider_region).to eq "us-central1" end context "#connectivity" do