deltacloud-core 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +40 -28
- data/bin/deltacloud-db-upgrade +24 -0
- data/bin/deltacloudd +20 -9
- data/config.ru +12 -53
- data/db/migrations/1_add_realm_to_machine_template.rb +23 -0
- data/deltacloud-core.gemspec +11 -5
- data/lib/cimi/collections.rb +4 -31
- data/lib/cimi/collections/address_templates.rb +2 -5
- data/lib/cimi/collections/addresses.rb +2 -5
- data/lib/cimi/collections/base.rb +18 -6
- data/lib/cimi/collections/credentials.rb +2 -5
- data/lib/cimi/collections/machine_images.rb +2 -1
- data/lib/cimi/collections/machine_templates.rb +2 -5
- data/lib/cimi/collections/machines.rb +6 -9
- data/lib/cimi/collections/network_ports.rb +3 -3
- data/lib/cimi/collections/networks.rb +5 -8
- data/lib/cimi/collections/system_templates.rb +72 -0
- data/lib/cimi/collections/systems.rb +194 -0
- data/lib/cimi/collections/volume_configurations.rb +1 -1
- data/lib/cimi/collections/volume_images.rb +2 -1
- data/lib/cimi/collections/volume_templates.rb +3 -2
- data/lib/cimi/collections/volumes.rb +2 -2
- data/lib/cimi/dependencies.rb +0 -2
- data/lib/cimi/helpers/cimi_helper.rb +12 -57
- data/lib/cimi/helpers/database_helper.rb +0 -4
- data/lib/cimi/models.rb +25 -14
- data/lib/cimi/models/address.rb +4 -31
- data/lib/cimi/models/address_create.rb +51 -0
- data/lib/cimi/models/address_template.rb +8 -52
- data/lib/cimi/models/address_template_create.rb +44 -0
- data/lib/cimi/models/base.rb +44 -6
- data/lib/cimi/models/cloud_entry_point.rb +1 -1
- data/lib/cimi/models/credential.rb +1 -1
- data/lib/cimi/models/credential_create.rb +46 -0
- data/lib/cimi/models/credential_template.rb +24 -0
- data/lib/cimi/models/machine.rb +1 -71
- data/lib/cimi/models/machine_configuration.rb +3 -3
- data/lib/cimi/models/machine_create.rb +49 -0
- data/lib/cimi/models/machine_image.rb +2 -25
- data/lib/cimi/models/machine_image_create.rb +41 -0
- data/lib/cimi/models/machine_template.rb +14 -34
- data/lib/cimi/models/machine_template_create.rb +33 -0
- data/lib/cimi/models/network.rb +0 -38
- data/lib/cimi/models/network_create.rb +43 -0
- data/lib/cimi/models/network_port.rb +17 -17
- data/lib/cimi/models/network_template.rb +2 -3
- data/lib/cimi/models/resource.rb +22 -3
- data/lib/cimi/models/schema.rb +94 -8
- data/lib/cimi/models/system.rb +67 -0
- data/lib/cimi/models/system_template.rb +63 -0
- data/lib/cimi/models/volume.rb +2 -42
- data/lib/cimi/models/volume_configuration.rb +4 -4
- data/lib/cimi/models/volume_create.rb +58 -0
- data/lib/cimi/models/volume_image.rb +8 -17
- data/lib/cimi/models/volume_image_create.rb +47 -0
- data/lib/cimi/models/volume_template.rb +6 -19
- data/lib/cimi/models/volume_template_create.rb +33 -0
- data/lib/db.rb +14 -22
- data/lib/db/volume_template.rb +1 -1
- data/lib/deltacloud/api.rb +6 -5
- data/lib/deltacloud/collections.rb +4 -27
- data/lib/deltacloud/collections/base.rb +4 -0
- data/lib/deltacloud/collections/images.rb +1 -1
- data/lib/deltacloud/collections/instances.rb +2 -2
- data/lib/deltacloud/core_ext/array.rb +1 -0
- data/lib/deltacloud/core_ext/integer.rb +13 -9
- data/lib/deltacloud/core_ext/string.rb +45 -28
- data/lib/deltacloud/drivers/arubacloud/arubacloud_driver.rb +0 -9
- data/lib/deltacloud/drivers/base_driver.rb +45 -16
- data/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb +78 -8
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +13 -9
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +44 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +164 -90
- data/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb +74 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +3 -3
- data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +3 -3
- data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +3 -3
- data/lib/deltacloud/drivers/mock/mock_client.rb +17 -1
- data/lib/deltacloud/drivers/mock/mock_driver.rb +161 -204
- data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +80 -0
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +6 -1
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +61 -68
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +0 -9
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +11 -6
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +0 -8
- data/lib/deltacloud/drivers/vsphere/vsphere_client.rb +11 -4
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +0 -12
- data/lib/deltacloud/helpers/collection_helper.rb +106 -0
- data/lib/deltacloud/helpers/deltacloud_helper.rb +12 -8
- data/lib/deltacloud/models/address.rb +19 -17
- data/lib/deltacloud/models/base_model.rb +29 -26
- data/lib/deltacloud/models/blob.rb +22 -20
- data/lib/deltacloud/models/bucket.rb +21 -16
- data/lib/deltacloud/models/firewall.rb +18 -16
- data/lib/deltacloud/models/firewall_rule.rb +22 -20
- data/lib/deltacloud/models/image.rb +29 -28
- data/lib/deltacloud/models/instance.rb +92 -94
- data/lib/deltacloud/models/instance_address.rb +42 -40
- data/lib/deltacloud/models/instance_profile.rb +28 -26
- data/lib/deltacloud/models/key.rb +47 -45
- data/lib/deltacloud/models/load_balancer.rb +32 -31
- data/lib/deltacloud/models/metric.rb +76 -29
- data/lib/deltacloud/models/provider.rb +15 -13
- data/lib/deltacloud/models/realm.rb +15 -21
- data/lib/deltacloud/models/storage_snapshot.rb +23 -19
- data/lib/deltacloud/models/storage_volume.rb +35 -34
- data/lib/deltacloud/version.rb +1 -1
- data/lib/deltacloud_rack.rb +22 -0
- data/lib/initialize.rb +28 -0
- data/lib/initializers/database_initialize.rb +76 -0
- data/lib/initializers/frontend_initialize.rb +42 -0
- data/lib/initializers/mock_initialize.rb +33 -0
- data/lib/sinatra/rack_logger.rb +35 -24
- data/tests/cimi/collections/cloud_entry_point_test.rb +1 -7
- data/tests/cimi/collections/machine_images_test.rb +2 -2
- data/tests/cimi/collections/machine_templates_test.rb +75 -0
- data/tests/cimi/collections/machines_test.rb +2 -2
- data/tests/cimi/collections/system_templates_test.rb +41 -0
- data/tests/cimi/collections/systems_test.rb +50 -0
- data/tests/cimi/db/database_helper_test.rb +17 -25
- data/tests/cimi/db/db_helper.rb +1 -12
- data/tests/cimi/db/entity_test.rb +7 -8
- data/tests/cimi/model/machine_create_spec.rb +44 -0
- data/tests/cimi/model/machine_template_spec.rb +29 -0
- data/tests/cimi/model/resource_spec.rb +40 -0
- data/tests/cimi/model/schema_spec.rb +37 -0
- data/tests/cimi/spec_helper.rb +3 -0
- data/tests/deltacloud/collections/buckets_collection_test.rb +1 -1
- data/tests/deltacloud/collections/drivers_collection_test.rb +2 -2
- data/tests/deltacloud/collections/hardware_profiles_collection_test.rb +2 -2
- data/tests/deltacloud/collections/images_collection_test.rb +2 -2
- data/tests/deltacloud/collections/instance_states_collection_test.rb +1 -1
- data/tests/deltacloud/collections/instances_collection_test.rb +6 -3
- data/tests/deltacloud/collections/keys_collection_test.rb +2 -2
- data/tests/deltacloud/collections/realms_collection_test.rb +2 -2
- data/tests/deltacloud/collections/storage_snapshots_collection_test.rb +2 -2
- data/tests/deltacloud/collections/storage_volumes_collection_test.rb +2 -2
- data/tests/deltacloud/collections_test.rb +5 -5
- data/tests/deltacloud/common.rb +2 -13
- data/tests/deltacloud/launcher_test.rb +3 -3
- data/tests/deltacloud/rack_test.rb +2 -2
- data/tests/deltacloud/server_test.rb +1 -1
- data/tests/drivers/base/base_driver_test.rb +5 -5
- data/tests/drivers/base/common.rb +2 -12
- data/tests/drivers/ec2/buckets_test.rb +1 -1
- data/tests/drivers/ec2/images_test.rb +2 -2
- data/tests/drivers/ec2/instance_test.rb +6 -6
- data/tests/drivers/ec2/keys_test.rb +3 -3
- data/tests/drivers/ec2/realms_test.rb +2 -2
- data/tests/drivers/ec2/storage_snapshots_test.rb +1 -1
- data/tests/drivers/fgcp/common.rb +32 -0
- data/tests/drivers/fgcp/firewall_test.rb +70 -0
- data/tests/drivers/fgcp/hardware_profiles_test.rb +61 -0
- data/tests/drivers/fgcp/images_test.rb +46 -0
- data/tests/drivers/fgcp/provider_test.rb +27 -0
- data/tests/drivers/fgcp/realms_test.rb +53 -0
- data/tests/drivers/fgcp/storage_volumes_test.rb +58 -0
- data/tests/drivers/gogrid/images_test.rb +2 -2
- data/tests/drivers/gogrid/instances_test.rb +2 -2
- data/tests/drivers/gogrid/realms_test.rb +2 -2
- data/tests/drivers/mock/images_test.rb +4 -4
- data/tests/drivers/mock/instances_test.rb +9 -9
- data/tests/drivers/mock/keys_test.rb +3 -3
- data/tests/drivers/mock/realms_test.rb +2 -2
- data/tests/drivers/mock/storage_snapshots_test.rb +2 -2
- data/tests/drivers/mock/storage_volumes_test.rb +4 -4
- data/tests/drivers/models/instance_test.rb +2 -2
- data/tests/drivers/openstack/images_test.rb +2 -2
- data/tests/drivers/openstack/instances_test.rb +2 -3
- data/tests/drivers/openstack/keys_test.rb +1 -1
- data/tests/drivers/openstack/realms_test.rb +2 -11
- data/tests/drivers/rhevm/common.rb +33 -12
- data/tests/drivers/rhevm/images_test.rb +20 -12
- data/tests/drivers/rhevm/instance_test.rb +62 -46
- data/tests/drivers/rhevm/provider_test.rb +12 -6
- data/tests/drivers/rhevm/realms_test.rb +15 -9
- data/tests/ec2/query_parser_test.rb +1 -1
- data/tests/test_helper.rb +68 -12
- data/views/addresses/show.html.haml +1 -1
- data/views/buckets/show.html.haml +1 -1
- data/views/errors/{500.html.haml → common.html.haml} +0 -0
- data/views/errors/common.xml.haml +17 -0
- data/views/firewalls/index.xml.haml +2 -2
- data/views/firewalls/new.html.haml +2 -2
- data/views/images/show.html.haml +1 -1
- data/views/instances/run_command.html.haml +1 -1
- data/views/instances/show.html.haml +3 -3
- data/views/keys/index.html.haml +1 -0
- data/views/keys/show.html.haml +8 -4
- data/views/keys/show.xml.haml +3 -2
- data/views/load_balancers/new.html.haml +1 -1
- data/views/load_balancers/show.html.haml +2 -2
- data/views/metrics/show.html.haml +1 -1
- data/views/realms/index.html.haml +0 -2
- data/views/realms/show.html.haml +0 -4
- data/views/realms/show.xml.haml +0 -3
- data/views/storage_snapshots/index.html.haml +1 -1
- data/views/storage_snapshots/new.html.haml +1 -1
- data/views/storage_volumes/new.html.haml +2 -2
- data/views/storage_volumes/show.html.haml +3 -3
- metadata +90 -41
- data/views/errors/400.html.haml +0 -41
- data/views/errors/400.xml.haml +0 -3
- data/views/errors/401.html.haml +0 -26
- data/views/errors/401.xml.haml +0 -3
- data/views/errors/403.html.haml +0 -42
- data/views/errors/403.xml.haml +0 -9
- data/views/errors/404.html.haml +0 -28
- data/views/errors/404.xml.haml +0 -3
- data/views/errors/405.html.haml +0 -29
- data/views/errors/405.xml.haml +0 -5
- data/views/errors/409.html.haml +0 -47
- data/views/errors/409.xml.haml +0 -11
- data/views/errors/500.xml.haml +0 -13
- data/views/errors/501.html.haml +0 -44
- data/views/errors/501.xml.haml +0 -1
- data/views/errors/502.html.haml +0 -44
- data/views/errors/502.xml.haml +0 -1
- data/views/errors/504.html.haml +0 -43
- data/views/errors/504.xml.haml +0 -1
@@ -14,37 +14,38 @@
|
|
14
14
|
# License for the specific language governing permissions and limitations
|
15
15
|
# under the License.
|
16
16
|
|
17
|
+
module Deltacloud
|
18
|
+
class Image < BaseModel
|
17
19
|
|
18
|
-
|
20
|
+
attr_accessor :name
|
21
|
+
attr_accessor :owner_id
|
22
|
+
attr_accessor :description
|
23
|
+
attr_accessor :architecture
|
24
|
+
attr_accessor :state
|
25
|
+
attr_accessor :hardware_profiles
|
26
|
+
attr_accessor :creation_time
|
27
|
+
attr_accessor :root_type
|
19
28
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
attr_accessor :architecture
|
24
|
-
attr_accessor :state
|
25
|
-
attr_accessor :hardware_profiles
|
26
|
-
attr_accessor :creation_time
|
27
|
-
attr_accessor :root_type
|
29
|
+
def root_type
|
30
|
+
@root_type || 'transient'
|
31
|
+
end
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
:creation_time => creation_time,
|
44
|
-
:hardware_profiles => hardware_profiles.map { |p|
|
45
|
-
{ :id => p.id, :href => context.hardware_profile_url(p.id), :rel => :hardware_profile }
|
33
|
+
def to_hash(context)
|
34
|
+
{
|
35
|
+
:id => self.id,
|
36
|
+
:href => context.image_url(self.id),
|
37
|
+
:name => name,
|
38
|
+
:description => description,
|
39
|
+
:owner => owner_id,
|
40
|
+
:architecture => architecture,
|
41
|
+
:state => state,
|
42
|
+
:root_type => root_type,
|
43
|
+
:creation_time => creation_time,
|
44
|
+
:hardware_profiles => hardware_profiles.map { |p|
|
45
|
+
{ :id => p.id, :href => context.hardware_profile_url(p.id), :rel => :hardware_profile }
|
46
|
+
}
|
46
47
|
}
|
47
|
-
|
48
|
-
end
|
48
|
+
end
|
49
49
|
|
50
|
+
end
|
50
51
|
end
|
@@ -14,111 +14,109 @@
|
|
14
14
|
# License for the specific language governing permissions and limitations
|
15
15
|
# under the License.
|
16
16
|
|
17
|
-
|
17
|
+
module Deltacloud
|
18
|
+
class Instance < BaseModel
|
18
19
|
|
19
|
-
|
20
|
+
attr_accessor :owner_id
|
21
|
+
attr_accessor :image_id
|
22
|
+
attr_accessor :name
|
23
|
+
attr_accessor :realm_id
|
24
|
+
attr_accessor :state
|
25
|
+
attr_accessor :actions
|
26
|
+
attr_accessor :public_addresses
|
27
|
+
attr_accessor :private_addresses
|
28
|
+
attr_accessor :instance_profile
|
29
|
+
attr_accessor :launch_time
|
30
|
+
attr_accessor :keyname
|
31
|
+
attr_accessor :authn_error
|
32
|
+
attr_accessor :username
|
33
|
+
attr_accessor :password
|
34
|
+
attr_accessor :create_image
|
35
|
+
attr_accessor :firewalls
|
36
|
+
attr_accessor :storage_volumes
|
20
37
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
r[:actions] << { :href => "#{context.run_instance_url(self.id)};id=#{self.id}", :rel => 'run', :method => 'post'}
|
68
|
-
end
|
69
|
-
if can_create_image?
|
70
|
-
r[:actions] << { :href => "#{context.create_image_url};instance_id=#{self.id}", :rel => 'create_image', :method => 'post'}
|
71
|
-
end
|
72
|
-
r.merge!(:create_time => launch_time) if launch_time
|
73
|
-
r.merge!(:create_image => create_image) if create_image
|
74
|
-
r.merge!(:firewalls => firewalls.map { |f| { :id => f, :href => context.firewall_url(f), :rel => :firewall }}) if firewalls
|
75
|
-
if storage_volumes
|
76
|
-
r.merge!(:storage_volumes => storage_volumes.map { |v| { :id => v.keys.first, :href => context.storage_volume_url(v.keys.first), :rel => :storage_volume }})
|
77
|
-
end
|
78
|
-
if context.driver.class.has_feature?(:instances, :authentication_key)
|
79
|
-
r.merge!(:authentication_type => 'key' )
|
80
|
-
r.merge!(:authentication => { :keyname => keyname }) if keyname
|
38
|
+
def to_hash(context)
|
39
|
+
r = {
|
40
|
+
:id => self.id,
|
41
|
+
:href => context.instance_url(self.id),
|
42
|
+
:name => name,
|
43
|
+
:state => state,
|
44
|
+
:owner => owner_id,
|
45
|
+
:image => { :href => context.image_url(image_id), :id => image_id, :rel => :image },
|
46
|
+
:realm => { :href => context.realm_url(realm_id), :id => realm_id, :rel => :realm },
|
47
|
+
:actions => actions.compact.map { |a|
|
48
|
+
{
|
49
|
+
:href => context.send("#{a}_instance_url", self.id),
|
50
|
+
:rel => "#{a}",
|
51
|
+
:method => context.instance_action_method(a)
|
52
|
+
}
|
53
|
+
},
|
54
|
+
:hardware_profile => {
|
55
|
+
:id => instance_profile.id,
|
56
|
+
:href => context.hardware_profile_url(instance_profile.id),
|
57
|
+
:rel => :hardware_profile,
|
58
|
+
:properties => instance_profile.overrides
|
59
|
+
},
|
60
|
+
:public_addresses => public_addresses.map { |addr| addr.to_hash(context) },
|
61
|
+
:private_addresses => private_addresses.map { |addr| addr.to_hash(context) }
|
62
|
+
}
|
63
|
+
if context.driver.respond_to? :run_on_instance
|
64
|
+
r[:actions] << { :href => "#{context.run_instance_url(self.id)};id=#{self.id}", :rel => 'run', :method => 'post'}
|
65
|
+
end
|
66
|
+
if can_create_image?
|
67
|
+
r[:actions] << { :href => "#{context.create_image_url};instance_id=#{self.id}", :rel => 'create_image', :method => 'post'}
|
68
|
+
end
|
69
|
+
r.merge!(:create_time => launch_time) if launch_time
|
70
|
+
r.merge!(:create_image => create_image) if create_image
|
71
|
+
r.merge!(:firewalls => firewalls.map { |f| { :id => f, :href => context.firewall_url(f), :rel => :firewall }}) if firewalls
|
72
|
+
if storage_volumes
|
73
|
+
r.merge!(:storage_volumes => storage_volumes.map { |v| { :id => v.keys.first, :href => context.storage_volume_url(v.keys.first), :rel => :storage_volume }})
|
74
|
+
end
|
75
|
+
if context.driver.class.has_feature?(:instances, :authentication_key)
|
76
|
+
r.merge!(:authentication_type => 'key' )
|
77
|
+
r.merge!(:authentication => { :keyname => keyname }) if keyname
|
78
|
+
end
|
79
|
+
if context.driver.class.has_feature?(:instances, :authentication_password)
|
80
|
+
r[:authentication] && username ? r[:authentication].merge!({ :user => username, :password => password }) :
|
81
|
+
(username ? r.merge!(:authentication => { :user => username, :password => password }) : nil)
|
82
|
+
end
|
83
|
+
r
|
81
84
|
end
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
+
|
86
|
+
def storage_volumes
|
87
|
+
@storage_volumes || []
|
85
88
|
end
|
86
|
-
r
|
87
|
-
end
|
88
89
|
|
89
|
-
|
90
|
-
|
91
|
-
|
90
|
+
def can_create_image?
|
91
|
+
self.create_image
|
92
|
+
end
|
92
93
|
|
93
|
-
|
94
|
-
|
95
|
-
|
94
|
+
def hardware_profile
|
95
|
+
instance_profile
|
96
|
+
end
|
96
97
|
|
97
|
-
|
98
|
-
|
99
|
-
|
98
|
+
def hardware_profile=(profile)
|
99
|
+
@instance_profile = profile
|
100
|
+
end
|
100
101
|
|
101
|
-
|
102
|
-
|
103
|
-
|
102
|
+
def initialize(init=nil)
|
103
|
+
super(init)
|
104
|
+
self.actions = [] if self.actions.nil?
|
105
|
+
self.public_addresses = [] if self.public_addresses.nil?
|
106
|
+
self.private_addresses = [] if self.private_addresses.nil?
|
107
|
+
end
|
104
108
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
109
|
+
def method_missing(name, *args)
|
110
|
+
if name.to_s =~ /is_(\w+)\?/
|
111
|
+
self.state.downcase.eql?($1)
|
112
|
+
else
|
113
|
+
raise NoMethodError.new(name.to_s)
|
114
|
+
end
|
115
|
+
end
|
111
116
|
|
112
|
-
|
113
|
-
|
114
|
-
self.state.downcase.eql?($1)
|
115
|
-
else
|
116
|
-
raise NoMethodError.new(name.to_s)
|
117
|
+
def authn_feature_failed?
|
118
|
+
return true unless authn_error.nil?
|
117
119
|
end
|
118
|
-
end
|
119
120
|
|
120
|
-
def authn_feature_failed?
|
121
|
-
return true unless authn_error.nil?
|
122
121
|
end
|
123
|
-
|
124
122
|
end
|
@@ -16,54 +16,56 @@
|
|
16
16
|
# Model to store the hardware profile applied to an instance together with
|
17
17
|
# any instance-specific overrides
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
module Deltacloud
|
20
|
+
class InstanceAddress
|
21
|
+
attr_accessor :address
|
22
|
+
attr_accessor :port
|
23
|
+
attr_accessor :address_type
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
def initialize(address, opts={})
|
26
|
+
self.address = address
|
27
|
+
self.port = opts[:port] if opts[:port]
|
28
|
+
self.address_type = opts[:type] || :ipv4
|
29
|
+
self
|
30
|
+
end
|
30
31
|
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
def address_type
|
33
|
+
(address and !address.strip.empty?) ? @address_type : :unavailable
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
def to_s
|
37
|
+
return ['VNC', address, port].join(':') if is_vnc?
|
38
|
+
address
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
41
|
+
def to_hash(context)
|
42
|
+
r = {
|
43
|
+
:address => address,
|
44
|
+
:type => address_type
|
45
|
+
}
|
46
|
+
r.merge!(:port => port) if !port.nil?
|
47
|
+
r
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
def is_mac?
|
51
|
+
address_type == :mac
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
def is_ipv4?
|
55
|
+
address_type == :ipv4
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
def is_ipv6?
|
59
|
+
address_type == :ipv6
|
60
|
+
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
62
|
+
def is_hostname?
|
63
|
+
address_type == :hostname
|
64
|
+
end
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
66
|
+
def is_vnc?
|
67
|
+
address_type == :vnc
|
68
|
+
end
|
68
69
|
|
70
|
+
end
|
69
71
|
end
|
@@ -17,39 +17,41 @@
|
|
17
17
|
# Model to store the hardware profile applied to an instance together with
|
18
18
|
# any instance-specific overrides
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
module Deltacloud
|
21
|
+
class InstanceProfile < BaseModel
|
22
|
+
attr_accessor :memory
|
23
|
+
attr_accessor :storage
|
24
|
+
attr_accessor :architecture
|
25
|
+
attr_accessor :cpu
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
27
|
+
def initialize(hwp_name, args = {})
|
28
|
+
opts = args.inject({ :id => hwp_name.to_s }) do |m, e|
|
29
|
+
k, v = e
|
30
|
+
m[$1] = v if k.to_s =~ /^hwp_(.*)$/
|
31
|
+
m
|
32
|
+
end
|
33
|
+
super(opts)
|
31
34
|
end
|
32
|
-
super(opts)
|
33
|
-
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
36
|
+
def name
|
37
|
+
id
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
40
|
+
def to_s
|
41
|
+
name
|
42
|
+
end
|
42
43
|
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
def override?(property)
|
45
|
+
overrides.find { |p, v| p == property }
|
46
|
+
end
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
def overrides
|
49
|
+
[:memory, :storage, :architecture, :cpu].inject({}) do |h, p|
|
50
|
+
if v = instance_variable_get("@#{p}")
|
51
|
+
h[p] = v
|
52
|
+
end
|
53
|
+
h
|
51
54
|
end
|
52
|
-
h
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
@@ -14,57 +14,59 @@
|
|
14
14
|
# License for the specific language governing permissions and limitations
|
15
15
|
# under the License.
|
16
16
|
|
17
|
-
|
17
|
+
module Deltacloud
|
18
|
+
class Key < BaseModel
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
attr_accessor :credential_type
|
21
|
+
attr_accessor :fingerprint
|
22
|
+
attr_accessor :username
|
23
|
+
attr_accessor :password
|
24
|
+
attr_accessor :pem_rsa_key
|
25
|
+
attr_accessor :state
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
def name
|
28
|
+
super || @id
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
def is_password?
|
32
|
+
@credential_type.eql?(:password)
|
33
|
+
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
35
|
+
def is_key?
|
36
|
+
@credential_type.eql?(:key)
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
# Mock fingerprint generator
|
40
|
+
# 1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f
|
41
|
+
def self.generate_mock_fingerprint
|
42
|
+
(0..19).map { "%02x" % (rand * 0xff) }.join(':')
|
43
|
+
end
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
45
|
+
# Mock PEM file
|
46
|
+
# NOTE: This is a fake PEM file, it will not work against SSH
|
47
|
+
def self.generate_mock_pem
|
48
|
+
chars = (('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a + %w(= / + ))
|
49
|
+
pem_material = (1..21).map do
|
50
|
+
(1..75).collect{|a| chars[rand(chars.size)] }.join
|
51
|
+
end.join("\n") + "\n" + (1..68).collect{|a| chars[rand(chars.size)] }.join
|
52
|
+
"-----BEGIN RSA PRIVATE KEY-----\n"+pem_material+"-----END RSA PRIVATE KEY-----"
|
53
|
+
end
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
55
|
+
def to_hash(context)
|
56
|
+
r = {
|
57
|
+
:id => self.id,
|
58
|
+
:href => context.key_url(self.id),
|
59
|
+
:credential_type => credential_type,
|
60
|
+
:username => username,
|
61
|
+
:password => password,
|
62
|
+
:state => state
|
63
|
+
}
|
64
|
+
r[:pem_rsa_key] = pem_rsa_key if pem_rsa_key
|
65
|
+
r[:fingerprint] = fingerprint if fingerprint
|
66
|
+
r[:username] = username if username
|
67
|
+
r[:password] = password if password
|
68
|
+
r
|
69
|
+
end
|
69
70
|
|
71
|
+
end
|
70
72
|
end
|