Class: Fog::AWS::EC2::Instance
- Inherits:
-
Model
- Object
- Model
- Fog::AWS::EC2::Instance
show all
- Defined in:
- lib/fog/aws/models/ec2/instance.rb
Instance Attribute Summary
Attributes inherited from Model
#connection
Instance Method Summary
collapse
Methods inherited from Model
#_dump, _load, aliases, attribute, attributes, #attributes, #collection, identity, #identity, #initialize, #inspect, #merge_attributes, #new_record?, #reload, #requires, #wait_for
Constructor Details
This class inherits a constructor from Fog::Model
Instance Method Details
#addresses ⇒ Object
26
27
28
29
30
|
# File 'lib/fog/aws/models/ec2/instance.rb', line 26
def addresses
requires :id
connection.addresses(:instance => self)
end
|
#destroy ⇒ Object
32
33
34
35
36
37
|
# File 'lib/fog/aws/models/ec2/instance.rb', line 32
def destroy
requires :id
connection.terminate_instances(@id)
true
end
|
#key_pair ⇒ Object
def security_group
connection.security_groups.all(@group_id)
end
def security_group=(new_security_group)
@group_id = new_security_group.name
end
47
48
49
50
51
|
# File 'lib/fog/aws/models/ec2/instance.rb', line 47
def key_pair
requires :key_name
connection.keypairs.all(@key_name).first
end
|
#key_pair=(new_keypair) ⇒ Object
53
54
55
|
# File 'lib/fog/aws/models/ec2/instance.rb', line 53
def key_pair=(new_keypair)
@key_name = new_keypair.name
end
|
#monitoring=(new_monitoring) ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/fog/aws/models/ec2/instance.rb', line 57
def monitoring=(new_monitoring)
if new_monitoring.is_a?(Hash)
@monitoring = new_monitoring['state']
else
@monitoring = new_monitoring
end
end
|
#placement=(new_placement) ⇒ Object
65
66
67
68
69
70
71
|
# File 'lib/fog/aws/models/ec2/instance.rb', line 65
def placement=(new_placement)
if new_placement.is_a?(Hash)
@availability_zone = new_placement['availabilityZone']
else
@availability_zone = new_placement
end
end
|
#reboot ⇒ Object
73
74
75
76
77
78
|
# File 'lib/fog/aws/models/ec2/instance.rb', line 73
def reboot
requires :id
connection.reboot_instances(@id)
true
end
|
#save ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/fog/aws/models/ec2/instance.rb', line 80
def save
requires :image_id
options = {}
if @availability_zone
options['Placement.AvailabilityZone'] = @availability_zone
end
if @group_id
options['SecurityGroup'] = @group_id
end
if @type
options['InstanceType'] = @type
end
if @kernel_id
options['KernelId'] = @kernel_id
end
if @key_name
options['KeyName'] = @key_name
end
if @monitoring
options['Monitoring.Enabled'] = @monitoring
end
if @ramdisk_id
options['RamdiskId'] = @ramdisk_id
end
if @user_data
options['UserData'] = @user_data
end
data = connection.run_instances(@image_id, 1, 1, options)
merge_attributes(data.body['instancesSet'].first)
true
end
|
#volumes ⇒ Object
113
114
115
116
117
|
# File 'lib/fog/aws/models/ec2/instance.rb', line 113
def volumes
requires :id
connection.volumes(:instance => self)
end
|