Skip to content

Commit

Permalink
Merge pull request #14742 from Ladas/ensure_google_managers_change_zo…
Browse files Browse the repository at this point in the history
…ne_and_provider_region_with_cloud_manager

Ensure google managers change zone and provider region with cloud manager
(cherry picked from commit 6d06dde)
  • Loading branch information
agrare authored and simaishi committed Apr 13, 2017
1 parent 1bc6927 commit c02e4ae
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/manageiq/providers/google/cloud_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class ManageIQ::Providers::Google::CloudManager < ManageIQ::Providers::CloudMana
supports :regions

before_create :ensure_managers
before_update :ensure_managers_zone_and_provider_region

def ensure_network_manager
build_network_manager(:type => 'ManageIQ::Providers::Google::NetworkManager') unless network_manager
Expand Down
30 changes: 30 additions & 0 deletions spec/models/manageiq/providers/google/cloud_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@
expect(described_class.description).to eq('Google Compute Engine')
end

it "does not create orphaned network_manager" do
ems = FactoryGirl.create(:ems_google)
same_ems = ExtManagementSystem.find(ems.id)

ems.destroy
expect(ExtManagementSystem.count).to eq(0)

same_ems.save!
expect(ExtManagementSystem.count).to eq(0)
end

it "moves the network_manager to the same zone and provider region as the cloud_manager" do
zone1 = FactoryGirl.create(:zone)
zone2 = FactoryGirl.create(:zone)

ems = FactoryGirl.create(:ems_google, :zone => zone1, :provider_region => "us-east1")
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
before do
@google_project = "yourprojectid"
Expand Down

0 comments on commit c02e4ae

Please sign in to comment.