Project

General

Profile

« Previous | Next » 

Revision 611f5bff

Added by Amos Benari over 11 years ago

  • ID 611f5bff49c1f06ae9ad0dd42b7566df9a02af2f

Add organization and location to foreman.

This feature allows foreman to provide multi location, multi tenant and
multi organizations capablities.

the idea is that resources within foreman (e.g. hosts, subnets, users,
environments etc) can belong to one or more locations and organization,
effectivily hidding resources from users.

Organization may contain multiple locations, and Locations can belong
to multiple Organization, this is an extermily flexiable design,
however, it is up to the user to allocate the resources across the
organizations and locations.

When creating new hosts, the resources that can be consumed are only
resources in which exists in both the currently used organization and location.

fixes #1578
fixes #1593

View differences:

app/models/subnet.rb
require 'ipaddr'
class Subnet < ActiveRecord::Base
include Authorization
include Taxonomix
has_many :hosts
# sps = Service processors / ilom boards etc
has_many :sps, :class_name => "Host", :foreign_key => 'sp_subnet_id'
......
validates_format_of :network, :mask, :with => Net::Validations::IP_REGEXP
validates_format_of :gateway, :dns_primary, :dns_secondary, :with => Net::Validations::IP_REGEXP, :allow_blank => true, :allow_nil => true
validate :name_should_be_uniq_across_domains
default_scope :order => 'priority'
validate :validate_ranges
default_scope lambda {
with_taxonomy_scope do
order('vlanid')
end
}
before_destroy EnsureNotUsedBy.new(:hosts, :sps)
scoped_search :on => [:name, :network, :mask, :gateway, :dns_primary, :dns_secondary, :vlanid], :complete_value => true
......
# [+other+] : Subnet object with which to compare ourself
# +returns+ : Subnet object with higher precedence
def <=> (other)
self.priority <=> other.priority
self.vlanid <=> other.vlanid
end
# Given an IP returns the subnet that contains that IP

Also available in: Unified diff