fog-oraclecloud 0.1.15 → 0.1.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fog/oraclecloud/compute.rb +395 -6
- data/lib/fog/oraclecloud/database.rb +6 -0
- data/lib/fog/oraclecloud/java.rb +1 -0
- data/lib/fog/oraclecloud/models/compute/instance.rb +64 -2
- data/lib/fog/oraclecloud/models/compute/ip_association.rb +42 -0
- data/lib/fog/oraclecloud/models/compute/ip_associations.rb +22 -0
- data/lib/fog/oraclecloud/models/compute/ip_reservation.rb +10 -5
- data/lib/fog/oraclecloud/models/compute/security_application.rb +1 -0
- data/lib/fog/oraclecloud/models/compute/security_applications.rb +6 -2
- data/lib/fog/oraclecloud/models/compute/security_association.rb +31 -0
- data/lib/fog/oraclecloud/models/compute/security_associations.rb +20 -0
- data/lib/fog/oraclecloud/models/compute/security_ip_list.rb +27 -0
- data/lib/fog/oraclecloud/models/compute/security_ip_lists.rb +22 -0
- data/lib/fog/oraclecloud/models/compute/security_list.rb +75 -1
- data/lib/fog/oraclecloud/models/compute/security_rule.rb +3 -3
- data/lib/fog/oraclecloud/models/database/access_rule.rb +52 -0
- data/lib/fog/oraclecloud/models/database/access_rules.rb +28 -0
- data/lib/fog/oraclecloud/models/database/instance.rb +17 -4
- data/lib/fog/oraclecloud/monitoring.rb +1 -1
- data/lib/fog/oraclecloud/requests/compute/create_instance.rb +34 -1
- data/lib/fog/oraclecloud/requests/compute/create_ip_association.rb +39 -0
- data/lib/fog/oraclecloud/requests/compute/create_security_application.rb +18 -0
- data/lib/fog/oraclecloud/requests/compute/create_security_association.rb +47 -0
- data/lib/fog/oraclecloud/requests/compute/create_security_ip_list.rb +47 -0
- data/lib/fog/oraclecloud/requests/compute/create_security_list.rb +49 -0
- data/lib/fog/oraclecloud/requests/compute/create_security_rule.rb +22 -0
- data/lib/fog/oraclecloud/requests/compute/delete_security_list.rb +29 -0
- data/lib/fog/oraclecloud/requests/compute/get_ip_association.rb +36 -0
- data/lib/fog/oraclecloud/requests/compute/get_ip_network.rb +1 -1
- data/lib/fog/oraclecloud/requests/compute/get_security_application.rb +21 -1
- data/lib/fog/oraclecloud/requests/compute/get_security_ip_list.rb +37 -0
- data/lib/fog/oraclecloud/requests/compute/get_security_list.rb +37 -0
- data/lib/fog/oraclecloud/requests/compute/get_security_rule.rb +17 -0
- data/lib/fog/oraclecloud/requests/compute/list_ip_associations.rb +28 -0
- data/lib/fog/oraclecloud/requests/compute/list_security_applications.rb +17 -4
- data/lib/fog/oraclecloud/requests/compute/list_security_rules.rb +1 -1
- data/lib/fog/oraclecloud/requests/compute/update_ip_reservation.rb +2 -0
- data/lib/fog/oraclecloud/requests/database/create_access_rule.rb +47 -0
- data/lib/fog/oraclecloud/requests/database/get_access_rule.rb +50 -0
- data/lib/fog/oraclecloud/soa.rb +1 -1
- data/lib/fog/oraclecloud/storage.rb +1 -1
- data/lib/fog/oraclecloud/version.rb +1 -1
- data/tests/requests/database_tests.rb +15 -8
- data/tests/requests/ip_reservation_tests.rb +33 -0
- data/tests/requests/security_application_tests.rb +32 -0
- metadata +23 -2
@@ -7,7 +7,6 @@ module Fog
|
|
7
7
|
identity :name
|
8
8
|
|
9
9
|
attribute :dst_list
|
10
|
-
attribute :name
|
11
10
|
attribute :src_list
|
12
11
|
attribute :uri
|
13
12
|
attribute :disabled
|
@@ -24,11 +23,12 @@ module Fog
|
|
24
23
|
end
|
25
24
|
|
26
25
|
def create
|
27
|
-
requires :name, :src_list, :dst_list, :application
|
26
|
+
requires :name, :src_list, :dst_list, :application
|
28
27
|
|
29
|
-
data = service.create_security_rule(name, src_list, dst_list, application,
|
28
|
+
data = service.create_security_rule(name, src_list, dst_list, application, 'PERMIT',
|
30
29
|
:description => description,
|
31
30
|
:disabled => disabled)
|
31
|
+
merge_attributes(data.body)
|
32
32
|
end
|
33
33
|
|
34
34
|
def destroy
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'fog/core/model'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module OracleCloud
|
5
|
+
class Database
|
6
|
+
class AccessRule < Fog::Model
|
7
|
+
identity :ruleName
|
8
|
+
|
9
|
+
attribute :destination
|
10
|
+
attribute :description
|
11
|
+
attribute :ports
|
12
|
+
attribute :source
|
13
|
+
attribute :status
|
14
|
+
|
15
|
+
attribute :database_id
|
16
|
+
|
17
|
+
def save
|
18
|
+
create
|
19
|
+
end
|
20
|
+
|
21
|
+
def destroy
|
22
|
+
requires :name, :database_id
|
23
|
+
service.delete_snapshot(database_id, name).body
|
24
|
+
end
|
25
|
+
|
26
|
+
# Had to override reload as we need to pass the database_id
|
27
|
+
def reload
|
28
|
+
requires :identity, :database_id
|
29
|
+
|
30
|
+
data = begin
|
31
|
+
collection.get(database_id, identity)
|
32
|
+
rescue Excon::Errors::SocketError
|
33
|
+
nil
|
34
|
+
end
|
35
|
+
|
36
|
+
return unless data
|
37
|
+
|
38
|
+
new_attributes = data.attributes
|
39
|
+
merge_attributes(new_attributes)
|
40
|
+
self
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def create
|
46
|
+
requires :ruleName, :database_id, :source
|
47
|
+
service.create_access_rule(database_id, ruleName, description, ports, source, destination || 'DB', status || 'enabled')
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'fog/core/collection'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module OracleCloud
|
5
|
+
class Database
|
6
|
+
class AccessRules < Fog::Collection
|
7
|
+
|
8
|
+
model Fog::OracleCloud::Database::AccessRule
|
9
|
+
|
10
|
+
def all(db_name)
|
11
|
+
data = service.list_access_rules(db_name).body
|
12
|
+
load(data)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get(db_name, access_rule_name)
|
16
|
+
new(service.get_access_rule(db_name, access_rule_name).body)
|
17
|
+
end
|
18
|
+
|
19
|
+
def create(db_name, attributes = {})
|
20
|
+
attributes[:database_id] = db_name
|
21
|
+
object = new(attributes)
|
22
|
+
object.save
|
23
|
+
object
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -209,6 +209,16 @@ module Fog
|
|
209
209
|
service.scale_instance(service_name, :additional_storage=>size, :usage=>type).body
|
210
210
|
end
|
211
211
|
|
212
|
+
def add_rule(port, ip, rule_name=nil)
|
213
|
+
if !rule_name then rule_name = "#{service_name}_#{port}_#{ip}" end
|
214
|
+
begin
|
215
|
+
rule = service.access_rules.get(service_name, rule_name)
|
216
|
+
rescue Fog::OracleCloud::Database::NotFound
|
217
|
+
Fog::Logger.debug "Add access rule (#{rule_name}) to (#{service_name}) on port #{port}"
|
218
|
+
rule = service.access_rules.create(service_name, :ports=>port, :source=>ip, :destination=>'DB', :ruleName=>rule_name)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
212
222
|
def snapshots
|
213
223
|
requires :service_name
|
214
224
|
service.snapshots.all(service_name)
|
@@ -258,8 +268,11 @@ module Fog
|
|
258
268
|
private
|
259
269
|
|
260
270
|
def create
|
261
|
-
requires :service_name, :
|
271
|
+
requires :service_name, :ssh_key, :admin_password
|
262
272
|
|
273
|
+
if backup_destination.nil? then
|
274
|
+
backup_destination = 'NONE'
|
275
|
+
end
|
263
276
|
if backup_destination != 'NONE' then
|
264
277
|
if cloud_storage_container.nil? then
|
265
278
|
cloud_storage_if_missing = true
|
@@ -277,10 +290,10 @@ module Fog
|
|
277
290
|
|
278
291
|
params = {
|
279
292
|
:service_name => service_name,
|
280
|
-
:edition => edition,
|
293
|
+
:edition => edition || 'SE',
|
281
294
|
:ssh_key => ssh_key,
|
282
|
-
:shape => shape,
|
283
|
-
:version => version,
|
295
|
+
:shape => shape || 'oc3',
|
296
|
+
:version => version || '12.2.0.1',
|
284
297
|
:level => level || 'PAAS',
|
285
298
|
:subscription_type => subscription_type || 'HOURLY',
|
286
299
|
:description => description
|
@@ -39,8 +39,8 @@ module Fog
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def request(params, parse_json = true, &block)
|
42
|
-
pp @connection
|
43
42
|
begin
|
43
|
+
Fog::Logger.debug("Sending #{params[:body].to_s} to #{params[:path]}")
|
44
44
|
response = @connection.request(params.merge!({
|
45
45
|
:headers => {
|
46
46
|
'Authorization' => auth_header,
|
@@ -39,7 +39,40 @@ module Fog
|
|
39
39
|
'imagelist' => imagelist,
|
40
40
|
'label' => label,
|
41
41
|
'sshkeys' => sshkeys,
|
42
|
-
'state' => 'running'
|
42
|
+
'state' => 'running',
|
43
|
+
'account' => "/Compute-#{@identity_domain}/default",
|
44
|
+
'boot_order' => [],
|
45
|
+
'disk_attach' => '',
|
46
|
+
'domain' => "compute-#{@identity_domain}.oraclecloud.internal",
|
47
|
+
'entry' => 1,
|
48
|
+
'error_reason' => '',
|
49
|
+
'hostname' => "mock.compute-#{@identity_domain}.oraclecloud.internal",
|
50
|
+
'hypervisor' => {"mode"=>"hvm"},
|
51
|
+
'image_format' => 'raw',
|
52
|
+
'ip' => '127.0.0.1',
|
53
|
+
'networking'=> {
|
54
|
+
"eth0"=>{
|
55
|
+
"model"=>"",
|
56
|
+
"seclists"=>["/Compute-#{@identity_domain}/default/default"],
|
57
|
+
"dns"=>["mock.compute-#{@identity_domain}.oraclecloud.internal."],
|
58
|
+
"vethernet"=>"/oracle/public/default",
|
59
|
+
"nat"=>nil
|
60
|
+
}
|
61
|
+
},
|
62
|
+
'placement_requirement' => ["/system/compute/placement/default", "/system/compute/allow_instances"],
|
63
|
+
'platform' => 'linux', # Probably? Don't rely on this in mock
|
64
|
+
'priority' => '/oracle/public/default',
|
65
|
+
'quota' => "/Compute-#{@identity_domain}",
|
66
|
+
'quota_reservation' => nil,
|
67
|
+
'resolvers' => nil,
|
68
|
+
'reverse_dns' => true,
|
69
|
+
'site' => '',
|
70
|
+
'storage_attachments' => [],
|
71
|
+
'tags' => [],
|
72
|
+
'uri'=>"#{@api_endpoint}/instance/Compute-#{@identity_domain}/#{@username}/#{name}",
|
73
|
+
'vcable_id'=>"/Compute-#{@identity_domain}/#{@username}/", # TODO: add random id
|
74
|
+
'virtio'=>nil,
|
75
|
+
'vnc'=>'127.0.0.1:5900'
|
43
76
|
}
|
44
77
|
response.status = 201
|
45
78
|
response.body = {
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
def create_ip_association (params)
|
6
|
+
params = params.reject {|key, value| value.nil?}
|
7
|
+
puts Fog::JSON.encode(params)
|
8
|
+
request(
|
9
|
+
:method => 'POST',
|
10
|
+
:expects => 201,
|
11
|
+
:path => "/ip/association/",
|
12
|
+
:body => Fog::JSON.encode(params),
|
13
|
+
:headers => {
|
14
|
+
'Content-Type' => 'application/oracle-compute-v3+json'
|
15
|
+
}
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Mock
|
21
|
+
def create_ip_association (params)
|
22
|
+
response = Excon::Response.new
|
23
|
+
name = SecureRandom.uuid
|
24
|
+
|
25
|
+
self.data[:ip_associations][name] = {
|
26
|
+
'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
|
27
|
+
'account' => "/Compute-#{@identity_domain}/#{@username}",
|
28
|
+
'uri' => "#{@api_endpoint}ip/reservation/Compute-#{@identity_domain}/#{@username}/#{name}",
|
29
|
+
'parentpool' => params[:parentpool],
|
30
|
+
'vcable' => params[:vcable]
|
31
|
+
}
|
32
|
+
response.status = 201
|
33
|
+
response.body = self.data[:ip_associations][name]
|
34
|
+
response
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -23,6 +23,24 @@ module Fog
|
|
23
23
|
)
|
24
24
|
end
|
25
25
|
end
|
26
|
+
|
27
|
+
class Mock
|
28
|
+
def create_security_application(name, protocol, options={})
|
29
|
+
response = Excon::Response.new
|
30
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
31
|
+
|
32
|
+
data = {
|
33
|
+
'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
|
34
|
+
'protcol' => protocol,
|
35
|
+
'uri' => "#{@api_endpoint}seclist/#{name}"
|
36
|
+
}
|
37
|
+
self.data[:security_applications][name] = data
|
38
|
+
|
39
|
+
response.status = 201
|
40
|
+
response.body = self.data[:security_applications][name]
|
41
|
+
response
|
42
|
+
end
|
43
|
+
end
|
26
44
|
end
|
27
45
|
end
|
28
46
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
def create_security_association(name, seclist, vcable)
|
6
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
7
|
+
seclist.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
8
|
+
|
9
|
+
body_data = {
|
10
|
+
'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
|
11
|
+
'seclist' => "/Compute-#{@identity_domain}/#{@username}/#{seclist}",
|
12
|
+
'vcable' => vcable
|
13
|
+
}
|
14
|
+
body_data = body_data.reject {|key, value| value.nil?}
|
15
|
+
request(
|
16
|
+
:method => 'POST',
|
17
|
+
:expects => 201,
|
18
|
+
:path => "/secassociation/",
|
19
|
+
:body => Fog::JSON.encode(body_data),
|
20
|
+
:headers => {
|
21
|
+
'Content-Type' => 'application/oracle-compute-v3+json'
|
22
|
+
}
|
23
|
+
)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
class Mock
|
27
|
+
def create_security_association(name, seclist, vcable)
|
28
|
+
response = Excon::Response.new
|
29
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
30
|
+
seclist.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
31
|
+
|
32
|
+
data = {
|
33
|
+
'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
|
34
|
+
'seclist' => "/Compute-#{@identity_domain}/#{@username}/#{seclist}",
|
35
|
+
'vcable' => vcable,
|
36
|
+
'uri' => "#{@api_endpoint}secassociation/#{name}"
|
37
|
+
}
|
38
|
+
self.data[:security_associations][name] = data
|
39
|
+
|
40
|
+
response.status = 201
|
41
|
+
response.body = self.data[:security_associations][name]
|
42
|
+
response
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
def create_security_ip_list(name, description, secipentries)
|
6
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
7
|
+
|
8
|
+
body_data = {
|
9
|
+
'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
|
10
|
+
'description' => description,
|
11
|
+
'secipentries' => secipentries,
|
12
|
+
}
|
13
|
+
body_data = body_data.reject {|key, value| value.nil?}
|
14
|
+
request(
|
15
|
+
:method => 'POST',
|
16
|
+
:expects => 201,
|
17
|
+
:path => "/seciplist/",
|
18
|
+
:body => Fog::JSON.encode(body_data),
|
19
|
+
:headers => {
|
20
|
+
'Content-Type' => 'application/oracle-compute-v3+json'
|
21
|
+
}
|
22
|
+
)
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Mock
|
28
|
+
def create_security_ip_list(name, description, secipentries)
|
29
|
+
response = Excon::Response.new
|
30
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
31
|
+
|
32
|
+
data = {
|
33
|
+
'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
|
34
|
+
'description' => description,
|
35
|
+
'secipentries' => secipentries,
|
36
|
+
'uri' => "#{@api_endpoint}seclist/#{name}"
|
37
|
+
}
|
38
|
+
self.data[:security_ip_lists][name] = data
|
39
|
+
|
40
|
+
response.status = 201
|
41
|
+
response.body = self.data[:security_ip_lists][name]
|
42
|
+
response
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
def create_security_list(name, description, policy, outbound_policy)
|
6
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
7
|
+
|
8
|
+
body_data = {
|
9
|
+
'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
|
10
|
+
'description' => description,
|
11
|
+
'policy' => policy,
|
12
|
+
'outbound_cidr_policy'=> outbound_policy
|
13
|
+
}
|
14
|
+
body_data = body_data.reject {|key, value| value.nil?}
|
15
|
+
request(
|
16
|
+
:method => 'POST',
|
17
|
+
:expects => 201,
|
18
|
+
:path => "/seclist/",
|
19
|
+
:body => Fog::JSON.encode(body_data),
|
20
|
+
:headers => {
|
21
|
+
'Content-Type' => 'application/oracle-compute-v3+json'
|
22
|
+
}
|
23
|
+
)
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class Mock
|
29
|
+
def create_security_list(name, description, policy, outbound_policy)
|
30
|
+
response = Excon::Response.new
|
31
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
32
|
+
|
33
|
+
data = {
|
34
|
+
'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
|
35
|
+
'description' => description,
|
36
|
+
'policy' => policy,
|
37
|
+
'outbound_cidr_policy'=> outbound_policy,
|
38
|
+
'uri' => "#{@api_endpoint}seclist/#{name}"
|
39
|
+
}
|
40
|
+
self.data[:security_lists][name] = data
|
41
|
+
|
42
|
+
response.status = 201
|
43
|
+
response.body = self.data[:security_lists][name]
|
44
|
+
response
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -24,6 +24,28 @@ module Fog
|
|
24
24
|
)
|
25
25
|
end
|
26
26
|
end
|
27
|
+
class Mock
|
28
|
+
def create_security_rule(name, src_list, dst_list, application, action, options={})
|
29
|
+
response = Excon::Response.new
|
30
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
31
|
+
|
32
|
+
data = {
|
33
|
+
'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
|
34
|
+
'src_list' => src_list,
|
35
|
+
'dst_list' => dst_list,
|
36
|
+
'application' => application,
|
37
|
+
'action' => action,
|
38
|
+
'description' => options[:description],
|
39
|
+
'disabled' => options[:disabled],
|
40
|
+
'uri' => "#{@api_endpoint}secrule/#{name}"
|
41
|
+
}
|
42
|
+
self.data[:security_rules][name] = data
|
43
|
+
|
44
|
+
response.status = 201
|
45
|
+
response.body = self.data[:security_rules][name]
|
46
|
+
response
|
47
|
+
end
|
48
|
+
end
|
27
49
|
end
|
28
50
|
end
|
29
51
|
end
|