Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add my_zone to Service Orchestration. #15533

Merged
merged 1 commit into from
Jul 11, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/models/service_orchestration.rb
Original file line number Diff line number Diff line change
@@ -83,6 +83,10 @@ def post_provision_configure
assign_vms_owner
end

def my_zone
orchestration_manager.try(:my_zone) || super
end

private

def add_stack_to_resource
24 changes: 21 additions & 3 deletions spec/models/service_orchestration_spec.rb
Original file line number Diff line number Diff line change
@@ -56,13 +56,31 @@
end

describe "#my_zone" do
it "takes the zone from ext_management_system" do
it "deployed stack, takes the zone from ext_management_system" do
deployed_stack.ext_management_system = manager_by_setter
expect(deployed_stack.my_zone).to eq(manager_by_setter.my_zone)
end

it "returns nil if ext_management_system is not valid" do
expect(deployed_stack.my_zone).to eq(nil)
it "deployed stack, returns nil zone if ext_management_system is not valid" do
expect(deployed_stack.my_zone).to be_nil
end

it "service, takes the zone from orchestration_manager" do
ems = FactoryGirl.create(:ems_amazon, :zone => FactoryGirl.create(:zone))
deployed_stack.direct_vms << FactoryGirl.create(:vm_amazon, :ext_management_system => ems)
expect(service_with_deployed_stack.my_zone).to eq(service.orchestration_manager.my_zone)
end

it "service, takes the zone from VM ext_management_system if no orchestration_manager" do
ems = FactoryGirl.create(:ems_amazon, :zone => FactoryGirl.create(:zone))
deployed_stack.direct_vms << FactoryGirl.create(:vm_amazon, :ext_management_system => ems)
service.orchestration_manager = nil
expect(service_with_deployed_stack.my_zone).to eq(service_with_deployed_stack.vms.first.ext_management_system.my_zone)
end

it "service, returns nil zone if no orchestration_manager and no VMs" do
service.orchestration_manager = nil
expect(service_with_deployed_stack.my_zone).to be_nil
end
end