Revision 9a9ec5b1
Added by Daniel Lobato Garcia over 8 years ago
.rubocop_todo.yml | ||
---|---|---|
Rails/DefaultScope:
|
||
Enabled: false
|
||
|
||
# Offense count: 19
|
||
# Cop supports --auto-correct.
|
||
Rails/Delegate:
|
||
Enabled: false
|
||
|
||
# Offense count: 14
|
||
# Configuration parameters: Include.
|
||
Rails/HasAndBelongsToMany:
|
app/models/compute_resources/foreman/model/ec2.rb | ||
---|---|---|
class EC2 < ComputeResource
|
||
has_one :key_pair, :foreign_key => :compute_resource_id, :dependent => :destroy
|
||
|
||
delegate :subnets, :to => :client
|
||
delegate :flavors, :subnets, :to => :client
|
||
validates :user, :password, :presence => true
|
||
|
||
after_create :setup_key_pair
|
||
... | ... | |
@zones ||= client.describe_availability_zones.body["availabilityZoneInfo"].map { |r| r["zoneName"] if r["regionName"] == region }.compact
|
||
end
|
||
|
||
def flavors
|
||
client.flavors
|
||
end
|
||
|
||
def test_connection(options = {})
|
||
super
|
||
errors[:user].empty? and errors[:password].empty? and regions
|
app/models/compute_resources/foreman/model/ovirt.rb | ||
---|---|---|
|
||
alias_attribute :datacenter, :uuid
|
||
|
||
delegate :clusters, :quotas, :templates, :to => :client
|
||
|
||
def self.model_name
|
||
ComputeResource.model_name
|
||
end
|
||
... | ... | |
16*Foreman::SIZE[:giga]
|
||
end
|
||
|
||
def quotas
|
||
client.quotas
|
||
end
|
||
|
||
def ovirt_quota=(ovirt_quota_id)
|
||
self.attrs[:ovirt_quota_id] = ovirt_quota_id
|
||
end
|
||
... | ... | |
end
|
||
end
|
||
|
||
def templates(opts = {})
|
||
client.templates
|
||
end
|
||
|
||
def available_images
|
||
templates
|
||
end
|
||
... | ... | |
compute
|
||
end
|
||
|
||
def clusters
|
||
client.clusters
|
||
end
|
||
|
||
# Check if HTTPS is mandatory, since rest_client will fail with a POST
|
||
def test_https_required
|
||
RestClient.post url, {} if URI(url).scheme == 'http'
|
app/models/compute_resources/foreman/model/rackspace.rb | ||
---|---|---|
validates :user, :password, :region, :presence => true
|
||
validate :ensure_valid_region
|
||
|
||
delegate :flavors, :to => :client
|
||
|
||
def provided_attributes
|
||
super.merge({ :ip => :public_ip_address })
|
||
end
|
||
... | ... | |
["rackspace"]
|
||
end
|
||
|
||
def flavors
|
||
client.flavors
|
||
end
|
||
|
||
def available_images
|
||
client.images
|
||
end
|
app/models/concerns/fog_extensions/google/server.rb | ||
---|---|---|
module Server
|
||
extend ActiveSupport::Concern
|
||
|
||
delegate :flavors, :to => :service
|
||
|
||
def pretty_machine_type
|
||
machine_type.split('/')[-1]
|
||
end
|
||
|
||
def flavors
|
||
service.flavors
|
||
end
|
||
|
||
def image_id
|
||
image_name unless disks.blank?
|
||
end
|
app/models/concerns/puppetclass_total_hosts.rb | ||
---|---|---|
after_save :update_total_hosts
|
||
after_destroy :update_total_hosts
|
||
|
||
def update_total_hosts
|
||
puppetclass.update_total_hosts
|
||
end
|
||
delegate :update_total_hosts, :to => :puppetclass
|
||
end
|
||
end
|
||
end
|
app/models/operatingsystems/archlinux.rb | ||
---|---|---|
class Archlinux < Operatingsystem
|
||
PXEFILES = {:kernel => "linux", :initrd => "initrd"}
|
||
|
||
class << self
|
||
delegate :model_name, :to => :superclass
|
||
end
|
||
|
||
# Simple output of the media url
|
||
def mediumpath(host)
|
||
medium_uri(host).to_s
|
||
... | ... | |
def display_family
|
||
"Arch Linux"
|
||
end
|
||
|
||
def self.model_name
|
||
superclass.model_name
|
||
end
|
||
end
|
app/models/operatingsystems/coreos.rb | ||
---|---|---|
class Coreos < Operatingsystem
|
||
PXEFILES = {:kernel => 'coreos_production_pxe.vmlinuz', :initrd => 'coreos_production_pxe_image.cpio.gz'}
|
||
|
||
class << self
|
||
delegate :model_name, :to => :superclass
|
||
end
|
||
|
||
def pxe_type
|
||
'coreos'
|
||
end
|
||
... | ... | |
def use_release_name?
|
||
true
|
||
end
|
||
|
||
def self.model_name
|
||
superclass.model_name
|
||
end
|
||
end
|
app/models/operatingsystems/freebsd.rb | ||
---|---|---|
# -as initrd we will use your custom FreeBSD-<arch>-<version>-mfs.img in boot
|
||
PXEFILES = {}
|
||
|
||
class << self
|
||
delegate :model_name, :to => :superclass
|
||
end
|
||
|
||
# Simple output of the media url
|
||
def mediumpath(host)
|
||
medium_uri(host).to_s.gsub("x86_64","amd64")
|
||
... | ... | |
"boot/FreeBSD-#{arch}-#{release}-mfs.img"
|
||
end
|
||
|
||
def self.model_name
|
||
superclass.model_name
|
||
end
|
||
|
||
def display_family
|
||
"FreeBSD"
|
||
end
|
app/models/operatingsystems/gentoo.rb | ||
---|---|---|
class Gentoo < Operatingsystem
|
||
PXEFILES = {}
|
||
|
||
class << self
|
||
delegate :model_name, :to => :superclass
|
||
end
|
||
|
||
def mediumpath(host)
|
||
end
|
||
|
||
... | ... | |
def display_family
|
||
"Gentoo"
|
||
end
|
||
|
||
def self.model_name
|
||
superclass.model_name
|
||
end
|
||
end
|
app/models/operatingsystems/redhat.rb | ||
---|---|---|
class Redhat < Operatingsystem
|
||
PXEFILES = {:kernel => "vmlinuz", :initrd => "initrd.img"}
|
||
|
||
class << self
|
||
delegate :model_name, :to => :superclass
|
||
end
|
||
|
||
# outputs kickstart installation medium based on the medium type (NFS or URL)
|
||
# it also convert the $arch string to the current host architecture
|
||
def mediumpath(host)
|
||
... | ... | |
s.strip!
|
||
s.blank? ? description : s
|
||
end
|
||
|
||
def self.model_name
|
||
superclass.model_name
|
||
end
|
||
end
|
app/models/operatingsystems/solaris.rb | ||
---|---|---|
class Solaris < Operatingsystem
|
||
PXEFILES = {:initrd => "x86.miniroot", :kernel => "multiboot"}
|
||
|
||
class << self
|
||
delegate :model_name, :to => :superclass
|
||
end
|
||
|
||
def file_prefix
|
||
"#{self}".gsub(/[\s\(\)]/,"-").gsub("--", "-").gsub(/-\Z/, "")
|
||
end
|
||
... | ... | |
"Solaris"
|
||
end
|
||
|
||
def self.model_name
|
||
superclass.model_name
|
||
end
|
||
|
||
private
|
||
|
||
def resolv_nfs_path(host, dir, domain)
|
app/models/operatingsystems/suse.rb | ||
---|---|---|
class Suse < Operatingsystem
|
||
PXEFILES = {:kernel => "linux", :initrd => "initrd"}
|
||
|
||
class << self
|
||
delegate :model_name, :to => :superclass
|
||
end
|
||
|
||
def pxe_type
|
||
"yast"
|
||
end
|
||
... | ... | |
s.strip!
|
||
s.blank? ? description : s
|
||
end
|
||
|
||
def self.model_name
|
||
superclass.model_name
|
||
end
|
||
end
|
app/models/operatingsystems/windows.rb | ||
---|---|---|
class Windows < Operatingsystem
|
||
PXEFILES = {:kernel => "wimboot", :initrd => "bootmgr", :bcd => "bcd", :bootsdi => "boot.sdi", :bootwim => "boot.wim"}
|
||
|
||
class << self
|
||
delegate :model_name, :to => :superclass
|
||
end
|
||
|
||
def pxe_type
|
||
"waik"
|
||
end
|
||
... | ... | |
end
|
||
end
|
||
|
||
def self.model_name
|
||
superclass.model_name
|
||
end
|
||
|
||
def display_family
|
||
"Windows"
|
||
end
|
app/models/user_role.rb | ||
---|---|---|
validates :role_id, :presence => true
|
||
validates :owner_id, :presence => true, :uniqueness => {:scope => [:role_id, :owner_type],
|
||
:message => N_("has this role already")}
|
||
|
||
delegate :expire_topbar_cache, :to => :owner
|
||
|
||
def user_role?
|
||
self.owner_type == 'User'
|
||
end
|
||
... | ... | |
after_save :cache_user_roles!
|
||
before_destroy :remove_cache!
|
||
|
||
def expire_topbar_cache(sweeper)
|
||
owner.expire_topbar_cache(sweeper)
|
||
end
|
||
|
||
private
|
||
|
||
def remove_cache!
|
app/services/orchestration/queue.rb | ||
---|---|---|
attr_reader :items
|
||
STATUS = %w[ pending running failed completed rollbacked conflict canceled]
|
||
|
||
delegate :count, :empty?, :to => :items
|
||
delegate :to_json, :to => :all
|
||
|
||
def initialize
|
||
@items = []
|
||
end
|
||
... | ... | |
items.sort
|
||
end
|
||
|
||
def count
|
||
items.count
|
||
end
|
||
|
||
def empty?
|
||
items.empty?
|
||
end
|
||
|
||
def clear
|
||
@items = [] && true
|
||
end
|
||
|
||
def to_json
|
||
all.to_json
|
||
end
|
||
|
||
STATUS.each do |s|
|
||
define_method s do
|
||
all.delete_if {|t| t.status != s}.sort
|
lib/tasks/smartproxy.rake | ||
---|---|---|
proxies.map! do |proxy|
|
||
class << proxy
|
||
attr_accessor :names
|
||
def include? hostname
|
||
names.include? hostname
|
||
end
|
||
delegate :include?, :to => :names
|
||
# # This creates a list of names that include the proxy's fqdn plus pupppet.domain, if puppet is an alias for host
|
||
def load_aliases
|
||
@names = [hostname]
|
Also available in: Unified diff
Refs #3809 - Enable Rails delegate cop