Class: Instance
- Includes:
- TestPoller, Timeout
- Defined in:
- lib/deltacloud/drivers/condor/condor_driver.rb,
lib/deltacloud/api.rb,
lib/deltacloud/models/instance.rb,
lib/deltacloud/drivers/ec2/ec2_driver.rb,
lib/deltacloud/drivers/gogrid/gogrid_driver.rb
Overview
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#authn_error ⇒ Object
Returns the value of attribute authn_error.
-
#create_image ⇒ Object
Returns the value of attribute create_image.
-
#firewalls ⇒ Object
Returns the value of attribute firewalls.
-
#image_id ⇒ Object
Returns the value of attribute image_id.
-
#instance_profile ⇒ Object
Returns the value of attribute instance_profile.
-
#keyname ⇒ Object
Returns the value of attribute keyname.
-
#launch_time ⇒ Object
Returns the value of attribute launch_time.
-
#name ⇒ Object
Returns the value of attribute name.
-
#owner_id ⇒ Object
Returns the value of attribute owner_id.
-
#password ⇒ Object
Returns the value of attribute password.
-
#private_addresses ⇒ Object
Returns the value of attribute private_addresses.
-
#public_addresses ⇒ Object
Returns the value of attribute public_addresses.
-
#realm_id ⇒ Object
Returns the value of attribute realm_id.
-
#state ⇒ Object
Returns the value of attribute state.
-
#storage_volumes ⇒ Object
Returns the value of attribute storage_volumes.
-
#username ⇒ Object
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #authn_feature_failed? ⇒ Boolean
- #can_create_image? ⇒ Boolean
- #hardware_profile ⇒ Object
- #hardware_profile=(profile) ⇒ Object
-
#initialize(init = nil) ⇒ Instance
constructor
A new instance of Instance.
- #method_missing(name, *args) ⇒ Object
- #to_hash(context) ⇒ Object
Methods included from TestPoller
Methods inherited from BaseModel
attr_accessor, attributes, #attributes, #id, #to_entity
Constructor Details
#initialize(init = nil) ⇒ Instance
Returns a new instance of Instance.
96 97 98 99 100 101 |
# File 'lib/deltacloud/models/instance.rb', line 96 def initialize(init=nil) super(init) self.actions = [] if self.actions.nil? self.public_addresses = [] if self.public_addresses.nil? self.private_addresses = [] if self.private_addresses.nil? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/deltacloud/models/instance.rb', line 103 def method_missing(name, *args) if name.to_s =~ /is_(\w+)\?/ self.state.downcase.eql?($1) else raise NoMethodError.new(name.to_s) end end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
28 29 30 |
# File 'lib/deltacloud/models/instance.rb', line 28 def actions @actions end |
#authn_error ⇒ Object
Returns the value of attribute authn_error.
34 35 36 |
# File 'lib/deltacloud/models/instance.rb', line 34 def authn_error @authn_error end |
#create_image ⇒ Object
Returns the value of attribute create_image.
37 38 39 |
# File 'lib/deltacloud/models/instance.rb', line 37 def create_image @create_image end |
#firewalls ⇒ Object
Returns the value of attribute firewalls.
38 39 40 |
# File 'lib/deltacloud/models/instance.rb', line 38 def firewalls @firewalls end |
#image_id ⇒ Object
Returns the value of attribute image_id.
24 25 26 |
# File 'lib/deltacloud/models/instance.rb', line 24 def image_id @image_id end |
#instance_profile ⇒ Object
Returns the value of attribute instance_profile.
31 32 33 |
# File 'lib/deltacloud/models/instance.rb', line 31 def instance_profile @instance_profile end |
#keyname ⇒ Object
Returns the value of attribute keyname.
33 34 35 |
# File 'lib/deltacloud/models/instance.rb', line 33 def keyname @keyname end |
#launch_time ⇒ Object
Returns the value of attribute launch_time.
32 33 34 |
# File 'lib/deltacloud/models/instance.rb', line 32 def launch_time @launch_time end |
#name ⇒ Object
Returns the value of attribute name.
25 26 27 |
# File 'lib/deltacloud/models/instance.rb', line 25 def name @name end |
#owner_id ⇒ Object
Returns the value of attribute owner_id.
23 24 25 |
# File 'lib/deltacloud/models/instance.rb', line 23 def owner_id @owner_id end |
#password ⇒ Object
Returns the value of attribute password.
36 37 38 |
# File 'lib/deltacloud/models/instance.rb', line 36 def password @password end |
#private_addresses ⇒ Object
Returns the value of attribute private_addresses.
30 31 32 |
# File 'lib/deltacloud/models/instance.rb', line 30 def private_addresses @private_addresses end |
#public_addresses ⇒ Object
Returns the value of attribute public_addresses.
29 30 31 |
# File 'lib/deltacloud/models/instance.rb', line 29 def public_addresses @public_addresses end |
#realm_id ⇒ Object
Returns the value of attribute realm_id.
26 27 28 |
# File 'lib/deltacloud/models/instance.rb', line 26 def realm_id @realm_id end |
#state ⇒ Object
Returns the value of attribute state.
27 28 29 |
# File 'lib/deltacloud/models/instance.rb', line 27 def state @state end |
#storage_volumes ⇒ Object
Returns the value of attribute storage_volumes.
39 40 41 |
# File 'lib/deltacloud/models/instance.rb', line 39 def storage_volumes @storage_volumes end |
#username ⇒ Object
Returns the value of attribute username.
35 36 37 |
# File 'lib/deltacloud/models/instance.rb', line 35 def username @username end |
Class Method Details
.convert_condor_state(state_id) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/deltacloud/drivers/condor/condor_driver.rb', line 18 def self.convert_condor_state(state_id) case state_id when 0,1,5 then 'PENDING' when 2 then 'RUNNING' when 3,4 then 'SHUTTING_DOWN' else raise "Unknown Condor state (#{state_id})" end end |
Instance Method Details
#authn_feature_failed? ⇒ Boolean
111 112 113 |
# File 'lib/deltacloud/models/instance.rb', line 111 def authn_feature_failed? return true unless authn_error.nil? end |
#can_create_image? ⇒ Boolean
84 85 86 |
# File 'lib/deltacloud/models/instance.rb', line 84 def can_create_image? self.create_image end |
#hardware_profile ⇒ Object
88 89 90 |
# File 'lib/deltacloud/models/instance.rb', line 88 def hardware_profile instance_profile end |
#hardware_profile=(profile) ⇒ Object
92 93 94 |
# File 'lib/deltacloud/models/instance.rb', line 92 def hardware_profile=(profile) @instance_profile = profile end |
#to_hash(context) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/deltacloud/models/instance.rb', line 41 def to_hash(context) r = { :id => self.id, :name => name, :state => state, :owner => owner_id, :image => { :href => context.image_url(image_id), :id => image_id, :rel => :image }, :realm => { :href => context.realm_url(realm_id), :id => realm_id, :rel => :realm }, :actions => actions.compact.map { |a| { :href => context.send("#{a}_instance_url", self.id), :rel => "#{a}", :method => context.instance_action_method(a) } }, :instance_profile => { :id => instance_profile.id, :href => context.hardware_profile_url(instance_profile.id), :rel => :hardware_profile, :properties => instance_profile.overrides }, :public_addresses => public_addresses.map { |addr| addr.to_hash(context) }, :private_addresses => private_addresses.map { |addr| addr.to_hash(context) } } r.merge!(:launch_time => launch_time) r.merge!(:create_image => create_image) if create_image r.merge!(:firewalls => firewalls.map { |f| { :id => f, :href => context.firewall_url(f), :rel => :firewall }}) if firewalls if storage_volumes r.merge!(:storage_volumes => storage_volumes.map { |v| { :id => v.keys.first, :href => context.storage_volume_url(v.keys.first), :rel => :storage_volume }}) end if context.driver.class.has_feature?(:instances, :authentication_key) r.merge!(:authentication => { :keyname => keyname }) if keyname end if context.driver.class.has_feature?(:instances, :authentication_password) r.merge!(:authentication => { :user => username, :password => password }) if username end r end |