fog-openstack 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.hound.yml +2 -0
- data/.rubocop.yml +93 -0
- data/.travis.yml +13 -10
- data/{lib/fog/openstack/CHANGELOG.md → CHANGELOG.md} +0 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile +2 -0
- data/README.md +497 -3
- data/Rakefile +5 -1
- data/fog-openstack.gemspec +8 -7
- data/gemfiles/Gemfile-1.9 +16 -0
- data/lib/fog/openstack.rb +55 -30
- data/lib/fog/openstack/docs/metering.md +29 -0
- data/lib/fog/openstack/metering.rb +6 -1
- data/lib/fog/openstack/models/metering/event.rb +16 -0
- data/lib/fog/openstack/models/metering/events.rb +23 -0
- data/lib/fog/openstack/models/network/floating_ip.rb +1 -24
- data/lib/fog/openstack/models/network/ike_policies.rb +32 -0
- data/lib/fog/openstack/models/network/ike_policy.rb +43 -0
- data/lib/fog/openstack/models/network/ipsec_policies.rb +32 -0
- data/lib/fog/openstack/models/network/ipsec_policy.rb +45 -0
- data/lib/fog/openstack/models/network/ipsec_site_connection.rb +51 -0
- data/lib/fog/openstack/models/network/ipsec_site_connections.rb +33 -0
- data/lib/fog/openstack/models/network/vpn_service.rb +42 -0
- data/lib/fog/openstack/models/network/vpn_services.rb +32 -0
- data/lib/fog/openstack/network.rb +52 -13
- data/lib/fog/openstack/requests/compute/create_volume.rb +28 -21
- data/lib/fog/openstack/requests/metering/get_event.rb +27 -0
- data/lib/fog/openstack/requests/metering/list_events.rb +42 -0
- data/lib/fog/openstack/requests/network/associate_floating_ip.rb +15 -10
- data/lib/fog/openstack/requests/network/create_floating_ip.rb +1 -1
- data/lib/fog/openstack/requests/network/create_ike_policy.rb +53 -0
- data/lib/fog/openstack/requests/network/create_ipsec_policy.rb +53 -0
- data/lib/fog/openstack/requests/network/create_ipsec_site_connection.rb +66 -0
- data/lib/fog/openstack/requests/network/create_vpn_service.rb +51 -0
- data/lib/fog/openstack/requests/network/delete_ike_policy.rb +28 -0
- data/lib/fog/openstack/requests/network/delete_ipsec_policy.rb +28 -0
- data/lib/fog/openstack/requests/network/delete_ipsec_site_connection.rb +29 -0
- data/lib/fog/openstack/requests/network/delete_vpn_service.rb +28 -0
- data/lib/fog/openstack/requests/network/disassociate_floating_ip.rb +15 -10
- data/lib/fog/openstack/requests/network/get_floating_ip.rb +12 -2
- data/lib/fog/openstack/requests/network/get_ike_policy.rb +28 -0
- data/lib/fog/openstack/requests/network/get_ipsec_policy.rb +28 -0
- data/lib/fog/openstack/requests/network/get_ipsec_site_connection.rb +28 -0
- data/lib/fog/openstack/requests/network/get_network.rb +1 -13
- data/lib/fog/openstack/requests/network/get_vpn_service.rb +28 -0
- data/lib/fog/openstack/requests/network/list_ike_policies.rb +25 -0
- data/lib/fog/openstack/requests/network/list_ipsec_policies.rb +25 -0
- data/lib/fog/openstack/requests/network/list_ipsec_site_connections.rb +25 -0
- data/lib/fog/openstack/requests/network/list_vpn_services.rb +25 -0
- data/lib/fog/openstack/requests/network/update_ike_policy.rb +49 -0
- data/lib/fog/openstack/requests/network/update_ipsec_policy.rb +52 -0
- data/lib/fog/openstack/requests/network/update_ipsec_site_connection.rb +64 -0
- data/lib/fog/openstack/requests/network/update_vpn_service.rb +46 -0
- data/lib/fog/openstack/storage.rb +2 -2
- data/lib/fog/openstack/version.rb +1 -1
- data/tests/helper.rb +3 -0
- data/tests/openstack/models/network/ike_policies_tests.rb +28 -0
- data/tests/openstack/models/network/ike_policy_tests.rb +36 -0
- data/tests/openstack/models/network/ipsec_policies_tests.rb +26 -0
- data/tests/openstack/models/network/ipsec_policy_tests.rb +36 -0
- data/tests/openstack/models/network/ipsec_site_connection_tests.rb +50 -0
- data/tests/openstack/models/network/ipsec_site_connections_tests.rb +32 -0
- data/tests/openstack/models/network/vpn_service_tests.rb +27 -0
- data/tests/openstack/models/network/vpn_services_tests.rb +22 -0
- data/tests/openstack/requests/metering/event_tests.rb +17 -0
- data/tests/openstack/requests/network/ike_policy_tests.rb +65 -0
- data/tests/openstack/requests/network/ipsec_policy_tests.rb +65 -0
- data/tests/openstack/requests/network/ipsec_site_connection_tests.rb +82 -0
- data/tests/openstack/requests/network/vpn_service_tests.rb +61 -0
- metadata +109 -47
- data/CONTRIBUTORS.md +0 -79
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'fog/openstack/models/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Network
|
5
|
+
class OpenStack
|
6
|
+
class IpsecSiteConnection < Fog::OpenStack::Model
|
7
|
+
identity :id
|
8
|
+
|
9
|
+
attribute :name
|
10
|
+
attribute :description
|
11
|
+
attribute :status
|
12
|
+
attribute :admin_state_up
|
13
|
+
attribute :tenant_id
|
14
|
+
attribute :vpnservice_id
|
15
|
+
attribute :ikepolicy_id
|
16
|
+
attribute :ipsecpolicy_id
|
17
|
+
attribute :peer_address
|
18
|
+
attribute :peer_id
|
19
|
+
attribute :peer_cidrs
|
20
|
+
attribute :psk
|
21
|
+
attribute :mtu
|
22
|
+
attribute :dpd
|
23
|
+
attribute :initiator
|
24
|
+
|
25
|
+
def create
|
26
|
+
requires :name, :vpnservice_id, :ikepolicy_id, :ipsecpolicy_id,
|
27
|
+
:peer_address, :peer_id, :peer_cidrs, :psk
|
28
|
+
merge_attributes(service.create_ipsec_site_connection(vpnservice_id,
|
29
|
+
ikepolicy_id,
|
30
|
+
ipsecpolicy_id,
|
31
|
+
attributes).body['ipsec_site_connection'])
|
32
|
+
self
|
33
|
+
end
|
34
|
+
|
35
|
+
def update
|
36
|
+
requires :id, :name, :vpnservice_id, :ikepolicy_id, :ipsecpolicy_id,
|
37
|
+
:peer_address, :peer_id, :peer_cidrs, :psk
|
38
|
+
merge_attributes(service.update_ipsec_site_connection(id,
|
39
|
+
attributes).body['ipsec_site_connection'])
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
def destroy
|
44
|
+
requires :id
|
45
|
+
service.delete_ipsec_site_connection(id)
|
46
|
+
true
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'fog/openstack/models/collection'
|
2
|
+
require 'fog/openstack/models/network/ipsec_site_connection'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Network
|
6
|
+
class OpenStack
|
7
|
+
class IpsecSiteConnections < Fog::OpenStack::Collection
|
8
|
+
attribute :filters
|
9
|
+
|
10
|
+
model Fog::Network::OpenStack::IpsecSiteConnection
|
11
|
+
|
12
|
+
def initialize(attributes)
|
13
|
+
self.filters ||= {}
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def all(filters_arg = filters)
|
18
|
+
filters = filters_arg
|
19
|
+
load_response(service.list_ipsec_site_connections(filters), 'ipsec_site_connections')
|
20
|
+
end
|
21
|
+
|
22
|
+
def get(ipsec_site_connection_id)
|
23
|
+
connection = service.get_ipsec_site_connection(ipsec_site_connection_id).body['ipsec_site_connection']
|
24
|
+
if connection
|
25
|
+
new(connection)
|
26
|
+
end
|
27
|
+
rescue Fog::Network::OpenStack::NotFound
|
28
|
+
nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'fog/openstack/models/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Network
|
5
|
+
class OpenStack
|
6
|
+
class VpnService < Fog::OpenStack::Model
|
7
|
+
identity :id
|
8
|
+
|
9
|
+
attribute :subnet_id
|
10
|
+
attribute :router_id
|
11
|
+
attribute :name
|
12
|
+
attribute :description
|
13
|
+
attribute :status
|
14
|
+
attribute :admin_state_up
|
15
|
+
attribute :tenant_id
|
16
|
+
attribute :external_v4_ip
|
17
|
+
attribute :external_v6_ip
|
18
|
+
|
19
|
+
def create
|
20
|
+
requires :subnet_id, :router_id, :name, :admin_state_up
|
21
|
+
merge_attributes(service.create_vpn_service(subnet_id,
|
22
|
+
router_id,
|
23
|
+
attributes).body['vpnservice'])
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
def update
|
28
|
+
requires :id, :subnet_id, :router_id, :name, :admin_state_up
|
29
|
+
merge_attributes(service.update_vpn_service(id,
|
30
|
+
attributes).body['vpnservice'])
|
31
|
+
self
|
32
|
+
end
|
33
|
+
|
34
|
+
def destroy
|
35
|
+
requires :id
|
36
|
+
service.delete_vpn_service(id)
|
37
|
+
true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'fog/openstack/models/collection'
|
2
|
+
require 'fog/openstack/models/network/vpn_service'
|
3
|
+
|
4
|
+
module Fog
|
5
|
+
module Network
|
6
|
+
class OpenStack
|
7
|
+
class VpnServices < Fog::OpenStack::Collection
|
8
|
+
attribute :filters
|
9
|
+
|
10
|
+
model Fog::Network::OpenStack::VpnService
|
11
|
+
|
12
|
+
def initialize(attributes)
|
13
|
+
self.filters ||= {}
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def all(filters_arg = filters)
|
18
|
+
filters = filters_arg
|
19
|
+
load_response(service.list_vpn_services(filters), 'vpnservices')
|
20
|
+
end
|
21
|
+
|
22
|
+
def get(vpn_service_id)
|
23
|
+
if vpn_service = service.get_vpn_service(vpn_service_id).body['vpnservice']
|
24
|
+
new(vpn_service)
|
25
|
+
end
|
26
|
+
rescue Fog::Network::OpenStack::NotFound
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
|
2
2
|
|
3
3
|
module Fog
|
4
4
|
module Network
|
@@ -38,6 +38,14 @@ module Fog
|
|
38
38
|
collection :lb_health_monitors
|
39
39
|
model :lb_vip
|
40
40
|
collection :lb_vips
|
41
|
+
model :vpn_service
|
42
|
+
collection :vpn_services
|
43
|
+
model :ike_policy
|
44
|
+
collection :ike_policies
|
45
|
+
model :ipsec_policy
|
46
|
+
collection :ipsec_policies
|
47
|
+
model :ipsec_site_connection
|
48
|
+
collection :ipsec_site_connections
|
41
49
|
model :security_group
|
42
50
|
collection :security_groups
|
43
51
|
model :security_group_rule
|
@@ -116,6 +124,34 @@ module Fog
|
|
116
124
|
request :get_lb_vip
|
117
125
|
request :update_lb_vip
|
118
126
|
|
127
|
+
# VPNaaS VPN Service CRUD
|
128
|
+
request :list_vpn_services
|
129
|
+
request :create_vpn_service
|
130
|
+
request :delete_vpn_service
|
131
|
+
request :get_vpn_service
|
132
|
+
request :update_vpn_service
|
133
|
+
|
134
|
+
# VPNaaS VPN IKE Policy CRUD
|
135
|
+
request :list_ike_policies
|
136
|
+
request :create_ike_policy
|
137
|
+
request :delete_ike_policy
|
138
|
+
request :get_ike_policy
|
139
|
+
request :update_ike_policy
|
140
|
+
|
141
|
+
# VPNaaS VPN IPSec Policy CRUD
|
142
|
+
request :list_ipsec_policies
|
143
|
+
request :create_ipsec_policy
|
144
|
+
request :delete_ipsec_policy
|
145
|
+
request :get_ipsec_policy
|
146
|
+
request :update_ipsec_policy
|
147
|
+
|
148
|
+
# VPNaaS VPN IPSec Site Connection CRUD
|
149
|
+
request :list_ipsec_site_connections
|
150
|
+
request :create_ipsec_site_connection
|
151
|
+
request :delete_ipsec_site_connection
|
152
|
+
request :get_ipsec_site_connection
|
153
|
+
request :update_ipsec_site_connection
|
154
|
+
|
119
155
|
# Security Group
|
120
156
|
request :create_security_group
|
121
157
|
request :delete_security_group
|
@@ -146,7 +182,7 @@ module Fog
|
|
146
182
|
|
147
183
|
hash[key] = {
|
148
184
|
:networks => {
|
149
|
-
network_id
|
185
|
+
network_id => {
|
150
186
|
'id' => network_id,
|
151
187
|
'name' => 'Public',
|
152
188
|
'subnets' => [subnet_id],
|
@@ -156,6 +192,15 @@ module Fog
|
|
156
192
|
'provider_network_type' => 'vlan',
|
157
193
|
'router:external' => false,
|
158
194
|
'admin_state_up' => true,
|
195
|
+
},
|
196
|
+
'e624a36d-762b-481f-9b50-4154ceb78bbb' => {
|
197
|
+
'id' => 'e624a36d-762b-481f-9b50-4154ceb78bbb',
|
198
|
+
'name' => 'network_1',
|
199
|
+
'subnets' => ['2e4ec6a4-0150-47f5-8523-e899ac03026e'],
|
200
|
+
'shared' => false,
|
201
|
+
'status' => 'ACTIVE',
|
202
|
+
'admin_state_up' => true,
|
203
|
+
'tenant_id' => 'f8b26a6032bc47718a7702233ac708b9',
|
159
204
|
}
|
160
205
|
},
|
161
206
|
:ports => {},
|
@@ -174,22 +219,16 @@ module Fog
|
|
174
219
|
'tenant_id' => tenant_id,
|
175
220
|
}
|
176
221
|
},
|
177
|
-
:floating_ips => {
|
178
|
-
'00000000-0000-0000-0000-000000000000' => {
|
179
|
-
'id' => '00000000-0000-0000-0000-000000000000',
|
180
|
-
'port_id' => nil,
|
181
|
-
'tenant_id' => tenant_id,
|
182
|
-
'floating_network_id' => network_id,
|
183
|
-
'router_id' => '00000000-0000-0000-0000-000000000000',
|
184
|
-
'floating_ip_address' => '66.66.66.66',
|
185
|
-
|
186
|
-
}
|
187
|
-
},
|
222
|
+
:floating_ips => {},
|
188
223
|
:routers => {},
|
189
224
|
:lb_pools => {},
|
190
225
|
:lb_members => {},
|
191
226
|
:lb_health_monitors => {},
|
192
227
|
:lb_vips => {},
|
228
|
+
:vpn_services => {},
|
229
|
+
:ike_policies => {},
|
230
|
+
:ipsec_policies => {},
|
231
|
+
:ipsec_site_connections => {},
|
193
232
|
:quota => {
|
194
233
|
"subnet" => 10,
|
195
234
|
"router" => 10,
|
@@ -1,8 +1,10 @@
|
|
1
|
+
#
|
1
2
|
module Fog
|
2
3
|
module Compute
|
3
4
|
class OpenStack
|
5
|
+
#
|
4
6
|
class Real
|
5
|
-
def create_volume(name, description, size, options={})
|
7
|
+
def create_volume(name, description, size, options = {})
|
6
8
|
data = {
|
7
9
|
'volume' => {
|
8
10
|
'display_name' => name,
|
@@ -11,38 +13,43 @@ module Fog
|
|
11
13
|
}
|
12
14
|
}
|
13
15
|
|
14
|
-
vanilla_options = [
|
15
|
-
|
16
|
+
vanilla_options = [
|
17
|
+
:snapshot_id,
|
18
|
+
:availability_zone,
|
19
|
+
:volume_type,
|
20
|
+
:metadata]
|
21
|
+
|
22
|
+
vanilla_options.select { |o| options[o] }.each do |key|
|
16
23
|
data['volume'][key] = options[key]
|
17
24
|
end
|
25
|
+
|
18
26
|
request(
|
19
|
-
:body
|
20
|
-
:expects
|
21
|
-
:method
|
22
|
-
:path
|
27
|
+
:body => Fog::JSON.encode(data),
|
28
|
+
:expects => [200, 202],
|
29
|
+
:method => 'POST',
|
30
|
+
:path => 'os-volumes'
|
23
31
|
)
|
24
32
|
end
|
25
33
|
end
|
26
34
|
|
35
|
+
#
|
27
36
|
class Mock
|
28
|
-
def create_volume(name, description, size, options={})
|
37
|
+
def create_volume(name, description, size, options = {})
|
29
38
|
response = Excon::Response.new
|
30
39
|
response.status = 202
|
31
|
-
data = {
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
'attachments' => [],
|
42
|
-
'metadata' => {}
|
40
|
+
data = {'id' => Fog::Mock.random_numbers(2),
|
41
|
+
'displayName' => name,
|
42
|
+
'displayDescription' => description,
|
43
|
+
'size' => size,
|
44
|
+
'status' => 'creating',
|
45
|
+
'snapshotId' => options[:snapshot_id],
|
46
|
+
'volumeType' => options[:volume_type] || 'None',
|
47
|
+
'availabilityZone' => options[:availability_zone] || 'nova',
|
48
|
+
'createdAt' => Time.now.strftime('%FT%T.%6N'),
|
49
|
+
'attachments' => [], 'metadata' => options[:metadata] || {}
|
43
50
|
}
|
44
51
|
self.data[:volumes][data['id']] = data
|
45
|
-
response.body = {
|
52
|
+
response.body = {'volume' => data}
|
46
53
|
response
|
47
54
|
end
|
48
55
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fog
|
2
|
+
module Metering
|
3
|
+
class OpenStack
|
4
|
+
class Real
|
5
|
+
def get_event(message_id)
|
6
|
+
request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => 'GET',
|
9
|
+
:path => "events/#{message_id}"
|
10
|
+
)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Mock
|
15
|
+
def get_event(message_id)
|
16
|
+
response = Excon::Response.new
|
17
|
+
response.status = 200
|
18
|
+
response.body = {
|
19
|
+
'event_type'=>'compute.instance.create',
|
20
|
+
'message_id'=>'d646b40dea6347dfb8caee2da1484c56',
|
21
|
+
}
|
22
|
+
response
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Fog
|
2
|
+
module Metering
|
3
|
+
class OpenStack
|
4
|
+
class Real
|
5
|
+
def list_events(options=[])
|
6
|
+
data = {
|
7
|
+
'q' => Array.new
|
8
|
+
}
|
9
|
+
|
10
|
+
options.each do |opt|
|
11
|
+
filter = {}
|
12
|
+
|
13
|
+
['field', 'op', 'value'].each do |key|
|
14
|
+
filter[key] = opt[key] if opt[key]
|
15
|
+
end
|
16
|
+
|
17
|
+
data['q'] << filter unless filter.empty?
|
18
|
+
end
|
19
|
+
|
20
|
+
request(
|
21
|
+
:body => Fog::JSON.encode(data),
|
22
|
+
:expects => 200,
|
23
|
+
:method => 'GET',
|
24
|
+
:path => 'events'
|
25
|
+
)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Mock
|
30
|
+
def list_events(options={})
|
31
|
+
response = Excon::Response.new
|
32
|
+
response.status = 200
|
33
|
+
response.body = [{
|
34
|
+
'event_type'=>'compute.instance.create',
|
35
|
+
'message_id'=>'d646b40dea6347dfb8caee2da1484c56',
|
36
|
+
}]
|
37
|
+
response
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -25,16 +25,21 @@ module Fog
|
|
25
25
|
|
26
26
|
class Mock
|
27
27
|
def associate_floating_ip(floating_ip_id, port_id, options = {})
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
28
|
+
response = Excon::Response.new
|
29
|
+
response.status = 201
|
30
|
+
data = {
|
31
|
+
'id' => '00000000-0000-0000-0000-000000000000',
|
32
|
+
'router_id' => '00000000-0000-0000-0000-000000000000',
|
33
|
+
'tenant_id' => options["tenant_id"],
|
34
|
+
'floating_network_id' => options["floating_network_id"],
|
35
|
+
'fixed_ip_address' => options["fixed_ip_address"],
|
36
|
+
'floating_ip_address' => options["floating_ip_address"],
|
37
|
+
'port_id' => port_id,
|
38
|
+
}
|
39
|
+
|
40
|
+
self.data[:floating_ips][data['floating_ip_id']] = data
|
41
|
+
response.body = { 'floatingip' => data }
|
42
|
+
response
|
38
43
|
end
|
39
44
|
end
|
40
45
|
end
|