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

Filter openstack networks in provisioning #17055

Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def allowed_cloud_subnets(_options = {})
def allowed_cloud_networks(_options = {})
return {} unless (src = provider_or_tenant_object)
targets = get_targets_for_source(src, :cloud_filter, CloudNetwork, 'all_cloud_networks')
targets = filter_openstack_networks(targets) if openstack?(targets)
allowed_ci(:cloud_network, [:availability_zone], targets.map(&:id))
end

Expand Down Expand Up @@ -141,4 +142,16 @@ def provider_or_tenant_object
obj = src[:cloud_tenant] || src[:ems]
load_ar_obj(obj)
end

def openstack?(networks)
networks.select do |cloud_network|
cloud_network.class.ancestors.include?("ManageIQ::Providers::Openstack::NetworkManager::CloudNetwork")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

core code can't have any mentions of OpenStack, do this via support mixin or use specific allowed_cloud_networks in OpenStack plugin

end.any?
end

def filter_openstack_networks(networks)
networks.select do |cloud_network|
cloud_network.eligible_for_vm_provisioning? == true
end
end
end