Class: DopCommon::Node
Defined Under Namespace
Modules: Config
Constant Summary
collapse
- DEFAULT_DIGITS =
2
- VALID_FLAVOR_TYPES =
{
:tiny => {
:cores => 1,
:memory => 536870912,
:storage => 1073741824
},
:small => {
:cores => 1,
:memory => 2147483648,
:storage => 10737418240
},
:medium => {
:cores => 2,
:memory => 4294967296,
:storage => 10737418240
},
:large => {
:cores => 4,
:memory => 8589934592,
:storage => 10737418240
},
:xlarge => {
:cores => 8,
:memory => 17179869184,
:storage => 10737418240
}
}
- DEFAULT_OPENSTACK_FLAVOR =
'm1.medium'
- DEFAULT_CORES =
VALID_FLAVOR_TYPES[:medium][:cores]
- DEFAULT_MEMORY =
VALID_FLAVOR_TYPES[:medium][:memory]
- DEFAULT_STORAGE =
VALID_FLAVOR_TYPES[:medium][:storage]
Instance Attribute Summary collapse
-
#name ⇒ Object
(also: #nodename)
readonly
Returns the value of attribute name.
Instance Method Summary
collapse
Methods included from Config
#config, #config_includes?, #fact, #has_config?, #has_fact?, #has_name?, #has_role?, #role
Methods included from Utils
sanitize_env
Methods included from HashParser
deep_symbolize_keys, hash_of_pattern_lists_valid?, is_valid_regexp?, key_aliases, load_content, load_content_valid?, parse_hash_of_pattern_lists, parse_pattern_list, pattern_list_valid?, represents_regexp?, symbolize_keys
Methods included from Validator
#log_validation_method, #set_not_valid, #try_validate_obj, #valid?
Constructor Details
#initialize(name, hash, parent = {}) ⇒ Node
Returns a new instance of Node.
52
53
54
55
56
57
58
59
|
# File 'lib/dop_common/node.rb', line 52
def initialize(name, hash, parent={})
@name = name
@hash = symbolize_keys(hash)
@parsed_infrastructures = parent[:parsed_infrastructures]
@parsed_credentials = parent[:parsed_credentials]
@parsed_hooks = parent[:parsed_hooks]
@parsed_configuration = parent[:parsed_configuration]
end
|
Instance Attribute Details
#name ⇒ Object
Also known as:
nodename
Returns the value of attribute name.
13
14
15
|
# File 'lib/dop_common/node.rb', line 13
def name
@name
end
|
Instance Method Details
#cores ⇒ Object
159
160
161
|
# File 'lib/dop_common/node.rb', line 159
def cores
@cores ||= cores_valid? ? create_cores : nil
end
|
#credentials ⇒ Object
183
184
185
|
# File 'lib/dop_common/node.rb', line 183
def credentials
@credentials ||= credentials_valid? ? create_credentials : []
end
|
#data_disks ⇒ Object
191
192
193
|
# File 'lib/dop_common/node.rb', line 191
def data_disks
@data_disks ||= data_disks_valid? ? create_data_disks : []
end
|
#digits ⇒ Object
92
93
94
95
|
# File 'lib/dop_common/node.rb', line 92
def digits
@digits ||= digits_valid? ?
@hash[:digits] : DEFAULT_DIGITS
end
|
#dns ⇒ Object
187
188
189
|
# File 'lib/dop_common/node.rb', line 187
def dns
@dns ||= dns_valid? ? create_dns : nil
end
|
#domainname ⇒ Object
124
125
126
|
# File 'lib/dop_common/node.rb', line 124
def domainname
@domainname ||= fqdn.split('.', 2).last
end
|
#flavor ⇒ Object
155
156
157
|
# File 'lib/dop_common/node.rb', line 155
def flavor
@flavor ||= flavor_valid? ? create_flavor : nil
end
|
#force_stop? ⇒ Boolean
Also known as:
force_stop
203
204
205
|
# File 'lib/dop_common/node.rb', line 203
def force_stop?
@force_stop ||= force_stop_valid? ? @hash[:force_stop] : false
end
|
#fqdn ⇒ Object
116
117
118
|
# File 'lib/dop_common/node.rb', line 116
def fqdn
@fqdn ||= fqdn_valid? ? create_fqdn : nil
end
|
#full_clone? ⇒ Boolean
Also known as:
full_clone
141
142
143
|
# File 'lib/dop_common/node.rb', line 141
def full_clone?
@full_clone ||= full_clone_valid? ? @hash[:full_clone] : true
end
|
#hooks ⇒ Object
195
196
197
|
# File 'lib/dop_common/node.rb', line 195
def hooks
@parsed_hooks
end
|
#hostname ⇒ Object
120
121
122
|
# File 'lib/dop_common/node.rb', line 120
def hostname
@hostname ||= fqdn.split('.').first
end
|
#image ⇒ Object
137
138
139
|
# File 'lib/dop_common/node.rb', line 137
def image
@image ||= image_valid? ? @hash[:image] : nil
end
|
#inflatable? ⇒ Boolean
Check if the node describes a series of nodes.
103
104
105
|
# File 'lib/dop_common/node.rb', line 103
def inflatable?
@name.include?('{i}')
end
|
#inflate ⇒ Object
Create and return all the nodes in the series
108
109
110
111
112
113
114
|
# File 'lib/dop_common/node.rb', line 108
def inflate
range.map do |node_number|
@node_copy = clone
@node_copy.name = @name.gsub('{i}', "%0#{digits}d" % node_number)
@node_copy
end
end
|
#infrastructure ⇒ Object
128
129
130
|
# File 'lib/dop_common/node.rb', line 128
def infrastructure
@infrastructure ||= infrastructure_valid? ? create_infrastructure : nil
end
|
#infrastructure_properties ⇒ Object
132
133
134
135
|
# File 'lib/dop_common/node.rb', line 132
def infrastructure_properties
@infrastructure_properties ||= infrastructure_properties_valid? ?
create_infrastructure_properties : {}
end
|
#interfaces ⇒ Object
151
152
153
|
# File 'lib/dop_common/node.rb', line 151
def interfaces
@interfaces ||= interfaces_valid? ? create_interfaces : []
end
|
#memory ⇒ Object
163
164
165
|
# File 'lib/dop_common/node.rb', line 163
def memory
@memory ||= memory_valid? ? create_memory : nil
end
|
#organization_name ⇒ Object
179
180
181
|
# File 'lib/dop_common/node.rb', line 179
def organization_name
@organization_name ||= organization_name_valid? ? @hash[:organization_name] : nil
end
|
#product_id ⇒ Object
175
176
177
|
# File 'lib/dop_common/node.rb', line 175
def product_id
@product_id ||= product_id_valid? ? @hash[:product_id] : nil
end
|
#range ⇒ Object
97
98
99
100
|
# File 'lib/dop_common/node.rb', line 97
def range
@range ||= range_valid? ?
Range.new(*@hash[:range].scan(/\d+/)) : nil
end
|
#storage ⇒ Object
167
168
169
|
# File 'lib/dop_common/node.rb', line 167
def storage
@storage ||= storage_valid? ? create_storage : nil
end
|
199
200
201
|
# File 'lib/dop_common/node.rb', line 199
def tags
@tags ||= tags_valid? ? create_tags : nil
end
|
#thin_clone? ⇒ Boolean
Also known as:
thin_clone
146
147
148
|
# File 'lib/dop_common/node.rb', line 146
def thin_clone?
@thin_clone ||= thin_clone_valid? ? @hash[:thin_clone] : nil
end
|
#timezone ⇒ Object
171
172
173
|
# File 'lib/dop_common/node.rb', line 171
def timezone
@timezone ||= timezone_valid? ? @hash[:timezone] : nil
end
|
#validate ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/dop_common/node.rb', line 61
def validate
log_validation_method('digits_valid?')
log_validation_method('range_valid?')
log_validation_method('fqdn_valid?')
log_validation_method('infrastructure_valid?')
log_validation_method('infrastructure_properties_valid?')
log_validation_method('image_valid?')
log_validation_method('full_clone_valid?')
log_validation_method('thin_clone_valid?')
log_validation_method('interfaces_valid?')
log_validation_method('flavor_valid?')
log_validation_method('cores_valid?')
log_validation_method('memory_valid?')
log_validation_method('storage_valid?')
log_validation_method('timezone_valid?')
log_validation_method('product_id_valid?')
log_validation_method('organization_name_valid?')
log_validation_method('credentials_valid?')
log_validation_method('dns_valid?')
log_validation_method('data_disks_valid?')
log_validation_method('tags_valid?')
log_validation_method('force_stop_valid?')
try_validate_obj("Node #{@name}: Can't validate the interfaces part because of a previous error"){interfaces}
try_validate_obj("Node #{@name}: Can't validate the infrastructure_properties part because of a previous error"){infrastructure_properties}
try_validate_obj("Node #{@name}: Can't validate the dns part because of a previous error"){dns}
try_validate_obj("Node #{@name}: Can't validate data_disks part because of a previous error"){data_disks}
try_validate_obj("Node #{@name}: Can't validate the memory part because of a previous error"){memory} unless @hash[:memory].nil?
try_validate_obj("Node #{@name}: Can't validate storage part because of a previous error"){storage} unless @hash[:storage].nil?
end
|