deltacloud-core 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +23 -0
- data/NOTICE +3 -0
- data/Rakefile +32 -20
- data/bin/deltacloudd +1 -1
- data/config.ru +25 -32
- data/deltacloud-core.gemspec +1 -1
- data/lib/cimi/collections.rb +4 -1
- data/lib/cimi/collections/address_templates.rb +2 -2
- data/lib/cimi/collections/addresses.rb +1 -1
- data/lib/cimi/collections/base.rb +64 -0
- data/lib/cimi/collections/{machine_admins.rb → credentials.rb} +12 -12
- data/lib/cimi/collections/{vsp_templates.rb → forwarding_group_templates.rb} +12 -16
- data/lib/cimi/collections/{vsp_configurations.rb → forwarding_groups.rb} +12 -13
- data/lib/cimi/collections/machine_configurations.rb +2 -2
- data/lib/cimi/collections/machine_images.rb +1 -1
- data/lib/cimi/collections/machines.rb +8 -2
- data/lib/cimi/collections/network_configurations.rb +2 -2
- data/lib/cimi/collections/{routing_groups.rb → network_port_configurations.rb} +12 -12
- data/lib/cimi/collections/{routing_group_templates.rb → network_port_templates.rb} +15 -12
- data/lib/cimi/collections/{vsps.rb → network_ports.rb} +33 -32
- data/lib/cimi/collections/network_templates.rb +2 -2
- data/lib/cimi/collections/networks.rb +17 -2
- data/lib/cimi/collections/{entity_metadata.rb → resource_metadata.rb} +10 -10
- data/lib/cimi/collections/volume_configurations.rb +1 -1
- data/lib/cimi/collections/volume_images.rb +1 -1
- data/lib/cimi/collections/volumes.rb +1 -2
- data/lib/cimi/dependencies.rb +1 -1
- data/lib/cimi/helpers.rb +3 -84
- data/lib/cimi/helpers/cimi_helper.rb +15 -14
- data/lib/cimi/models.rb +20 -36
- data/lib/cimi/models/address.rb +32 -4
- data/lib/cimi/models/address_template.rb +2 -2
- data/lib/cimi/models/base.rb +24 -5
- data/lib/cimi/models/cloud_entry_point.rb +4 -9
- data/lib/cimi/models/collection.rb +101 -0
- data/lib/cimi/models/{machine_admin.rb → credential.rb} +6 -4
- data/lib/cimi/models/disk_collection.rb +1 -2
- data/lib/cimi/models/{routing_group_template.rb → forwarding_group.rb} +5 -3
- data/lib/cimi/models/{routing_group.rb → forwarding_group_template.rb} +5 -3
- data/lib/cimi/models/machine.rb +9 -7
- data/lib/cimi/models/machine_configuration.rb +2 -0
- data/lib/cimi/models/machine_image.rb +2 -0
- data/lib/cimi/models/machine_template.rb +3 -1
- data/lib/cimi/models/machine_volume_collection.rb +1 -1
- data/lib/cimi/models/network.rb +2 -0
- data/lib/cimi/models/network_configuration.rb +4 -8
- data/lib/cimi/models/{vsp.rb → network_port.rb} +7 -11
- data/lib/cimi/models/{network_configuration_collection.rb → network_port_collection.rb} +25 -8
- data/lib/cimi/models/{vsp_configuration.rb → network_port_configuration.rb} +6 -10
- data/lib/cimi/models/{network_collection.rb → network_port_configuration_collection.rb} +9 -9
- data/lib/cimi/models/{vsp_template.rb → network_port_template.rb} +6 -4
- data/lib/cimi/models/{network_template_collection.rb → network_port_template_collection.rb} +10 -8
- data/lib/cimi/models/network_template.rb +3 -1
- data/lib/cimi/models/{entity_metadata.rb → resource_metadata.rb} +16 -15
- data/lib/cimi/models/schema.rb +23 -12
- data/lib/cimi/models/volume.rb +2 -0
- data/lib/cimi/models/volume_configuration.rb +2 -0
- data/lib/cimi/models/volume_image.rb +2 -0
- data/lib/cimi/models/volume_template.rb +2 -0
- data/lib/cimi/server.rb +10 -6
- data/lib/deltacloud/collections.rb +7 -2
- data/lib/deltacloud/collections/addresses.rb +3 -1
- data/lib/deltacloud/collections/base.rb +64 -0
- data/lib/deltacloud/collections/buckets.rb +14 -4
- data/lib/deltacloud/collections/drivers.rb +1 -1
- data/lib/deltacloud/collections/firewalls.rb +1 -1
- data/lib/deltacloud/collections/instances.rb +5 -1
- data/lib/deltacloud/collections/keys.rb +1 -1
- data/lib/deltacloud/collections/load_balancers.rb +2 -0
- data/lib/deltacloud/collections/storage_volumes.rb +3 -5
- data/lib/deltacloud/core_ext.rb +1 -0
- data/lib/deltacloud/core_ext/hash.rb +8 -0
- data/lib/deltacloud/core_ext/ordered_hash.rb +222 -0
- data/lib/deltacloud/core_ext/string.rb +9 -0
- data/lib/deltacloud/drivers/aruba/aruba_driver.rb +0 -9
- data/lib/deltacloud/drivers/base_driver.rb +22 -4
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +0 -4
- data/lib/deltacloud/drivers/exceptions.rb +30 -13
- data/lib/deltacloud/drivers/features.rb +7 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +1 -9
- data/lib/deltacloud/drivers/google/google_driver.rb +13 -0
- data/lib/deltacloud/drivers/mock/data/addresses/192.168.0.1.yml +3 -0
- data/lib/deltacloud/drivers/mock/data/addresses/192.168.0.2.yml +3 -0
- data/lib/deltacloud/drivers/mock/data/addresses/192.168.0.3.yml +3 -0
- data/lib/deltacloud/drivers/mock/data/addresses/192.168.0.4.yml +3 -0
- data/lib/deltacloud/drivers/mock/mock_driver.rb +65 -1
- data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +55 -32
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +18 -6
- data/lib/deltacloud/helpers.rb +0 -75
- data/lib/deltacloud/helpers/deltacloud_helper.rb +66 -28
- data/lib/deltacloud/helpers/driver_helper.rb +7 -0
- data/lib/deltacloud/helpers/rabbit_helper.rb +51 -0
- data/lib/deltacloud/server.rb +12 -14
- data/lib/deltacloud/version.rb +1 -1
- data/lib/deltacloud_rack.rb +26 -2
- data/lib/ec2/query_parser.rb +18 -3
- data/lib/sinatra/rack_accept.rb +7 -2
- data/lib/sinatra/rack_matrix_params.rb +14 -14
- data/public/javascripts/cmwgapp.js +2 -2
- data/tests/cimi/collections/cloud_entry_point_test.rb +3 -3
- data/tests/cimi/collections/machine_images_test.rb +2 -2
- data/tests/cimi/collections/machines_test.rb +1 -1
- data/tests/cimi/collections/url_helper_test.rb +31 -0
- data/tests/cimi/spec/cimi/model/{machine_admin_spec.rb → credential_spec.rb} +4 -4
- data/tests/deltacloud/base_collection_test.rb +0 -5
- data/tests/deltacloud/collections/buckets_collection_test.rb +1 -1
- data/tests/deltacloud/collections/drivers_collection_test.rb +1 -1
- data/tests/deltacloud/collections/hardware_profiles_collection_test.rb +1 -1
- data/tests/deltacloud/collections/images_collection_test.rb +1 -1
- data/tests/deltacloud/collections/instance_states_collection_test.rb +1 -1
- data/tests/deltacloud/collections/instances_collection_test.rb +1 -1
- data/tests/deltacloud/collections/keys_collection_test.rb +1 -4
- data/tests/deltacloud/deltacloud_helper_test.rb +0 -9
- data/tests/deltacloud/server_test.rb +1 -1
- data/tests/drivers/base/base_driver_test.rb +30 -0
- data/tests/drivers/base/common.rb +14 -0
- data/tests/drivers/base/exceptions_test.rb +64 -0
- data/tests/drivers/ec2/buckets_test.rb +45 -0
- data/tests/drivers/ec2/keys_test.rb +1 -1
- data/tests/drivers/google/buckets_test.rb +2 -2
- data/tests/drivers/google/common.rb +3 -3
- data/tests/test_helper.rb +28 -0
- data/views/api/show.html.haml +2 -2
- data/views/api/show.xml.haml +1 -1
- data/views/buckets/index.html.haml +1 -1
- data/views/cimi/cloudEntryPoint/index.xml.haml +1 -1
- data/views/cimi/collection/index.html.haml +3 -3
- data/views/cimi/collection/response.xml.haml +1 -1
- data/views/cimi/error.html.haml +1 -1
- data/views/cimi/errors/500.xml.haml +1 -1
- data/views/cimi/layout.html.haml +1 -1
- data/views/cimi/machine_configurations/show.html.haml +2 -2
- data/views/cimi/machine_configurations/show.xml.haml +1 -1
- data/views/cimi/machine_images/show.html.haml +2 -2
- data/views/cimi/machine_images/show.xml.haml +1 -1
- data/views/cimi/machines/show.html.haml +2 -2
- data/views/cimi/machines/show.xml.haml +1 -1
- data/views/cimi/volumes/show.html.haml +2 -2
- data/views/cimi/volumes/show.xml.haml +1 -1
- data/views/docs/collection.html.haml +1 -1
- data/views/docs/collection.xml.haml +2 -2
- data/views/docs/index.html.haml +1 -1
- data/views/docs/index.xml.haml +1 -1
- data/views/docs/operation.xml.haml +1 -1
- data/views/error.html.haml +1 -1
- data/views/errors/500.html.haml +7 -4
- data/views/firewalls/index.html.haml +1 -1
- data/views/firewalls/show.html.haml +1 -1
- data/views/images/show.html.haml +2 -2
- data/views/index.html.haml +9 -0
- data/views/instance_states/show.html.haml +1 -1
- data/views/instances/run_command.html.haml +1 -1
- data/views/instances/show.html.haml +2 -2
- data/views/keys/index.html.haml +1 -1
- data/views/layout.html.haml +1 -1
- data/views/load_balancers/index.html.haml +1 -1
- data/views/load_balancers/show.html.haml +3 -3
- data/views/storage_snapshots/show.html.haml +1 -1
- data/views/storage_volumes/attach.html.haml +1 -1
- data/views/storage_volumes/index.html.haml +1 -1
- data/views/storage_volumes/show.html.haml +4 -4
- metadata +40 -43
- data/lib/cimi/models/address_collection.rb +0 -34
- data/lib/cimi/models/address_template_collection.rb +0 -34
- data/lib/cimi/models/entity_metadata_collection.rb +0 -31
- data/lib/cimi/models/machine_admin_collection.rb +0 -34
- data/lib/cimi/models/machine_collection.rb +0 -37
- data/lib/cimi/models/machine_configuration_collection.rb +0 -36
- data/lib/cimi/models/machine_image_collection.rb +0 -36
- data/lib/cimi/models/machine_template_collection.rb +0 -36
- data/lib/cimi/models/routing_group_collection.rb +0 -34
- data/lib/cimi/models/routing_group_template_collection.rb +0 -35
- data/lib/cimi/models/volume_collection.rb +0 -36
- data/lib/cimi/models/volume_configuration_collection.rb +0 -36
- data/lib/cimi/models/volume_image_collection.rb +0 -36
- data/lib/cimi/models/volume_template_collection.rb +0 -36
- data/lib/cimi/models/vsp_collection.rb +0 -34
- data/lib/cimi/models/vsp_configuration_collection.rb +0 -34
- data/lib/cimi/models/vsp_template_collection.rb +0 -34
- data/lib/deltacloud/helpers/url_helper.rb +0 -115
@@ -24,7 +24,7 @@ module CIMI::Collections
|
|
24
24
|
description "Get list all VolumeConfigurations"
|
25
25
|
param :CIMISelect, :string, :optional
|
26
26
|
control do
|
27
|
-
volume_configuration =
|
27
|
+
volume_configuration = VolumeConfiguration.list(self).filter_by(params[:CIMISelect])
|
28
28
|
respond_to do |format|
|
29
29
|
format.xml { volume_configuration.to_xml }
|
30
30
|
format.json { volume_configuration.to_json }
|
@@ -25,7 +25,7 @@ module CIMI::Collections
|
|
25
25
|
description "List all volumes images"
|
26
26
|
param :CIMISelect, :string, :optional
|
27
27
|
control do
|
28
|
-
volume_images =
|
28
|
+
volume_images = VolumeImage.list(self).filter_by(params[:CIMISelect])
|
29
29
|
respond_to do |format|
|
30
30
|
format.xml { volume_images.to_xml }
|
31
31
|
format.json { volume_images.to_json }
|
@@ -24,7 +24,7 @@ module CIMI::Collections
|
|
24
24
|
description "List all volumes"
|
25
25
|
param :CIMISelect, :string, :optional
|
26
26
|
control do
|
27
|
-
volumes =
|
27
|
+
volumes = Volume.list(self).filter_by(params[:CIMISelect])
|
28
28
|
respond_to do |format|
|
29
29
|
format.xml { volumes.to_xml }
|
30
30
|
format.json { volumes.to_json }
|
@@ -67,7 +67,6 @@ module CIMI::Collections
|
|
67
67
|
|
68
68
|
operation :destroy do
|
69
69
|
description "Delete a specified Volume"
|
70
|
-
param :id, :string, :required
|
71
70
|
control do
|
72
71
|
Volume.delete!(params[:id], self)
|
73
72
|
no_content_with_status(200)
|
data/lib/cimi/dependencies.rb
CHANGED
data/lib/cimi/helpers.rb
CHANGED
@@ -13,104 +13,23 @@
|
|
13
13
|
# License for the specific language governing permissions and limitations
|
14
14
|
# under the License.
|
15
15
|
|
16
|
-
module Deltacloud; end
|
17
|
-
module CIMI; end
|
18
|
-
|
19
16
|
require_relative '../deltacloud/drivers/features'
|
20
17
|
|
21
|
-
# Declare namespace for CIMI models
|
22
|
-
#
|
23
|
-
|
24
18
|
module CIMI
|
25
19
|
module Model; end
|
26
|
-
|
27
20
|
class FakeCollection
|
28
21
|
extend Sinatra::Rabbit::Features
|
29
22
|
include Deltacloud::Features
|
30
23
|
end
|
31
24
|
end
|
32
25
|
|
26
|
+
# Declare namespace for CIMI models
|
27
|
+
#
|
28
|
+
|
33
29
|
require_relative '../deltacloud/drivers'
|
34
30
|
require_relative '../deltacloud/models'
|
35
31
|
require_relative '../deltacloud/helpers/driver_helper'
|
36
32
|
require_relative '../deltacloud/helpers/auth_helper'
|
37
|
-
require_relative '../deltacloud/helpers/url_helper'
|
38
33
|
require_relative '../deltacloud/helpers/deltacloud_helper'
|
39
34
|
require_relative '../deltacloud/helpers/rabbit_helper'
|
40
35
|
require_relative './helpers/cimi_helper'
|
41
|
-
require_relative './models'
|
42
|
-
|
43
|
-
module CIMI::Collections
|
44
|
-
class Base < Sinatra::Base
|
45
|
-
|
46
|
-
include Sinatra::Rabbit
|
47
|
-
extend Deltacloud::Helpers::Drivers
|
48
|
-
include Sinatra::Rabbit::Features
|
49
|
-
include CIMI::Model
|
50
|
-
|
51
|
-
helpers Deltacloud::Helpers::Drivers
|
52
|
-
helpers Sinatra::AuthHelper
|
53
|
-
helpers Sinatra::UrlForHelper
|
54
|
-
helpers Rack::RespondTo::Helpers
|
55
|
-
helpers Deltacloud::Helpers::Application
|
56
|
-
helpers CIMIHelper
|
57
|
-
|
58
|
-
register Rack::RespondTo
|
59
|
-
|
60
|
-
enable :xhtml
|
61
|
-
enable :dump_errors
|
62
|
-
enable :show_errors
|
63
|
-
disable :show_exceptions
|
64
|
-
|
65
|
-
set :config, Deltacloud[:cimi]
|
66
|
-
set :root_url, config.root_url
|
67
|
-
set :root_path, config.root_url
|
68
|
-
set :version, config.version
|
69
|
-
set :root, File.join(File.dirname(__FILE__), '..', '..')
|
70
|
-
set :views, root + '/views/cimi'
|
71
|
-
set :public_folder, root + '/public'
|
72
|
-
|
73
|
-
Sinatra::Rabbit.set :root_path, "#{config.root_url}/"
|
74
|
-
|
75
|
-
error do
|
76
|
-
report_error
|
77
|
-
end
|
78
|
-
|
79
|
-
error Deltacloud::ExceptionHandler::ValidationFailure do
|
80
|
-
report_error
|
81
|
-
end
|
82
|
-
|
83
|
-
before do
|
84
|
-
# Respond with 400, If we don't get a http Host header,
|
85
|
-
halt 400, "Unable to find HTTP Host header" if @env['HTTP_HOST'] == nil
|
86
|
-
end
|
87
|
-
|
88
|
-
after do
|
89
|
-
headers 'CIMI-Specification-Version' => Deltacloud[:cimi].version
|
90
|
-
end
|
91
|
-
|
92
|
-
def self.new_route_for(route, &block)
|
93
|
-
get route_for('/' + route.to_s + '/new') do
|
94
|
-
instance_eval(&block) if block_given?
|
95
|
-
respond_to do |format|
|
96
|
-
format.html do
|
97
|
-
haml :"#{route}/new"
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
def self.check_capability(opts={})
|
104
|
-
Sinatra::Rabbit.set :check_capability, opts[:for]
|
105
|
-
end
|
106
|
-
|
107
|
-
def self.check_features(opts={})
|
108
|
-
Sinatra::Rabbit.set :check_features, opts[:for]
|
109
|
-
end
|
110
|
-
|
111
|
-
def self.route_for(url)
|
112
|
-
"#{settings.root_url}#{url}"
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
end
|
@@ -13,36 +13,38 @@
|
|
13
13
|
# License for the specific language governing permissions and limitations
|
14
14
|
# under the License.
|
15
15
|
|
16
|
-
module
|
16
|
+
module CIMI
|
17
|
+
module Helper
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
def no_content_with_status(code=200)
|
20
|
+
body ''
|
21
|
+
status code
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
def href_id(href, entity)
|
25
|
+
split_on = self.send(:"#{entity.to_s}_url")
|
26
|
+
href.split("#{split_on}/").last
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
def to_kibibyte(value, unit)
|
30
|
+
case unit
|
30
31
|
when "GB"
|
31
32
|
value*1024*1024
|
32
33
|
when "MB"
|
33
34
|
value*1024
|
34
35
|
else
|
35
36
|
nil # should probably be exploding something here...
|
37
|
+
end
|
36
38
|
end
|
37
|
-
end
|
38
39
|
|
40
|
+
end
|
39
41
|
end
|
40
42
|
|
41
43
|
class Array
|
42
44
|
def to_xml_cimi_collection(_self)
|
43
45
|
model_name = first.class.xml_tag_name
|
44
46
|
XmlSimple.xml_out({
|
45
|
-
"xmlns" => "http://
|
47
|
+
"xmlns" => "http://schemas.dmtf.org/cimi/1",
|
46
48
|
"uri" => [ _self.send(:"#{model_name.underscore.pluralize}_url") ],
|
47
49
|
"name" => [ "default" ],
|
48
50
|
"created" => [ Time.now.to_s ],
|
@@ -61,4 +63,3 @@ class Array
|
|
61
63
|
end
|
62
64
|
|
63
65
|
end
|
64
|
-
|
data/lib/cimi/models.rb
CHANGED
@@ -21,50 +21,34 @@ require 'require_relative' if RUBY_VERSION < '1.9'
|
|
21
21
|
|
22
22
|
require_relative './models/schema'
|
23
23
|
require_relative './models/base'
|
24
|
+
require_relative './models/collection'
|
24
25
|
require_relative './models/errors'
|
25
|
-
require_relative './models/
|
26
|
-
require_relative './models/
|
26
|
+
require_relative './models/action'
|
27
|
+
require_relative './models/disk'
|
28
|
+
require_relative './models/disk_collection'
|
29
|
+
require_relative './models/machine_volume'
|
30
|
+
require_relative './models/machine_volume_collection'
|
31
|
+
|
32
|
+
# Toplevel entities; order matters as it determines the order
|
33
|
+
# in which the entities appear in the CEP
|
27
34
|
require_relative './models/cloud_entry_point'
|
35
|
+
require_relative './models/resource_metadata'
|
36
|
+
require_relative './models/machine'
|
28
37
|
require_relative './models/machine_template'
|
29
|
-
require_relative './models/machine_image'
|
30
38
|
require_relative './models/machine_configuration'
|
31
|
-
require_relative './models/
|
32
|
-
require_relative './models/
|
39
|
+
require_relative './models/machine_image'
|
40
|
+
require_relative './models/credential'
|
33
41
|
require_relative './models/volume'
|
34
|
-
require_relative './models/
|
42
|
+
require_relative './models/volume_template'
|
35
43
|
require_relative './models/volume_configuration'
|
36
44
|
require_relative './models/volume_image'
|
37
|
-
require_relative './models/volume_template'
|
38
|
-
require_relative './models/machine_template_collection'
|
39
|
-
require_relative './models/machine_image_collection'
|
40
|
-
require_relative './models/machine_configuration_collection'
|
41
|
-
require_relative './models/machine_collection'
|
42
|
-
require_relative './models/volume_collection'
|
43
|
-
require_relative './models/machine_admin_collection'
|
44
|
-
require_relative './models/volume_configuration_collection'
|
45
|
-
require_relative './models/volume_image_collection'
|
46
|
-
require_relative './models/volume_template_collection'
|
47
45
|
require_relative './models/network'
|
48
|
-
require_relative './models/network_collection'
|
49
|
-
require_relative './models/network_configuration'
|
50
|
-
require_relative './models/network_configuration_collection'
|
51
46
|
require_relative './models/network_template'
|
52
|
-
require_relative './models/
|
53
|
-
require_relative './models/
|
54
|
-
require_relative './models/
|
55
|
-
require_relative './models/
|
56
|
-
require_relative './models/routing_group_template_collection'
|
57
|
-
require_relative './models/vsp'
|
58
|
-
require_relative './models/vsp_collection'
|
59
|
-
require_relative './models/vsp_configuration'
|
60
|
-
require_relative './models/vsp_configuration_collection'
|
61
|
-
require_relative './models/vsp_template'
|
62
|
-
require_relative './models/vsp_template_collection'
|
47
|
+
require_relative './models/network_configuration'
|
48
|
+
require_relative './models/network_port'
|
49
|
+
require_relative './models/network_port_template'
|
50
|
+
require_relative './models/network_port_configuration'
|
63
51
|
require_relative './models/address'
|
64
|
-
require_relative './models/address_collection'
|
65
52
|
require_relative './models/address_template'
|
66
|
-
require_relative './models/
|
67
|
-
require_relative './models/
|
68
|
-
require_relative './models/disk_collection'
|
69
|
-
require_relative './models/machine_volume'
|
70
|
-
require_relative './models/machine_volume_collection'
|
53
|
+
require_relative './models/forwarding_group'
|
54
|
+
require_relative './models/forwarding_group_template'
|
data/lib/cimi/models/address.rb
CHANGED
@@ -15,6 +15,8 @@
|
|
15
15
|
|
16
16
|
class CIMI::Model::Address < CIMI::Model::Base
|
17
17
|
|
18
|
+
acts_as_root_entity
|
19
|
+
|
18
20
|
text :ip
|
19
21
|
|
20
22
|
text :hostname
|
@@ -25,8 +27,6 @@ class CIMI::Model::Address < CIMI::Model::Base
|
|
25
27
|
|
26
28
|
text :dns
|
27
29
|
|
28
|
-
text :mac_address
|
29
|
-
|
30
30
|
text :protocol
|
31
31
|
|
32
32
|
text :mask
|
@@ -41,9 +41,11 @@ class CIMI::Model::Address < CIMI::Model::Base
|
|
41
41
|
|
42
42
|
def self.find(id, context)
|
43
43
|
if id==:all
|
44
|
-
context.driver.addresses(context.credentials
|
44
|
+
addresses = context.driver.addresses(context.credentials)
|
45
|
+
addresses.map{|addr| from_address(addr, context)}
|
45
46
|
else
|
46
|
-
context.driver.
|
47
|
+
address = context.driver.address(context.credentials, {:id=>id})
|
48
|
+
from_address(address, context)
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
@@ -69,4 +71,30 @@ class CIMI::Model::Address < CIMI::Model::Base
|
|
69
71
|
context.driver.delete_address(context.credentials, id)
|
70
72
|
end
|
71
73
|
|
74
|
+
private
|
75
|
+
|
76
|
+
def self.from_address(address, context)
|
77
|
+
self.new(
|
78
|
+
:name => address.id,
|
79
|
+
:id => context.address_url(address.id),
|
80
|
+
:description => "Address #{address.id}",
|
81
|
+
:ip => address.id,
|
82
|
+
:allocation => "dynamic", #or "static"
|
83
|
+
:default_gateway => "unkown", #wtf
|
84
|
+
:dns => "unknown", #wtf
|
85
|
+
:protocol => protocol_from_address(address.id),
|
86
|
+
:mask => "unknown",
|
87
|
+
:resource => (address.instance_id) ? {:href=> context.machine_url(address.instance_id)} : nil,
|
88
|
+
:network => nil #unknown
|
89
|
+
#optional:
|
90
|
+
#:hostname =>
|
91
|
+
#:
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.protocol_from_address(address)
|
96
|
+
addr = IPAddr.new(address)
|
97
|
+
addr.ipv4? ? "ipv4" : "ipv6"
|
98
|
+
end
|
99
|
+
|
72
100
|
end
|
@@ -15,6 +15,8 @@
|
|
15
15
|
|
16
16
|
class CIMI::Model::AddressTemplate < CIMI::Model::Base
|
17
17
|
|
18
|
+
acts_as_root_entity
|
19
|
+
|
18
20
|
text :ip
|
19
21
|
|
20
22
|
text :hostname
|
@@ -25,8 +27,6 @@ class CIMI::Model::AddressTemplate < CIMI::Model::Base
|
|
25
27
|
|
26
28
|
text :dns
|
27
29
|
|
28
|
-
text :mac_address
|
29
|
-
|
30
30
|
text :protocol
|
31
31
|
|
32
32
|
text :mask
|
data/lib/cimi/models/base.rb
CHANGED
@@ -69,11 +69,16 @@ require 'json'
|
|
69
69
|
|
70
70
|
module CIMI::Model
|
71
71
|
|
72
|
-
def self.register_as_root_entity!(
|
72
|
+
def self.register_as_root_entity!(klass, opts = {})
|
73
73
|
@root_entities ||= []
|
74
|
-
@root_entities <<
|
74
|
+
@root_entities << klass
|
75
|
+
name = klass.name.split("::").last.pluralize
|
75
76
|
unless CIMI::Model::CloudEntryPoint.href_defined?(name)
|
76
|
-
|
77
|
+
params = {}
|
78
|
+
if opts[:as]
|
79
|
+
params[:xml_name] = params[:json_name] = opts[:as]
|
80
|
+
end
|
81
|
+
CIMI::Model::CloudEntryPoint.send(:href, name.underscore, params)
|
77
82
|
end
|
78
83
|
end
|
79
84
|
|
@@ -94,6 +99,20 @@ class CIMI::Model::Base
|
|
94
99
|
# attribute, we also define a getter and a setter to access/change the
|
95
100
|
# value for that attribute
|
96
101
|
class << self
|
102
|
+
|
103
|
+
def <<(model)
|
104
|
+
clone_base_schema unless base_schema_cloned?
|
105
|
+
member_name = model.name.split("::").last
|
106
|
+
if ::Struct.const_defined?("CIMI_#{member_name}")
|
107
|
+
puts "Removing struct"
|
108
|
+
::Struct.send(:remove_const, "CIMI_#{member_name}")
|
109
|
+
end
|
110
|
+
member_symbol = member_name.underscore.pluralize.to_sym
|
111
|
+
members = CIMI::Model::Schema::Array.new(member_symbol)
|
112
|
+
members.struct.schema.attributes = model.schema.attributes
|
113
|
+
base_schema.attributes << members
|
114
|
+
end
|
115
|
+
|
97
116
|
def base_schema
|
98
117
|
@schema ||= CIMI::Model::Schema.new
|
99
118
|
end
|
@@ -192,7 +211,7 @@ class CIMI::Model::Base
|
|
192
211
|
|
193
212
|
def self.to_xml(model)
|
194
213
|
xml = @schema.to_xml(model)
|
195
|
-
xml["xmlns"] = "http://
|
214
|
+
xml["xmlns"] = "http://schemas.dmtf.org/cimi/1"
|
196
215
|
XmlSimple.xml_out(xml, :root_name => xml_tag_name)
|
197
216
|
end
|
198
217
|
|
@@ -211,7 +230,7 @@ class CIMI::Model::Base
|
|
211
230
|
|
212
231
|
hash :property
|
213
232
|
|
214
|
-
def self.
|
233
|
+
def self.acts_as_root_entity(name=nil)
|
215
234
|
if name
|
216
235
|
name = name.to_s.camelize.pluralize
|
217
236
|
else
|
@@ -17,18 +17,13 @@ class CIMI::Model::CloudEntryPoint < CIMI::Model::Base
|
|
17
17
|
|
18
18
|
text :base_uri, :xml_name => "baseURI", :json_name => "baseURI"
|
19
19
|
|
20
|
-
array :entity_metadata do
|
21
|
-
scalar :href
|
22
|
-
end
|
23
|
-
|
24
20
|
def self.create(context)
|
25
21
|
self.new(entities(context).merge({
|
26
22
|
:name => context.driver.name,
|
27
23
|
:description => "Cloud Entry Point for the Deltacloud #{context.driver.name} driver",
|
28
24
|
:id => context.cloudEntryPoint_url,
|
29
|
-
:base_uri => context.
|
30
|
-
:created => Time.now
|
31
|
-
:entity_metadata => CIMI::Model::EntityMetadata.all_uri(context)
|
25
|
+
:base_uri => context.base_uri,
|
26
|
+
:created => Time.now
|
32
27
|
}))
|
33
28
|
end
|
34
29
|
|
@@ -46,8 +41,8 @@ class CIMI::Model::CloudEntryPoint < CIMI::Model::Base
|
|
46
41
|
|
47
42
|
private
|
48
43
|
|
49
|
-
def self.href_defined?(
|
50
|
-
true if schema.attribute_names.include?
|
44
|
+
def self.href_defined?(resource)
|
45
|
+
true if schema.attribute_names.include? resource.underscore
|
51
46
|
end
|
52
47
|
|
53
48
|
end
|