forked from ManageIQ/manageiq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ManageIQ#15901 from bmclaughlin/enable-cockpit-for…
…-cloud-providers Fix web console for AWS, GCE and enable for RHOS
- Loading branch information
Showing
4 changed files
with
69 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module CockpitMixin | ||
extend ActiveSupport::Concern | ||
def cockpit_server | ||
ext_management_system.try(:zone).try(:remote_cockpit_ws_miq_server) | ||
end | ||
|
||
def cockpit_worker | ||
cockpit_server.nil? ? nil : MiqCockpitWsWorker.fetch_worker_settings_from_server(cockpit_server) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,62 @@ | ||
describe 'VM::Operations' do | ||
before(:each) do | ||
miq_server = EvmSpecHelper.local_miq_server | ||
@ems = FactoryGirl.create(:ems_vmware, :zone => miq_server.zone) | ||
@vm = FactoryGirl.create(:vm_vmware, :ems_id => @ems.id) | ||
allow(@vm).to receive(:ipaddresses).and_return(@ipaddresses) | ||
@miq_server = EvmSpecHelper.local_miq_server | ||
@ems = FactoryGirl.create(:ems_vmware, :zone => @miq_server.zone) | ||
@vm = FactoryGirl.create(:vm_vmware, :ems_id => @ems.id) | ||
ipaddresses = %w(fe80::21a:4aff:fe22:dde5 127.0.0.1) | ||
allow(@vm).to receive(:ipaddresses).and_return(ipaddresses) | ||
|
||
@hardware = FactoryGirl.create(:hardware) | ||
@hardware.ipaddresses << '10.142.0.2' | ||
@hardware.ipaddresses << '35.190.140.48' | ||
end | ||
|
||
context '#cockpit_url' do | ||
it '#returns a valid Cockpit url' do | ||
@ipaddresses = %w(fe80::21a:4aff:fe22:dde5 127.0.0.1) | ||
expect(@vm).to receive(:cockpit_url).and_return('http://127.0.0.1:9090') | ||
@vm.send(:cockpit_url) | ||
url = @vm.send(:cockpit_url) | ||
expect(url).to eq(URI::HTTP.build(:host => "127.0.0.1", :port => 9090)) | ||
end | ||
end | ||
|
||
context '#ipv4_address' do | ||
after(:each) { @vm.send(:return_ipv4_address) } | ||
|
||
it 'returns the existing ipv4 address' do | ||
@ipaddresses = %w(fe80::21a:4aff:fe22:dde5 127.0.0.1) | ||
expect(@vm).to receive(:return_ipv4_address).and_return('127.0.0.1') | ||
url = @vm.send(:ipv4_address) | ||
expect(url).to eq('127.0.0.1') | ||
end | ||
|
||
context 'cloud providers' do | ||
before(:each) { @ipaddresses = %w(10.10.1.121 35.190.140.48) } | ||
it 'returns the public ipv4 address for AWS' do | ||
ems = FactoryGirl.create(:ems_google, :project => 'manageiq-dev') | ||
az = FactoryGirl.create(:availability_zone_google) | ||
vm = FactoryGirl.create(:vm_google, | ||
:ext_management_system => ems, | ||
:ems_ref => 123, | ||
:availability_zone => az, | ||
:hardware => @hardware) | ||
allow(vm).to receive(:ipaddresses).and_return(@ipaddresses) | ||
url = vm.send(:ipv4_address) | ||
expect(url).to eq('35.190.140.48') | ||
end | ||
|
||
it 'returns the public ipv4 address for GCE' do | ||
ems = FactoryGirl.create(:ems_amazon) | ||
vm = FactoryGirl.create(:vm_amazon, :ext_management_system => ems, :hardware => @hardware) | ||
allow(vm).to receive(:ipaddresses).and_return(@ipaddresses) | ||
url = vm.send(:ipv4_address) | ||
expect(url).to eq('35.190.140.48') | ||
end | ||
end | ||
end | ||
|
||
context '#public_address' do | ||
it 'returns a public ipv4 address' do | ||
ipaddresses = %w(10.10.1.121 35.190.140.48) | ||
ems = FactoryGirl.create(:ems_amazon) | ||
vm = FactoryGirl.create(:vm_amazon, :ext_management_system => ems, :hardware => @hardware) | ||
allow(vm).to receive(:ipaddresses).and_return(ipaddresses) | ||
url = vm.send(:public_address) | ||
expect(url).to eq('35.190.140.48') | ||
end | ||
end | ||
end |