class ForemanSalt::Api::V2::SaltAutosignController
def all_autosign
def all_autosign @_autosigns ||= @api.autosign_list.map { |record| OpenStruct.new(record: record) } end
def auth
def auth Rails.logger.info("Removing Salt autosign key and update status for host #{@host}") @api.autosign_remove_key(@host.salt_autosign_key) unless @host.salt_autosign_key.nil? @host.update(salt_status: ForemanSalt::SaltStatus.minion_auth_success) render json: { message: 'Removed autosign key and updated status succesfully' }, status: :no_content rescue ::Foreman::Exception => e Rails.logger.warn("Cannot delete autosign key of host (id => #{params[:name]}) state: #{e}") render json: { message: e.to_s }, status: :unprocessable_entity end
def create
def create @api.autosign_create params[:record] @salt_autosign = { record: params[:record] } end
def destroy
def destroy @api.autosign_remove params[:record] render json: { root_node_name => _('Record deleted.') } end
def find_host
def find_host @host = resource_finder(Host.authorized(:view_hosts), params[:name]) not_found unless @host end
def find_proxy
def find_proxy @proxy = ::SmartProxy.friendly.find(params[:smart_proxy_id]) not_found unless @proxy end
def find_proxy_via_host
def find_proxy_via_host @proxy = ::SmartProxy.friendly.find(@host.salt_proxy.id) not_found unless @proxy end
def index
def index @salt_autosigns = all_autosign end
def metadata_page
def metadata_page 1 end
def metadata_per_page
def metadata_per_page metadata_total end
def metadata_subtotal
def metadata_subtotal metadata_total end
def metadata_total
def metadata_total @total ||= all_autosign.count end
def setup_proxy
def setup_proxy @api = ProxyAPI::Salt.new(url: @proxy.url) end