Revision acfbc458
Added by Marek Hulán about 10 years ago
app/controllers/subnets_controller.rb | ||
---|---|---|
class SubnetsController < ApplicationController
|
||
include Foreman::Controller::AutoCompleteSearch
|
||
before_filter :find_by_name, :only => [:edit, :update, :destroy]
|
||
|
||
def index
|
||
@subnets = Subnet.search_for(params[:search], :order => params[:order]).includes(:domains, :dhcp).paginate :page => params[:page]
|
||
@subnets = resource_base.search_for(params[:search], :order => params[:order]).includes(:domains, :dhcp).paginate :page => params[:page]
|
||
end
|
||
|
||
def new
|
||
... | ... | |
end
|
||
|
||
def edit
|
||
@subnet = Subnet.find(params[:id])
|
||
end
|
||
|
||
def update
|
||
@subnet = Subnet.find(params[:id])
|
||
if @subnet.update_attributes(params[:subnet])
|
||
process_success
|
||
else
|
||
... | ... | |
end
|
||
|
||
def destroy
|
||
@subnet = Subnet.find(params[:id])
|
||
if @subnet.destroy
|
||
process_success
|
||
else
|
||
... | ... | |
organization = params[:organization_id].blank? ? nil : Organization.find(params[:organization_id])
|
||
location = params[:location_id].blank? ? nil : Location.find(params[:location_id])
|
||
Taxonomy.as_taxonomy organization, location do
|
||
not_found and return unless (subnet = Subnet.find(s))
|
||
not_found and return unless (subnet = Subnet.authorized(:view_subnets).find(s))
|
||
if (ip = subnet.unused_ip(params[:host_mac]))
|
||
render :json => {:ip => ip}
|
||
else
|
||
... | ... | |
end
|
||
end
|
||
rescue => e
|
||
logger.warn "Failed to query #{subnet} for free ip: #{e}"
|
||
logger.warn "Failed to query subnet #{s} for free ip: #{e}"
|
||
head :status => 500
|
||
end
|
||
|
Also available in: Unified diff
fixes #812 - new permissions model, user group role and nest support, role filters for better granularity
Contributions from: