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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fog/oraclecloud/compute.rb +395 -6
  3. data/lib/fog/oraclecloud/database.rb +6 -0
  4. data/lib/fog/oraclecloud/java.rb +1 -0
  5. data/lib/fog/oraclecloud/models/compute/instance.rb +64 -2
  6. data/lib/fog/oraclecloud/models/compute/ip_association.rb +42 -0
  7. data/lib/fog/oraclecloud/models/compute/ip_associations.rb +22 -0
  8. data/lib/fog/oraclecloud/models/compute/ip_reservation.rb +10 -5
  9. data/lib/fog/oraclecloud/models/compute/security_application.rb +1 -0
  10. data/lib/fog/oraclecloud/models/compute/security_applications.rb +6 -2
  11. data/lib/fog/oraclecloud/models/compute/security_association.rb +31 -0
  12. data/lib/fog/oraclecloud/models/compute/security_associations.rb +20 -0
  13. data/lib/fog/oraclecloud/models/compute/security_ip_list.rb +27 -0
  14. data/lib/fog/oraclecloud/models/compute/security_ip_lists.rb +22 -0
  15. data/lib/fog/oraclecloud/models/compute/security_list.rb +75 -1
  16. data/lib/fog/oraclecloud/models/compute/security_rule.rb +3 -3
  17. data/lib/fog/oraclecloud/models/database/access_rule.rb +52 -0
  18. data/lib/fog/oraclecloud/models/database/access_rules.rb +28 -0
  19. data/lib/fog/oraclecloud/models/database/instance.rb +17 -4
  20. data/lib/fog/oraclecloud/monitoring.rb +1 -1
  21. data/lib/fog/oraclecloud/requests/compute/create_instance.rb +34 -1
  22. data/lib/fog/oraclecloud/requests/compute/create_ip_association.rb +39 -0
  23. data/lib/fog/oraclecloud/requests/compute/create_security_application.rb +18 -0
  24. data/lib/fog/oraclecloud/requests/compute/create_security_association.rb +47 -0
  25. data/lib/fog/oraclecloud/requests/compute/create_security_ip_list.rb +47 -0
  26. data/lib/fog/oraclecloud/requests/compute/create_security_list.rb +49 -0
  27. data/lib/fog/oraclecloud/requests/compute/create_security_rule.rb +22 -0
  28. data/lib/fog/oraclecloud/requests/compute/delete_security_list.rb +29 -0
  29. data/lib/fog/oraclecloud/requests/compute/get_ip_association.rb +36 -0
  30. data/lib/fog/oraclecloud/requests/compute/get_ip_network.rb +1 -1
  31. data/lib/fog/oraclecloud/requests/compute/get_security_application.rb +21 -1
  32. data/lib/fog/oraclecloud/requests/compute/get_security_ip_list.rb +37 -0
  33. data/lib/fog/oraclecloud/requests/compute/get_security_list.rb +37 -0
  34. data/lib/fog/oraclecloud/requests/compute/get_security_rule.rb +17 -0
  35. data/lib/fog/oraclecloud/requests/compute/list_ip_associations.rb +28 -0
  36. data/lib/fog/oraclecloud/requests/compute/list_security_applications.rb +17 -4
  37. data/lib/fog/oraclecloud/requests/compute/list_security_rules.rb +1 -1
  38. data/lib/fog/oraclecloud/requests/compute/update_ip_reservation.rb +2 -0
  39. data/lib/fog/oraclecloud/requests/database/create_access_rule.rb +47 -0
  40. data/lib/fog/oraclecloud/requests/database/get_access_rule.rb +50 -0
  41. data/lib/fog/oraclecloud/soa.rb +1 -1
  42. data/lib/fog/oraclecloud/storage.rb +1 -1
  43. data/lib/fog/oraclecloud/version.rb +1 -1
  44. data/tests/requests/database_tests.rb +15 -8
  45. data/tests/requests/ip_reservation_tests.rb +33 -0
  46. data/tests/requests/security_application_tests.rb +32 -0
  47. metadata +23 -2
@@ -0,0 +1,29 @@
1
+ module Fog
2
+ module Compute
3
+ class OracleCloud
4
+ class Real
5
+ def delete_security_list(name)
6
+ # Just in case it's already set
7
+ name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
8
+ request(
9
+ :method => 'DELETE',
10
+ :expects => 204,
11
+ :path => "/seclist/Compute-#{@identity_domain}/#{@username}/#{name}",
12
+ :headers => {
13
+ 'Content-Type' => 'application/oracle-compute-v3+json'
14
+ }
15
+ )
16
+ end
17
+ end
18
+ class Mock
19
+ def delete_security_list(name)
20
+ response = Excon::Response.new
21
+ clean_name = name.sub "/Compute-#{@identity_domain}/#{@username}/", ''
22
+ self.data[:security_lists].delete(clean_name)
23
+ response.status = 204
24
+ response
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,36 @@
1
+ module Fog
2
+ module Compute
3
+ class OracleCloud
4
+ class Real
5
+ def get_ip_association(name)
6
+ name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
7
+ response = request(
8
+ :expects => 200,
9
+ :method => 'GET',
10
+ :path => "/ip/association/Compute-#{@identity_domain}/#{@username}/#{name}",
11
+ :headers => {
12
+ 'Content-Type' => 'application/oracle-compute-v3+json',
13
+ 'Accept' => 'application/oracle-compute-v3+json'
14
+ }
15
+ )
16
+ response
17
+ end
18
+ end
19
+
20
+ class Mock
21
+ def get_ip_association(name)
22
+ response = Excon::Response.new
23
+ clean_name = name.sub "/Compute-#{@identity_domain}/#{@username}/", ''
24
+
25
+ if ip = self.data[:ip_associations][clean_name]
26
+ response.status = 200
27
+ response.body = ip
28
+ response
29
+ else;
30
+ raise Fog::Compute::OracleCloud::NotFound.new("IP Association #{name} does not exist");
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -2,7 +2,7 @@ module Fog
2
2
  module Compute
3
3
  class OracleCloud
4
4
  class Real
5
- def get_ip_reservation(name)
5
+ def get_ip_network(name)
6
6
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
7
7
  response = request(
8
8
  :expects => 200,
@@ -3,10 +3,17 @@ module Fog
3
3
  class OracleCloud
4
4
  class Real
5
5
  def get_security_application(name)
6
+ path = "/secapplication"
7
+ name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
8
+ if name.include? '/oracle/public' then
9
+ path += "/#{name}/"
10
+ else
11
+ path += "/Compute-#{@identity_domain}/#{@username}/#{name}/"
12
+ end
6
13
  response = request(
7
14
  :expects => 200,
8
15
  :method => 'GET',
9
- :path => "/secapplication/Compute-#{@identity_domain}/#{@username}/#{name}",
16
+ :path => path,
10
17
  :headers => {
11
18
  'Content-Type' => 'application/oracle-compute-v3+json',
12
19
  'Accept' => 'application/oracle-compute-v3+json'
@@ -15,6 +22,19 @@ module Fog
15
22
  response
16
23
  end
17
24
  end
25
+ class Mock
26
+ def get_security_application(name)
27
+ response = Excon::Response.new
28
+ clean_name = name.sub "/Compute-#{@identity_domain}/#{@username}/", ''
29
+ if app = self.data[:security_applications][clean_name]
30
+ response.status = 200
31
+ response.body = app
32
+ response
33
+ else
34
+ raise Fog::Compute::OracleCloud::NotFound.new("Security application #{name} does not exist");
35
+ end
36
+ end
37
+ end
18
38
  end
19
39
  end
20
40
  end
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module Compute
3
+ class OracleCloud
4
+ class Real
5
+ def get_security_ip_list(name)
6
+ name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
7
+
8
+ response = request(
9
+ :expects => 200,
10
+ :method => 'GET',
11
+ :path => "/seciplist/Compute-#{@identity_domain}/#{@username}/#{name}",
12
+ :headers => {
13
+ 'Content-Type' => 'application/oracle-compute-v3+json',
14
+ 'Accept' => 'application/oracle-compute-v3+json'
15
+ }
16
+ )
17
+ response
18
+ end
19
+ end
20
+
21
+ class Mock
22
+ def get_security_ip_list(name)
23
+ response = Excon::Response.new
24
+ clean_name = name.sub "/Compute-#{@identity_domain}/#{@username}/", ''
25
+
26
+ if instance = self.data[:security_ip_lists][clean_name]
27
+ response.status = 200
28
+ response.body = instance
29
+ response
30
+ else
31
+ raise Fog::Compute::OracleCloud::NotFound.new("Security IP List #{name} does not exist");
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,37 @@
1
+ module Fog
2
+ module Compute
3
+ class OracleCloud
4
+ class Real
5
+ def get_security_list(name)
6
+ name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
7
+
8
+ response = request(
9
+ :expects => 200,
10
+ :method => 'GET',
11
+ :path => "/seclist/Compute-#{@identity_domain}/#{@username}/#{name}",
12
+ :headers => {
13
+ 'Content-Type' => 'application/oracle-compute-v3+json',
14
+ 'Accept' => 'application/oracle-compute-v3+json'
15
+ }
16
+ )
17
+ response
18
+ end
19
+ end
20
+
21
+ class Mock
22
+ def get_security_list(name)
23
+ response = Excon::Response.new
24
+ clean_name = name.sub "/Compute-#{@identity_domain}/#{@username}/", ''
25
+
26
+ if instance = self.data[:security_lists][clean_name]
27
+ response.status = 200
28
+ response.body = instance
29
+ response
30
+ else
31
+ raise Fog::Compute::OracleCloud::NotFound.new("Security List #{name} does not exist");
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -3,6 +3,8 @@ module Fog
3
3
  class OracleCloud
4
4
  class Real
5
5
  def get_security_rule(name)
6
+ name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
7
+
6
8
  response = request(
7
9
  :expects => 200,
8
10
  :method => 'GET',
@@ -15,6 +17,21 @@ module Fog
15
17
  response
16
18
  end
17
19
  end
20
+
21
+ class Mock
22
+ def get_security_rule(name)
23
+ response = Excon::Response.new
24
+ clean_name = name.sub "/Compute-#{@identity_domain}/#{@username}/", ''
25
+
26
+ if instance = self.data[:security_rules][clean_name]
27
+ response.status = 200
28
+ response.body = instance
29
+ response
30
+ else
31
+ raise Fog::Compute::OracleCloud::NotFound.new("Security Rule #{name} does not exist");
32
+ end
33
+ end
34
+ end
18
35
  end
19
36
  end
20
37
  end
@@ -0,0 +1,28 @@
1
+ module Fog
2
+ module Compute
3
+ class OracleCloud
4
+ class Real
5
+ def list_ip_associations
6
+ response = request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => "/ip/association/Compute-#{@identity_domain}/"
10
+ )
11
+ response
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def list_ip_associations
17
+ response = Excon::Response.new
18
+
19
+ ips = self.data[:ip_associations].values
20
+ response.body = {
21
+ 'result' => ips
22
+ }
23
+ response
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -2,18 +2,31 @@ module Fog
2
2
  module Compute
3
3
  class OracleCloud
4
4
  class Real
5
- def list_security_applications
5
+ def list_security_applications(public_list=false)
6
+ path = "/secapplication"
7
+ if public_list then
8
+ path += "/oracle/public/"
9
+ else
10
+ path += "/Compute-#{@identity_domain}/#{@username}/"
11
+ end
6
12
  response = request(
7
13
  :expects => 200,
8
14
  :method => 'GET',
9
- :path => "/secapplication/Compute-#{@identity_domain}/#{@username}/"
15
+ :path => path
10
16
  )
11
17
  response
12
18
  end
13
19
  end
14
-
15
20
  class Mock
16
- def list_security_applications
21
+ def list_security_applications(public_list=false)
22
+ response = Excon::Response.new
23
+ if public_list then check = "/oracle/public"
24
+ else check = "/Compute-" end
25
+ instances = self.data[:security_applications].values.select { |app| app['name'].include? check}
26
+ response.body = {
27
+ 'result' => instances
28
+ }
29
+ response
17
30
  end
18
31
  end
19
32
  end
@@ -13,7 +13,7 @@ module Fog
13
13
  end
14
14
 
15
15
  class Mock
16
- def list_security_applications
16
+ def list_security_rules
17
17
  end
18
18
  end
19
19
  end
@@ -5,6 +5,8 @@ module Fog
5
5
  class OracleCloud
6
6
  class Real
7
7
  def update_ip_reservation (params)
8
+ params[:name].sub! "/Compute-#{@identity_domain}/#{@username}/", ''
9
+ params[:name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:name]}"
8
10
  params = params.reject {|key, value| value.nil?}
9
11
  request(
10
12
  :method => 'PUT',
@@ -0,0 +1,47 @@
1
+ module Fog
2
+ module OracleCloud
3
+ class Database
4
+ class Real
5
+
6
+ def create_access_rule(service_name, name, description, ports, source, destination, status)
7
+ body_data = {
8
+ 'ruleName' => name,
9
+ 'description' => description,
10
+ 'destination' => destination,
11
+ 'ports' => ports,
12
+ 'source' => source,
13
+ 'status' => status
14
+ }
15
+ response = request(
16
+ :method => 'POST',
17
+ :expects => 202,
18
+ :path => "/paas/api/v1.1/instancemgmt/#{@identity_domain}/services/dbaas/instances/#{service_name}/accessrules",
19
+ :body => Fog::JSON.encode(body_data),
20
+ )
21
+ response
22
+ end
23
+ end
24
+
25
+ class Mock
26
+ def create_access_rule(service_name, name, description, ports, source, destination, status)
27
+ response = Excon::Response.new
28
+
29
+ data = {
30
+ 'ruleName' => name,
31
+ 'description' => description,
32
+ 'status' => status,
33
+ 'source' => source,
34
+ 'destination'=>destination,
35
+ 'ports'=>ports,
36
+ 'ruleType'=>'USER',
37
+ 'database_id'=>service_name
38
+ }
39
+ if !self.data[:access_rules].key?(service_name) then self.data[:access_rules][service_name] = {} end
40
+ self.data[:access_rules][service_name][name] = data
41
+ response.status = 202
42
+ response
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,50 @@
1
+ module Fog
2
+ module OracleCloud
3
+ class Database
4
+ class Real
5
+
6
+ def get_access_rule(db_name, rule_name)
7
+ # There isn't actually an API for this. So just get all of them and find the one they wanted
8
+ response = request(
9
+ :expects => 200,
10
+ :method => 'GET',
11
+ :path => "/paas/api/v1.1/instancemgmt/#{@identity_domain}/services/dbaas/instances/#{db_name}/accessrules"
12
+ )
13
+ rule = response.body["accessRules"].detect { |r| r['ruleName'] == rule_name}
14
+ if rule.nil? then
15
+ raise Fog::OracleCloud::Database::NotFound.new("Could not find rule (#{rule_name}) attached to #{service_name}")
16
+ end
17
+ response.body = rule
18
+ response
19
+ end
20
+ end
21
+
22
+ class Mock
23
+ def get_snapshot(db_name, snapshot_name)
24
+ response = Excon::Response.new
25
+
26
+ if snapshot = self.data[:snapshots][db_name][snapshot_name]
27
+ case snapshot['status']
28
+ when 'Terminating'
29
+ if Time.now - self.data[:deleted_at][snapshot_name] >= Fog::Mock.delay
30
+ self.data[:deleted_at].delete(snapshot_name)
31
+ self.data[:snapshots][db_name].delete(snapshot_name)
32
+ end
33
+ when 'In Progress'
34
+ if Time.now - self.data[:created_at][snapshot_name] >= Fog::Mock.delay
35
+ self.data[:snapshots][db_name][snapshot_name]['status'] = 'Succeeded'
36
+ snapshot = self.data[:snapshots][db_name][snapshot_name]
37
+ self.data[:created_at].delete(snapshot_name)
38
+ end
39
+ end
40
+ response.status = 200
41
+ response.body = snapshot
42
+ response
43
+ else
44
+ raise Fog::OracleCloud::Database::NotFound.new("Snapshot #{snapshot_name} for #{db_name} does not exist");
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -40,8 +40,8 @@ module Fog
40
40
  end
41
41
 
42
42
  def request(params, parse_json = true, &block)
43
-
44
43
  begin
44
+ Fog::Logger.debug("Sending #{params[:body].to_s} to #{params[:path]}")
45
45
  response = @connection.request(params.merge!({
46
46
  :headers => {
47
47
  'Authorization' => auth_header,
@@ -29,8 +29,8 @@ module Fog
29
29
  end
30
30
 
31
31
  def authenticate()
32
-
33
32
  begin
33
+ Fog::Logger.debug("Sending #{params[:body].to_s} to #{params[:path]}")
34
34
  response = @connection.request({
35
35
  :expects => 200,
36
36
  :method => 'GET',
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module OracleCloud
3
- VERSION = "0.1.15"
3
+ VERSION = "0.1.16"
4
4
  end
5
5
  end
@@ -3,18 +3,25 @@ require 'pp'
3
3
  Shindo.tests('Fog::Database[oraclecloud] | database requests', 'database') do
4
4
 
5
5
  tests("#database-create", "create") do
6
+ #db = Fog::OracleCloud[:database].instances.create(
7
+ # :service_name => 'TestDB',
8
+ # :description => 'A new database',
9
+ # :edition => 'SE',
10
+ # :ssh_key => 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAkNNQ4ri2oUW46mBO/4CHMGCOALciumwGvFEMDLGNnlDbUSqU4IRrqgj+znLClfb29Oer0devdarM6DilsZVgZ2YbI5ZD5vICR/O9J0c28dArwbtFeIjcV2TCWyj5xKEXF1r+OrJMexHQa0fW1URGrU8QODpJNC/9eCVGcEXddL31xTZYpjoVOCVx66kNa6lSHEVV3T4zaCby9Oe5QI4gZe1+xyxHPNEW5wogwS3dlKSyL2CfBP0aUKOmJ5Nrl8+y0GqJQXdGjZ9FIknmwWueRW/6qPQvZocjOZ8YiPZgAP0RNy6lL+u8mnAazj/mrEdmB5QUzpDAllIr5Tn/xaddZQ==',
11
+ # :shape => 'oc3',
12
+ # :version => '12.1.0.2',
13
+ # :backup_destination => 'NONE',
14
+ # :admin_password => 'Welcome1#',
15
+ # :usable_storage => '15'
16
+ #)
17
+ # Minimum options
6
18
  db = Fog::OracleCloud[:database].instances.create(
7
19
  :service_name => 'TestDB',
8
- :description => 'A new database',
9
- :edition => 'SE',
10
20
  :ssh_key => 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAkNNQ4ri2oUW46mBO/4CHMGCOALciumwGvFEMDLGNnlDbUSqU4IRrqgj+znLClfb29Oer0devdarM6DilsZVgZ2YbI5ZD5vICR/O9J0c28dArwbtFeIjcV2TCWyj5xKEXF1r+OrJMexHQa0fW1URGrU8QODpJNC/9eCVGcEXddL31xTZYpjoVOCVx66kNa6lSHEVV3T4zaCby9Oe5QI4gZe1+xyxHPNEW5wogwS3dlKSyL2CfBP0aUKOmJ5Nrl8+y0GqJQXdGjZ9FIknmwWueRW/6qPQvZocjOZ8YiPZgAP0RNy6lL+u8mnAazj/mrEdmB5QUzpDAllIr5Tn/xaddZQ==',
11
- :shape => 'oc3',
12
- :version => '12.1.0.2',
13
- :backup_destination => 'NONE',
14
21
  :admin_password => 'Welcome1#',
15
- :usable_storage => '15'
16
22
  )
17
23
 
24
+
18
25
  test "can create a database" do
19
26
  db.is_a? Fog::OracleCloud::Database::Instance
20
27
  end
@@ -49,7 +56,6 @@ Shindo.tests('Fog::Database[oraclecloud] | database requests', 'database') do
49
56
  db.wait_for { ready? }
50
57
  db.ready?
51
58
  end
52
-
53
59
  end
54
60
 
55
61
  tests("#database-attributes", "attributes") do
@@ -66,7 +72,8 @@ Shindo.tests('Fog::Database[oraclecloud] | database requests', 'database') do
66
72
  end
67
73
 
68
74
  tests('#database-read') do
69
- instances = Fog::OracleCloud[:database].instances
75
+ instances = Fog::OracleCloud[:database].instances.all
76
+
70
77
  test "returns an Array" do
71
78
  instances.is_a? Array
72
79
  end