Skip to content

Commit

Permalink
Move placement checks to common location
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Sep 27, 2016
1 parent 51e70c8 commit dca8127
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ def find_destination_in_vmdb
def prepare_for_clone_task
raise MiqException::MiqProvisionError, "Provision Request's Destination VM Name=[#{dest_name}] cannot be blank" if dest_name.blank?
raise MiqException::MiqProvisionError, "A VM with name: [#{dest_name}] already exists" if source.ext_management_system.vms.where(:name => dest_name).any?
raise MiqException::MiqProvisionError, "Neither Cluster nor Host selected for [#{dest_name}]" if dest_host.nil? && dest_cluster.nil?
raise MiqException::MiqProvisionError, "A Host must be selected on a non-DRS enabled cluster" if dest_host.nil? && !dest_cluster.drs_enabled

clone_options = {
:name => dest_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,17 @@ module ManageIQ::Providers::Vmware::InfraManager::Provision::Placement
protected

def placement
if get_option(:placement_auto) == true
host, cluster, datastore = if get_option(:placement_auto) == true
automatic_placement
else
manual_placement
end

raise MiqException::MiqProvisionError, "Destination placement_ds_name not provided" if datastore.nil?
raise MiqException::MiqProvisionError, "Destination placement_host_name and placement_cluster_name not provided" if host.nil? && cluster.nil?
raise MiqException::MiqProvisionError, "A Host must be selected on a non-DRS enabled cluster" if host.nil? && !cluster.drs_enabled

return host, cluster, datastore
end

private
Expand All @@ -20,9 +26,6 @@ def manual_placement
cluster = selected_placement_obj(:placement_cluster_name, EmsCluster)
datastore = selected_placement_obj(:placement_ds_name, Storage)

raise MiqException::MiqProvisionError, "Destination placement_ds_name not provided" if datastore.nil?
raise MiqException::MiqProvisionError, "Destination placement_host_name and placement_cluster_name not provided" if host.nil? && cluster.nil?

if host && cluster.nil?
cluster = host.ems_cluster
end
Expand Down

0 comments on commit dca8127

Please sign in to comment.