fog-oraclecloud 0.1.16 → 0.1.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9f9ad74ac0b9188a2b139801bfcae16b9899b9fd
4
- data.tar.gz: b45fb66290683793a7fa5b7ab1a4e4a3769cb960
3
+ metadata.gz: 957f4b17a9cd35a509e3e36a143601554f65af0e
4
+ data.tar.gz: 90772e01330a112d5d1e59f1155a6c97d4337fd3
5
5
  SHA512:
6
- metadata.gz: b66da260963aef98195ad8313c159f437bce2d8afe5f36daafa0b85e93142412e0a1782524a09e07af98a253566370b5334a715c97e04ec4eebea072863d6d68
7
- data.tar.gz: c509903acc75d3ba4a8366c0cdbb2c901e1f49f2017169fd04ca03598ac81cb3750a55be58102c7d9ec5ea6adb266efaf8f7bfdfbdd45327595a9e9e9275a819
6
+ metadata.gz: 1fa4a5478e1b4df84d3e4708b4f00f976294aef8e2ec1466ddcd5e37e6c0e10c0fae2a691355b64b2d9d4d57c682e5fd5fa9c96e1c367347a829d5e4be7f7065
7
+ data.tar.gz: 82399fc788831cbc2568eef8421c3f84344a3f35559de16b08fb4e1237a242ea8478ee82b24cb5edbe99d9b6e3e5efb2a2b2f2a1b58b743eee48cf846a570e74
data/README.md CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- Before you can use fog-aws, you must require it in your application:
23
+ Before you can use fog-oraclecloud, you must require it in your application:
24
24
 
25
25
  ```ruby
26
26
  require 'fog/oraclecloud'
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "fog/oracle"
4
+ require "fog/oraclecloud"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -161,7 +161,7 @@ module Fog
161
161
 
162
162
  def request(params, parse_json = true, &block)
163
163
  begin
164
- Fog::Logger.debug("Sending #{params[:body].to_s} to #{params[:path]}")
164
+ Fog::Logger.debug("Sending #{params[:body].to_s} to (#{params[:method]}):#{params[:path]}")
165
165
  response = @connection.request(params.merge!({
166
166
  :headers => {
167
167
  'Cookie' => @auth_cookie
@@ -37,8 +37,11 @@ module Fog
37
37
  request :backup_instance
38
38
  request :recover_instance
39
39
  request :list_patches
40
+
40
41
  request :create_access_rule
41
42
  request :get_access_rule
43
+ request :list_access_rules
44
+
42
45
 
43
46
  class Real
44
47
 
@@ -48,7 +51,7 @@ module Fog
48
51
  @identity_domain = options[:oracle_domain]
49
52
  region_url = options[:oracle_region] == 'emea' ? 'https://dbcs.emea.oraclecloud.com' : 'https://dbaas.oraclecloud.com'
50
53
  Excon.ssl_verify_peer = false
51
-
54
+ Fog::Logger.debug("Using region_url #{region_url}")
52
55
  @connection = Fog::XML::Connection.new(region_url)
53
56
  end
54
57
 
@@ -66,7 +69,7 @@ module Fog
66
69
 
67
70
  def request(params, parse_json = true, &block)
68
71
  begin
69
- Fog::Logger.debug("Sending #{params[:body].to_s} to #{params[:path]}")
72
+ Fog::Logger.debug("Sending #{params[:body].to_s} to (#{params[:method]}):#{params[:path]}")
70
73
  response = @connection.request(params.merge!({
71
74
  :headers => {
72
75
  'Authorization' => auth_header,
@@ -8,7 +8,7 @@ module Fog
8
8
  model Fog::OracleCloud::Database::AccessRule
9
9
 
10
10
  def all(db_name)
11
- data = service.list_access_rules(db_name).body
11
+ data = service.list_access_rules(db_name).body['accessRules']
12
12
  load(data)
13
13
  end
14
14
 
@@ -209,10 +209,20 @@ module Fog
209
209
  service.scale_instance(service_name, :additional_storage=>size, :usage=>type).body
210
210
  end
211
211
 
212
+ def access_rules
213
+ requires :service_name
214
+ service.access_rules.all(service_name)
215
+ end
216
+
217
+ def get_access_rule(rule_name)
218
+ requires :service_name
219
+ service.access_rules.get(service_name, rule_name)
220
+ end
221
+
212
222
  def add_rule(port, ip, rule_name=nil)
213
223
  if !rule_name then rule_name = "#{service_name}_#{port}_#{ip}" end
214
224
  begin
215
- rule = service.access_rules.get(service_name, rule_name)
225
+ rule = get_access_rule(rule_name)
216
226
  rescue Fog::OracleCloud::Database::NotFound
217
227
  Fog::Logger.debug "Add access rule (#{rule_name}) to (#{service_name}) on port #{port}"
218
228
  rule = service.access_rules.create(service_name, :ports=>port, :source=>ip, :destination=>'DB', :ruleName=>rule_name)
@@ -8,7 +8,7 @@ module Fog
8
8
  model Fog::OracleCloud::Database::Patch
9
9
 
10
10
  def all(db_name)
11
- data = service.list_patches(db_name).body['availablePatches']
11
+ data = service.list_patches(db_name).body
12
12
  load(data)
13
13
  end
14
14
 
@@ -70,7 +70,7 @@ module Fog
70
70
  'storage_attachments' => [],
71
71
  'tags' => [],
72
72
  'uri'=>"#{@api_endpoint}/instance/Compute-#{@identity_domain}/#{@username}/#{name}",
73
- 'vcable_id'=>"/Compute-#{@identity_domain}/#{@username}/", # TODO: add random id
73
+ 'vcable_id'=>"/Compute-#{@identity_domain}/#{@username}/#{SecureRandom.uuid}", # TODO: add random id
74
74
  'virtio'=>nil,
75
75
  'vnc'=>'127.0.0.1:5900'
76
76
  }
@@ -29,6 +29,13 @@ module Fog
29
29
  'parentpool' => params[:parentpool],
30
30
  'vcable' => params[:vcable]
31
31
  }
32
+ instance = self.data[:instances].detect { |i|i[1]['vcable_id'] = params[:vcable]}
33
+ if instance.nil? then
34
+ # TODO: Add error handling. And don't create ip association
35
+ else
36
+ # Update it's networking
37
+ instance[1]['networking']['eth0']['nat']="#{params[:parentpool]}"
38
+ end
32
39
  response.status = 201
33
40
  response.body = self.data[:ip_associations][name]
34
41
  response
@@ -26,7 +26,6 @@ module Fog
26
26
  response = Excon::Response.new
27
27
  name = params[:name]
28
28
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
29
-
30
29
  self.data[:ip_reservations][name] = {
31
30
  'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
32
31
  'account' => "/Compute-#{@identity_domain}/#{@username}",
@@ -21,7 +21,6 @@ module Fog
21
21
  def get_ip_association(name)
22
22
  response = Excon::Response.new
23
23
  clean_name = name.sub "/Compute-#{@identity_domain}/#{@username}/", ''
24
-
25
24
  if ip = self.data[:ip_associations][clean_name]
26
25
  response.status = 200
27
26
  response.body = ip
@@ -21,7 +21,6 @@ module Fog
21
21
  def get_ip_reservation(name)
22
22
  response = Excon::Response.new
23
23
  clean_name = name.sub "/Compute-#{@identity_domain}/#{@username}/", ''
24
-
25
24
  if ip = self.data[:ip_reservations][clean_name]
26
25
  response.status = 200
27
26
  response.body = ip
@@ -36,8 +36,8 @@ module Fog
36
36
  'ruleType'=>'USER',
37
37
  'database_id'=>service_name
38
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
39
+ if !self.data[:access_rules].key?(service_name) then self.data[:access_rules][service_name] = [] end
40
+ self.data[:access_rules][service_name] << data
41
41
  response.status = 202
42
42
  response
43
43
  end
@@ -91,6 +91,18 @@ module Fog
91
91
  "hostname"=>"db12c-xp-rac1"
92
92
  }
93
93
  self.data[:servers][config[:service_name]] = [node]
94
+
95
+ # And some access rules
96
+ if self.data[:access_rules][config[:service_name]].nil? then self.data[:access_rules][config[:service_name]] = [] end
97
+ self.data[:access_rules][config[:service_name]] << {
98
+ "ruleName"=>"ora_p2_ssh",
99
+ "destination"=>"DB",
100
+ "ports"=>22,
101
+ "source"=>"PUBLIC-INTERNET",
102
+ "status"=>"enabled",
103
+ "database_id"=>config[:service_name]
104
+ }
105
+
94
106
  response.headers['Location'] = "https://dbaas.oraclecloud.com:443/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}/status/create/job/#{job_id}"
95
107
  response.status = 202
96
108
  response
@@ -12,7 +12,7 @@ module Fog
12
12
  )
13
13
  rule = response.body["accessRules"].detect { |r| r['ruleName'] == rule_name}
14
14
  if rule.nil? then
15
- raise Fog::OracleCloud::Database::NotFound.new("Could not find rule (#{rule_name}) attached to #{service_name}")
15
+ raise Fog::OracleCloud::Database::NotFound.new("Could not find rule (#{rule_name}) attached to #{db_name}")
16
16
  end
17
17
  response.body = rule
18
18
  response
@@ -20,28 +20,17 @@ module Fog
20
20
  end
21
21
 
22
22
  class Mock
23
- def get_snapshot(db_name, snapshot_name)
23
+ def get_access_rule(db_name, rule_name)
24
24
  response = Excon::Response.new
25
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
26
+ rule = self.data[:access_rules][db_name].detect { |r| r['ruleName'] == rule_name}
27
+
28
+ if !rule.nil? then
40
29
  response.status = 200
41
- response.body = snapshot
30
+ response.body = rule
42
31
  response
43
32
  else
44
- raise Fog::OracleCloud::Database::NotFound.new("Snapshot #{snapshot_name} for #{db_name} does not exist");
33
+ raise Fog::OracleCloud::Database::NotFound.new("Rule #{rule_name} for #{db_name} does not exist");
45
34
  end
46
35
  end
47
36
  end
@@ -0,0 +1,30 @@
1
+ module Fog
2
+ module OracleCloud
3
+ class Database
4
+ class Real
5
+ def list_access_rules(db_name)
6
+ response = request(
7
+ :expects => 200,
8
+ :method => 'GET',
9
+ :path => "/paas/api/v1.1/instancemgmt/#{@identity_domain}/services/dbaas/instances/#{db_name}/accessrules"
10
+ )
11
+ response
12
+ end
13
+ end
14
+
15
+ class Mock
16
+ def list_access_rules(db_name)
17
+ response = Excon::Response.new
18
+
19
+ if !self.data[:access_rules][db_name] then self.data[:access_rules][db_name] = [] end
20
+ access_rules = self.data[:access_rules][db_name]
21
+
22
+ response.body = {
23
+ 'accessRules' => access_rules
24
+ }
25
+ response
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -6,7 +6,7 @@ module Fog
6
6
  response = request(
7
7
  :expects => 200,
8
8
  :method => 'GET',
9
- :path => "/paas/service/dbcs/api/v1.1/instances/#{@identity_domain}/#{db_name}/patches"
9
+ :path => "/paas/api/v1.1/instancemgmt/#{@identity_domain}/services/dbaas/instances/#{db_name}/patches/available"
10
10
  )
11
11
  response
12
12
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module OracleCloud
3
- VERSION = "0.1.16"
3
+ VERSION = "0.1.17"
4
4
  end
5
5
  end
@@ -55,4 +55,13 @@ Shindo.tests('Fog::Compute[oraclecloud] | compute requests', 'compute') do
55
55
  rule = Fog::Compute[:oraclecloud].ip_reservations.get(ip_name)
56
56
  end
57
57
  end
58
+
59
+ tests("#ip-association", "create") do
60
+ test "it can add a public ip" do
61
+ compute = Fog::Compute[:oraclecloud].instances.create(:name=>'Test', :sshkeys=>['TestSSHKey'])
62
+ compute.wait_for { ready? }
63
+ compute.add_public_ip_address
64
+ compute.get_public_ip_address.is_a? String
65
+ end
66
+ end
58
67
  end
@@ -127,6 +127,18 @@ Shindo.tests('Fog::Database[oraclecloud] | database requests', 'database') do
127
127
  end
128
128
  end
129
129
 
130
+ tests("#database-access_rules") do
131
+ instance = Fog::OracleCloud[:database].instances.first
132
+ access_rules = instance.access_rules
133
+ test "should get access_rules" do
134
+ access_rules.is_a? Array
135
+ end
136
+ test "should get rule" do
137
+ rule = instance.get_access_rule('ora_p2_ssh')
138
+ rule.ruleName == 'ora_p2_ssh'
139
+ end
140
+ end
141
+
130
142
  tests("#database-recoveries-create", "create") do
131
143
  instance = Fog::OracleCloud[:database].instances.first
132
144
  tag = instance.backups.first.db_tag
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-oraclecloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Nation
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-12 00:00:00.000000000 Z
11
+ date: 2017-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -301,6 +301,7 @@ files:
301
301
  - lib/fog/oraclecloud/requests/database/get_instance.rb
302
302
  - lib/fog/oraclecloud/requests/database/get_instance_from_job.rb
303
303
  - lib/fog/oraclecloud/requests/database/get_snapshot.rb
304
+ - lib/fog/oraclecloud/requests/database/list_access_rules.rb
304
305
  - lib/fog/oraclecloud/requests/database/list_backups.rb
305
306
  - lib/fog/oraclecloud/requests/database/list_instances.rb
306
307
  - lib/fog/oraclecloud/requests/database/list_patches.rb