Sha256: 8a1f1815f4ea448561d26b9e3c1bf421b0a65896b3d2130842b21c6f4782b94c

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

module ForemanAzureRM
  module Concerns
    module HostsControllerExtensions

      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

      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
foreman_azure_rm-1.2.0 app/controllers/foreman_azure_rm/concerns/hosts_controller_extensions.rb
foreman_azure_rm-1.1.1 app/controllers/foreman_azure_rm/concerns/hosts_controller_extensions.rb
foreman_azure_rm-1.1.0 app/controllers/foreman_azure_rm/concerns/hosts_controller_extensions.rb