Class: ForemanOpenstackCluster::Cluster

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
HostCommon
Defined in:
app/models/foreman_openstack_cluster/cluster.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#private_subnetObject

Returns the value of attribute private_subnet.



32
33
34
# File 'app/models/foreman_openstack_cluster/cluster.rb', line 32

def private_subnet
  @private_subnet
end

#public_subnetObject

Returns the value of attribute public_subnet.



32
33
34
# File 'app/models/foreman_openstack_cluster/cluster.rb', line 32

def public_subnet
  @public_subnet
end

Class Method Details

.advanced_paramsObject



91
92
93
# File 'app/models/foreman_openstack_cluster/cluster.rb', line 91

def self.advanced_params
  params.reject {|p,d| d[:advanced].blank? }
end

.basic_paramsObject

Helpers for the two types of params



87
88
89
# File 'app/models/foreman_openstack_cluster/cluster.rb', line 87

def self.basic_params
  params.reject {|p,d| d[:advanced].present? }
end

.column(name, sql_type = nil, default = nil, null = true) ⇒ Object



10
11
12
13
# File 'app/models/foreman_openstack_cluster/cluster.rb', line 10

def self.column(name, sql_type = nil, default = nil, null = true)
  columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default,
                                                          sql_type.to_s, null)
end

.columnsObject

Make a table-less model to avoid pointless migrations



6
7
8
# File 'app/models/foreman_openstack_cluster/cluster.rb', line 6

def self.columns
  @columns ||= [];
end

.param(args) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'app/models/foreman_openstack_cluster/cluster.rb', line 40

def self.param args
  name = args[:name] || return
  default = args[:default] || ''
  type = args[:type] || :string
  advanced = args[:advanced].present? ? true : false

  params.merge! name => { :default     => default,
                          :type        => type,
                          :placeholder => args[:placeholder],
                          :description => args[:description],
                          :advanced    => advanced }

  column name.to_sym, type
  validates_presence_of name.to_sym unless type == :boolean
end

.paramsObject

Class parameters to be supplied



36
37
38
# File 'app/models/foreman_openstack_cluster/cluster.rb', line 36

def self.params
  @params ||= {};
end

Instance Method Details

#save(validate = true) ⇒ Object

Override the save method to prevent exceptions.



16
17
18
# File 'app/models/foreman_openstack_cluster/cluster.rb', line 16

def save(validate = true)
  validate ? valid? : true
end