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
@@ -0,0 +1,106 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright ownership. The
|
4
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the
|
6
|
+
# License. You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations
|
14
|
+
# under the License.
|
15
|
+
|
16
|
+
module Deltacloud
|
17
|
+
|
18
|
+
# Collection methods that every frontend need to provide.
|
19
|
+
#
|
20
|
+
module CollectionMethods
|
21
|
+
|
22
|
+
# Return all collections provided by the current frontend
|
23
|
+
#
|
24
|
+
def collections
|
25
|
+
module_klass::Collections.collections
|
26
|
+
end
|
27
|
+
|
28
|
+
# Return all collection names provided by the current frontend
|
29
|
+
#
|
30
|
+
def collection_names
|
31
|
+
module_klass::Collections.collection_names
|
32
|
+
end
|
33
|
+
|
34
|
+
# Simple check if the collection is available in the current frontend
|
35
|
+
#
|
36
|
+
def collection_exists?(c)
|
37
|
+
collections.include? c
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def module_klass
|
43
|
+
@klass ||= self
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
extend CollectionMethods
|
49
|
+
|
50
|
+
module CollectionHelper
|
51
|
+
|
52
|
+
def collection_names
|
53
|
+
collections.map { |c| c.collection_name }
|
54
|
+
end
|
55
|
+
|
56
|
+
def collections
|
57
|
+
@collections ||= []
|
58
|
+
end
|
59
|
+
|
60
|
+
def collection(name)
|
61
|
+
collections.find { |c| c.collection_name == name }
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def modules(frontend)
|
66
|
+
case frontend
|
67
|
+
when :cimi then @cimi_modules ||= []
|
68
|
+
when :deltacloud then @deltacloud_modules ||= []
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# This method will load all collections from given directory.
|
73
|
+
#
|
74
|
+
# Syntax:
|
75
|
+
#
|
76
|
+
# load_collections_for :cimi, :from => DIRECTORY
|
77
|
+
#
|
78
|
+
def load_collections_for(frontend, opts={})
|
79
|
+
frontend_module = (frontend == :cimi) ? CIMI : Deltacloud
|
80
|
+
Dir[File.join(opts[:from], '*.rb')].each do |collection|
|
81
|
+
base_collection_name = File.basename(collection).gsub('.rb', '')
|
82
|
+
next if base_collection_name == 'base'
|
83
|
+
require collection
|
84
|
+
collection_module_class = frontend_module::Collections.const_get(
|
85
|
+
base_collection_name.camelize
|
86
|
+
)
|
87
|
+
modules(frontend) << collection_module_class
|
88
|
+
if collection_module_class.collections.nil?
|
89
|
+
warn "WARNING: #{collection_module_class} does not include any collections"
|
90
|
+
else
|
91
|
+
collection_module_class.collections.each do |c|
|
92
|
+
if frontend_module.collection_exists?(c)
|
93
|
+
raise "ERROR: Collection already registred #{c}"
|
94
|
+
end
|
95
|
+
frontend_module.collections << c
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
module CIMI
|
105
|
+
extend Deltacloud::CollectionMethods
|
106
|
+
end
|
@@ -18,6 +18,10 @@ module Deltacloud::Helpers
|
|
18
18
|
|
19
19
|
require 'benchmark'
|
20
20
|
|
21
|
+
def current_provider
|
22
|
+
Thread.current[:provider] || ENV['API_PROVIDER'] || 'default'
|
23
|
+
end
|
24
|
+
|
21
25
|
def collections_to_json(collections)
|
22
26
|
r = {
|
23
27
|
:version => settings.version,
|
@@ -53,12 +57,12 @@ module Deltacloud::Helpers
|
|
53
57
|
end
|
54
58
|
|
55
59
|
def instance_action_method(action)
|
56
|
-
action_method(action,
|
60
|
+
action_method(action, Deltacloud::Rabbit::InstancesCollection)
|
57
61
|
end
|
58
62
|
|
59
63
|
def action_method(action, collection)
|
60
64
|
http_method = collection.operation(action).http_method
|
61
|
-
http_method ||
|
65
|
+
http_method || Deltacloud::Rabbit::BaseCollection.http_method_for(action)
|
62
66
|
end
|
63
67
|
|
64
68
|
def filter_all(model)
|
@@ -76,7 +80,7 @@ module Deltacloud::Helpers
|
|
76
80
|
format.json { JSON::dump({ model => @elements.map { |el| el.to_hash(self) }}) }
|
77
81
|
end
|
78
82
|
else
|
79
|
-
report_error(@exception.respond_to?(:code) ? @exception.code :
|
83
|
+
report_error(@exception.respond_to?(:code) ? @exception.code : nil)
|
80
84
|
end
|
81
85
|
end
|
82
86
|
|
@@ -102,10 +106,10 @@ module Deltacloud::Helpers
|
|
102
106
|
Deltacloud::Exceptions.logger(Deltacloud.default_frontend.logger)
|
103
107
|
end
|
104
108
|
|
105
|
-
def report_error(code=nil)
|
109
|
+
def report_error(code=nil, message=nil)
|
106
110
|
|
107
111
|
if !code.nil?
|
108
|
-
@error = Deltacloud::Exceptions.exception_from_status(code, translate_error_code(code)[:message])
|
112
|
+
@error = Deltacloud::Exceptions.exception_from_status(code, message || translate_error_code(code)[:message])
|
109
113
|
@code = code
|
110
114
|
message = @error.message
|
111
115
|
else
|
@@ -124,16 +128,16 @@ module Deltacloud::Helpers
|
|
124
128
|
end
|
125
129
|
|
126
130
|
respond_to do |format|
|
127
|
-
format.xml { haml :"errors
|
131
|
+
format.xml { haml :"errors/common", :layout => false }
|
128
132
|
format.json { JSON::dump({ :code => @code || @error.code, :message => message, :error => @error.class.name }) }
|
129
133
|
format.html {
|
130
134
|
begin
|
131
|
-
haml :"errors
|
135
|
+
haml :"errors/common", :layout => :error
|
132
136
|
rescue RuntimeError
|
133
137
|
# If the HTML representation of error is missing, then try to report
|
134
138
|
# it through XML
|
135
139
|
@media_type=:xml
|
136
|
-
haml :"errors
|
140
|
+
haml :"errors/common", :layout => false
|
137
141
|
end
|
138
142
|
}
|
139
143
|
end
|
@@ -14,25 +14,27 @@
|
|
14
14
|
# License for the specific language governing permissions and limitations
|
15
15
|
# under the License.
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
module Deltacloud
|
18
|
+
class Address < BaseModel
|
19
|
+
attr_accessor :instance_id
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
def initialize(init=nil)
|
22
|
+
super(init)
|
23
|
+
end
|
23
24
|
|
24
|
-
|
25
|
-
|
26
|
-
|
25
|
+
def associated?
|
26
|
+
!self.instance_id.nil?
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
def to_hash(context)
|
30
|
+
r = {
|
31
|
+
:id => self.id,
|
32
|
+
:href => context.address_url(self.id),
|
33
|
+
:associated => associated?
|
34
|
+
}
|
35
|
+
r[:instance_id] = instance_id if associated?
|
36
|
+
r
|
37
|
+
end
|
37
38
|
|
39
|
+
end
|
38
40
|
end
|
@@ -14,38 +14,41 @@
|
|
14
14
|
# License for the specific language governing permissions and limitations
|
15
15
|
# under the License.
|
16
16
|
|
17
|
+
module Deltacloud
|
18
|
+
class BaseModel
|
19
|
+
|
20
|
+
attr_accessor :name, :description
|
21
|
+
|
22
|
+
def initialize(init=nil)
|
23
|
+
if ( init )
|
24
|
+
@id=init[:id]
|
25
|
+
init.each{|k,v|
|
26
|
+
self.send( "#{k}=", v ) if ( self.respond_to?( "#{k}=" ) )
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
17
30
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
@id=init[:id]
|
23
|
-
init.each{|k,v|
|
24
|
-
self.send( "#{k}=", v ) if ( self.respond_to?( "#{k}=" ) )
|
25
|
-
}
|
31
|
+
def self.attr_accessor(*vars)
|
32
|
+
@attributes ||= [:id]
|
33
|
+
@attributes.concat vars
|
34
|
+
super
|
26
35
|
end
|
27
|
-
end
|
28
36
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
super
|
33
|
-
end
|
37
|
+
def self.attributes
|
38
|
+
@attributes
|
39
|
+
end
|
34
40
|
|
35
|
-
|
36
|
-
|
37
|
-
|
41
|
+
def attributes
|
42
|
+
self.class.attributes
|
43
|
+
end
|
38
44
|
|
39
|
-
|
40
|
-
|
41
|
-
|
45
|
+
def id
|
46
|
+
@id
|
47
|
+
end
|
42
48
|
|
43
|
-
|
44
|
-
|
45
|
-
|
49
|
+
def to_entity
|
50
|
+
self.class.name.downcase
|
51
|
+
end
|
46
52
|
|
47
|
-
def to_entity
|
48
|
-
self.class.name.downcase
|
49
53
|
end
|
50
|
-
|
51
54
|
end
|
@@ -14,27 +14,29 @@
|
|
14
14
|
# License for the specific language governing permissions and limitations
|
15
15
|
# under the License.
|
16
16
|
|
17
|
-
|
17
|
+
module Deltacloud
|
18
|
+
class Blob < BaseModel
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
#already has an id from basemodel (for the key)
|
21
|
+
attr_accessor :bucket
|
22
|
+
attr_accessor :content_length
|
23
|
+
attr_accessor :content_type
|
24
|
+
attr_accessor :last_modified
|
25
|
+
attr_accessor :content
|
26
|
+
attr_accessor :user_metadata
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
28
|
+
def to_hash(context)
|
29
|
+
{
|
30
|
+
:id => self.id,
|
31
|
+
:href => context.bucket_url(bucket) + '/' + self.id,
|
32
|
+
:bucket => { :rel => :bucket, :href => context.bucket_url(bucket), :id => bucket },
|
33
|
+
:content_length => content_length,
|
34
|
+
:content_type => content_type,
|
35
|
+
:last_modified => last_modified,
|
36
|
+
:content => content,
|
37
|
+
:user_metadata => user_metadata
|
38
|
+
}
|
39
|
+
end
|
39
40
|
|
41
|
+
end
|
40
42
|
end
|
@@ -14,24 +14,29 @@
|
|
14
14
|
# License for the specific language governing permissions and limitations
|
15
15
|
# under the License.
|
16
16
|
|
17
|
-
|
17
|
+
module Deltacloud
|
18
|
+
class Bucket < BaseModel
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
attr_accessor :name
|
21
|
+
attr_accessor :size
|
22
|
+
attr_accessor :blob_list
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
def blob_list
|
25
|
+
@blob_list || []
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
def to_hash(context)
|
29
|
+
{
|
30
|
+
:id => self.id,
|
31
|
+
:href => context.bucket_url(self.id),
|
32
|
+
:name => name,
|
33
|
+
:size => size,
|
34
|
+
:blob_list => blob_list.map { |b| {
|
35
|
+
:rel => :blob,
|
36
|
+
:href => context.url("/buckets/#{self.id}/#{b}"), :id => b }
|
37
|
+
}
|
38
|
+
}
|
39
|
+
end
|
36
40
|
|
41
|
+
end
|
37
42
|
end
|
@@ -14,22 +14,24 @@
|
|
14
14
|
# License for the specific language governing permissions and limitations
|
15
15
|
# under the License.
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
module Deltacloud
|
18
|
+
class Firewall < BaseModel
|
19
|
+
attr_accessor :name
|
20
|
+
attr_accessor :description
|
21
|
+
attr_accessor :owner_id
|
22
|
+
attr_accessor :rules
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
24
|
+
def to_hash(context)
|
25
|
+
r = {
|
26
|
+
:id => self.id,
|
27
|
+
:href => context.firewall_url(self.id),
|
28
|
+
:name => name,
|
29
|
+
:description => description,
|
30
|
+
:owner_id => owner_id,
|
31
|
+
:rules => []
|
32
|
+
}
|
33
|
+
r[:rules] = rules.map { |rule| rule.to_hash(context) } if rules and !rules.empty?
|
34
|
+
r
|
35
|
+
end
|
34
36
|
end
|
35
37
|
end
|
@@ -14,26 +14,28 @@
|
|
14
14
|
# License for the specific language governing permissions and limitations
|
15
15
|
# under the License.
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
module Deltacloud
|
18
|
+
class FirewallRule < BaseModel
|
19
|
+
attr_accessor :allow_protocol # tcp/udp/icmp
|
20
|
+
attr_accessor :port_from
|
21
|
+
attr_accessor :port_to
|
22
|
+
attr_accessor :sources
|
23
|
+
attr_accessor :direction #ingress egress
|
24
|
+
attr_accessor :rule_action #Accept/Deny - initially added for FGCP
|
25
|
+
attr_accessor :log_rule #log when rule triggered true/false - added for FGCP
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
27
|
+
def to_hash(context)
|
28
|
+
{
|
29
|
+
:id => self.id,
|
30
|
+
:allow_protocol => allow_protocol,
|
31
|
+
:port_from => port_from,
|
32
|
+
:port_to => port_to,
|
33
|
+
:sources => sources,
|
34
|
+
:direction => direction,
|
35
|
+
:rule_action => rule_action,
|
36
|
+
:log_rule => log_rule
|
37
|
+
}.delete_if { |k, v| v.nil? }
|
38
|
+
end
|
38
39
|
|
40
|
+
end
|
39
41
|
end
|