Module: ForemanAzureRM::Concerns::HostsControllerExtensions

Defined in:
app/controllers/foreman_azure_rm/concerns/hosts_controller_extensions.rb

Instance Method Summary collapse

Instance Method Details

#sizesObject



5
6
7
8
9
10
11
12
13
# File 'app/controllers/foreman_azure_rm/concerns/hosts_controller_extensions.rb', line 5

def sizes
  if (azure_rm_resource = Image.unscoped.find_by_uuid(params[:image_id])).present?
    resource = azure_rm_resource.compute_resource
    render :json => resource.vm_sizes(params[:location_string])
  else
    no_sizes = _('The location you selected has no sizes associated with it')
    render :json => "[\"#{no_sizes}\"]"
  end
end

#subnetsObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/foreman_azure_rm/concerns/hosts_controller_extensions.rb', line 15

def subnets
  azure_rm_image = Image.unscoped.find_by_uuid(params[:image_id])
  if azure_rm_image.present?
    azure_rm_resource = azure_rm_image.compute_resource
    subnets = azure_rm_resource.subnets(params[:location])
    if subnets.present?
      render :json => azure_rm_resource.subnets(params[:location])
    else
      no_subnets = _('The selected location has no subnets')
      render :json => "[\"#{no_subnets}\"]"
    end
  else
    no_compute = _('The selected image has no associated compute resource')
    render :json => "[\"#{no_compute}\"]"
  end
end