Class: Ironfan::Dsl::Server

Inherits:
Compute show all
Defined in:
lib/ironfan/headers.rb,
lib/ironfan/dsl/server.rb

Instance Attribute Summary

Attributes included from Gorillib::Resolution

#underlay

Instance Method Summary collapse

Methods inherited from Compute

_project, #cloud, cluster_role_name, #ec2, facet_role_name, #openstack, #raid_group, #rds, #recipe, #role, #run_list, #selected_cloud, #static, #vsphere

Methods inherited from Ironfan::Dsl

#_skip_fields, #skip_fields, #to_manifest

Methods included from Gorillib::Resolution

#deep_resolve, #merge_resolve, #merge_values, #read_resolved_attribute, #read_set_attribute, #read_set_or_underlay_attribute, #read_underlay_attribute, #resolve, #resolve!, #resolve_value

Methods included from CookbookRequirements

#_cookbook_reqs, #children, #cookbook_req, #cookbook_reqs, #join_req

Methods inherited from Builder

ui, #ui

Constructor Details

#initialize(attrs = {}, &block) ⇒ Server

Returns a new instance of Server.


223
224
225
226
227
228
229
230
231
232
233
# File 'lib/ironfan/dsl/server.rb', line 223

def initialize(attrs={},&block)
  unless attrs[:owner].nil?
    self.realm_name       attrs[:owner].realm_name
    self.cluster_name =   attrs[:owner].cluster_name
    self.facet_name =     attrs[:owner].name

    self.role     Compute.cluster_role_name(realm_name, cluster_name), :last
    self.role     Compute.facet_role_name(realm_name, cluster_name, facet_name), :last
  end
  super
end

Instance Method Details

#canonical_machine_manifest_hashObject


326
327
328
# File 'lib/ironfan/dsl/server.rb', line 326

def canonical_machine_manifest_hash
  self.class.canonicalize(to_machine_manifest)
end

#fqdnObject


247
# File 'lib/ironfan/dsl/server.rb', line 247

def fqdn()                [self.host_name, self.dns_domain].compact.join(".");     end

#full_cluster_nameObject


239
240
241
# File 'lib/ironfan/dsl/server.rb', line 239

def full_cluster_name
    "#{realm_name}-#{cluster_name}"
end

#full_nameObject


243
244
245
# File 'lib/ironfan/dsl/server.rb', line 243

def full_name
  "#{full_cluster_name}-#{facet_name}-#{name}"
end

#host_nameObject


246
# File 'lib/ironfan/dsl/server.rb', line 246

def host_name()           full_name.gsub('_','-'); end

#implied_volumesObject


250
# File 'lib/ironfan/dsl/server.rb', line 250

def implied_volumes()    selected_cloud.implied_volumes;                 end

#indexObject


249
# File 'lib/ironfan/dsl/server.rb', line 249

def index()               name.to_i;                                      end

#inspect_compactObject

we should always show up in owners' inspect string


263
# File 'lib/ironfan/dsl/server.rb', line 263

def inspect_compact ; inspect ; end

#keypair_nameObject


235
236
237
# File 'lib/ironfan/dsl/server.rb', line 235

def keypair_name
  full_cluster_name
end

#lintObject


266
267
268
269
270
# File 'lib/ironfan/dsl/server.rb', line 266

def lint
  errors = []
  errors['missing cluster/facet/server'] = [cluster_name, facet_name, name] unless (cluster_name && facet_name && name)
  errors
end

#to_display(style, values = {}) ⇒ Object


252
253
254
255
256
257
258
259
260
# File 'lib/ironfan/dsl/server.rb', line 252

def to_display(style,values={})
  selected_cloud.to_display(style,values)

  return values if style == :minimal

  values["Env"]   = environment
  values["Realm"] = realm_name
  values
end

#to_machine_manifestObject


272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/ironfan/dsl/server.rb', line 272

def to_machine_manifest
  cloud = clouds.each.to_a.first
  MachineManifest.receive(

                          # base server fields

                          environment: environment,
                          name: name,
                          cluster_name: cluster_name,
                          facet_name: facet_name,
                          run_list: run_list,
                          components: components,
                          cluster_default_attributes: cluster_role.default_attributes,
                          cluster_override_attributes: cluster_role.override_attributes,
                          facet_default_attributes: facet_role.default_attributes,
                          facet_override_attributes: facet_role.override_attributes,
                          volumes: volumes,

                          # cloud fields

                          cloud_name: cloud.name,

                          availability_zones: cloud.availability_zones,
                          backing: cloud.backing,
                          bits: cloud.bits,
                          bootstrap_distro: cloud.bootstrap_distro,
                          chef_client_script: cloud.chef_client_script,
                          default_availability_zone: cloud.default_availability_zone,
                          elastic_load_balancers: cloud.respond_to?(:elastic_load_balancers) ? cloud.elastic_load_balancers : nil,
                          ebs_optimized: cloud.ebs_optimized,
                          flavor: cloud.flavor,
                          iam_server_certificates: cloud.respond_to?(:iam_server_certificates) ? cloud.iam_server_certificates : nil,
                          image_id: cloud.image_id,
                          image_name: cloud.image_name,
                          keypair: cloud.keypair,
                          monitoring: cloud.monitoring,
                          mount_ephemerals: cloud.mount_ephemerals,
                          permanent: cloud.permanent,
                          placement_group: cloud.placement_group,
                          provider: cloud.provider,
                          elastic_ip: cloud.elastic_ip,
                          auto_elastic_ip: cloud.auto_elastic_ip,
                          allocation_id: cloud.allocation_id,
                          region: cloud.region,
                          security_groups: cloud.security_groups,
                          ssh_user: cloud.ssh_user,
                          ssh_identity_dir: cloud.ssh_identity_dir,
                          subnet: cloud.subnet,
                          validation_key: cloud.validation_key,
                          vpc: cloud.vpc

                          )
end