Class: DNApi::Instance

Inherits:
Struct
  • Object
show all
Includes:
ComponentPossessor
Defined in:
lib/dnapi/instance.rb

Instance Attribute Summary collapse

Attributes inherited from Struct

#parent

Instance Method Summary collapse

Methods included from ComponentPossessor

#add_component, #component, #component_group, #has_component?, included

Methods inherited from Struct

#==, #_many, _many, #_many_values, #_ones, _ones, #_ones_values, _umembers, belongs_to, from, #inspect, many, map, one, #to_hash, #umember_inspect, unserialized_member

Methods included from Test::Ext

#default_fauxture_name, #fixture, #generate, #generate_attributes, #pick

Constructor Details

#initialize(attributes) ⇒ Instance

Returns a new instance of Instance.



20
21
22
23
24
25
26
27
28
# File 'lib/dnapi/instance.rb', line 20

def initialize(attributes)
  #legacy - (awsm,cookbooks?) passed in 'provisioned' (<2010?) - paranoid of breaking our existing "api"
  if provisioned = attributes.delete(:provisioned)
    attributes[:id] = provisioned.id
    attributes[:public_hostname] = provisioned.public_hostname
    attributes[:private_hostname] = provisioned.private_hostname
  end
  super(attributes)
end

Instance Attribute Details

#awsm_tokenObject

Returns the value of attribute awsm_token

Returns:

  • (Object)

    the current value of awsm_token



2
3
4
# File 'lib/dnapi/instance.rb', line 2

def awsm_token
  @awsm_token
end

#enabledObject Also known as: enabled?

Returns the value of attribute enabled

Returns:

  • (Object)

    the current value of enabled



2
3
4
# File 'lib/dnapi/instance.rb', line 2

def enabled
  @enabled
end

#environmentObject

chef-ey selectors



67
68
69
# File 'lib/dnapi/instance.rb', line 67

def environment
  @environment
end

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



2
3
4
# File 'lib/dnapi/instance.rb', line 2

def id
  @id
end

#instance_api_configObject

Returns the value of attribute instance_api_config

Returns:

  • (Object)

    the current value of instance_api_config



2
3
4
# File 'lib/dnapi/instance.rb', line 2

def instance_api_config
  @instance_api_config
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



2
3
4
# File 'lib/dnapi/instance.rb', line 2

def name
  @name
end

#private_hostnameObject

Returns the value of attribute private_hostname

Returns:

  • (Object)

    the current value of private_hostname



2
3
4
# File 'lib/dnapi/instance.rb', line 2

def private_hostname
  @private_hostname
end

#public_hostnameObject

Returns the value of attribute public_hostname

Returns:

  • (Object)

    the current value of public_hostname



2
3
4
# File 'lib/dnapi/instance.rb', line 2

def public_hostname
  @public_hostname
end

#reporting_urlObject

Returns the value of attribute reporting_url

Returns:

  • (Object)

    the current value of reporting_url



2
3
4
# File 'lib/dnapi/instance.rb', line 2

def reporting_url
  @reporting_url
end

#roleObject

Returns the value of attribute role

Returns:

  • (Object)

    the current value of role



2
3
4
# File 'lib/dnapi/instance.rb', line 2

def role
  @role
end

#stonith_configObject

Returns the value of attribute stonith_config

Returns:

  • (Object)

    the current value of stonith_config



2
3
4
# File 'lib/dnapi/instance.rb', line 2

def stonith_config
  @stonith_config
end

Instance Method Details

#engineyard_hashObject



46
47
48
49
# File 'lib/dnapi/instance.rb', line 46

def engineyard_hash
  { :environment => environment.to_hash,
    :this => id }
end

#legacy_hashObject



51
52
53
54
55
56
# File 'lib/dnapi/instance.rb', line 51

def legacy_hash
  { :engineyard => engineyard_hash,
    :instance_role => role,
    :reporting_url => reporting_url,
    :name => name }.reject {|k,v| v.nil? }
end

#newrelic_seedObject



32
33
34
35
# File 'lib/dnapi/instance.rb', line 32

def newrelic_seed
  c = component(:newrelic)
  c && c.seed
end

#newrelic_tokenObject



37
38
39
40
# File 'lib/dnapi/instance.rb', line 37

def newrelic_token
  c = component(:newrelic)
  c && c.token
end

#to_dnaObject



58
59
60
# File 'lib/dnapi/instance.rb', line 58

def to_dna
  to_legacy_hash
end

#to_legacy_hashObject



42
43
44
# File 'lib/dnapi/instance.rb', line 42

def to_legacy_hash
  environment.to_legacy_hash.merge(legacy_hash)
end

#to_sObject



62
63
64
# File 'lib/dnapi/instance.rb', line 62

def to_s
  "Instance #{id} @ #{public_hostname} as #{role}"
end