Module: Staypuft::Concerns::HostsApiExtensions

Extended by:
ActiveSupport::Concern
Defined in:
app/controllers/staypuft/concerns/hosts_api_extensions.rb

Instance Method Summary collapse

Instance Method Details

#check_openstack_hostgroupObject



8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/staypuft/concerns/hosts_api_extensions.rb', line 8

def check_openstack_hostgroup
  if params[:host] and params[:host][:hostgroup_id]
    hostgroup_id = params[:host][:hostgroup_id]
    hg = Hostgroup.find(hostgroup_id)
    unless @host.deployment and @host.hostgroup == hg
      if hg.ancestors.include? Hostgroup.get_base_hostgroup
        Rails.logger.error "Cannot set a deployment hostgroup directly."
        render :json => {:error => _('Cannot set a deployment hostgroup directly.') }, :status => :forbidden
      end
    end
  end
end