Skip to content

Commit

Permalink
Merge pull request #25 from bronaghs/floating_ip_available_method_change
Browse files Browse the repository at this point in the history
Return the available Floating IPs in Azure.
  • Loading branch information
djberg96 authored Jan 17, 2017
2 parents f9d9e06 + 659a8f8 commit 8479948
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/manageiq/providers/azure/network_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class ManageIQ::Providers::Azure::NetworkManager < ManageIQ::Providers::NetworkM

include ManageIQ::Providers::Azure::ManagerMixin

has_many :floating_ips, :foreign_key => :ems_id, :dependent => :destroy,
:class_name => ManageIQ::Providers::Azure::NetworkManager::FloatingIp

# Auth and endpoints delegations, editing of this type of manager must be disabled
delegate :authentication_check,
:authentication_status,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
class ManageIQ::Providers::Azure::NetworkManager::FloatingIp < ::FloatingIp
def self.available
joins(:network_port).where("network_ports.device_id" => nil) + where(:network_port_id => nil)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,34 @@
end
end
end

context "floating ips" do
before do
FactoryGirl.create(:network_port_azure, :id => 1, :device_id => nil)
ems.floating_ips << FactoryGirl.create(
:floating_ip_azure,
:ext_management_system => ems.network_manager,
:network_port_id => 1
)

FactoryGirl.create(:network_port_azure, :id => 2, :device_id => 1)
ems.floating_ips << FactoryGirl.create(
:floating_ip_azure,
:ext_management_system => ems.network_manager,
:network_port_id => 2
)

ems.floating_ips << FactoryGirl.create(
:floating_ip_azure,
:ext_management_system => ems.network_manager,
:network_port_id => nil
)
end

it "allowed_floating_ips" do
expect(workflow.allowed_floating_ip_addresses.length).to eq(2)
end
end
end

context "with applied tags" do
Expand Down

0 comments on commit 8479948

Please sign in to comment.