fog-scaleway 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5303513c33ef6ae3857f4151f5ca012fa86d2c47
4
- data.tar.gz: 9a223682b88e327c3e9cd08d296eb35ba71e7da2
3
+ metadata.gz: 51b03e240e9f4cd20d0e1fa7720d3f7ee8ba5bb3
4
+ data.tar.gz: 16d35624f89537158d15e49f1f234ec6435c9ad6
5
5
  SHA512:
6
- metadata.gz: 6320bec3011290491e7afee7e0ce68a3431f04efa20c8a8c2d439bb7c21f06fc0515570d8ef0964faff0b20bc184ca390bbcfbdbb03a493a4e8e44710de50cc0
7
- data.tar.gz: 8714c0dc342be29bb5ff57fd359fd3706b6d43778f2674687ab4fc3538bc2702e20ede17e48495aaf4155f6e015d509bc65515531ce61bcb930c99ed80399a41
6
+ metadata.gz: dcc876f2188e9e01af2598617028b98d7b6306bcbcf5851272402773e5d5dca816071b4d68ce539b0a44d1da3e1e853c53830cd3b04f2a0faa365719d17012d9
7
+ data.tar.gz: d500fe46c3a918d3e67fddd2a9d25d369ce6c2cb03f5f70e02fee0527fad556fe4aeec9a49bc0b589037b3f1254219320ab1f75312b687d6379787ef39e9956a
data/.rubocop.yml ADDED
@@ -0,0 +1,7 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ AllCops:
4
+ DisplayCopNames: true
5
+
6
+ Style/GuardClause:
7
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,23 @@
1
+ Metrics/AbcSize:
2
+ Enabled: false
3
+
4
+ Metrics/ClassLength:
5
+ Enabled: false
6
+
7
+ Metrics/CyclomaticComplexity:
8
+ Enabled: false
9
+
10
+ Metrics/LineLength:
11
+ Enabled: false
12
+
13
+ Metrics/MethodLength:
14
+ Enabled: false
15
+
16
+ Metrics/ParameterLists:
17
+ Enabled: false
18
+
19
+ Metrics/PerceivedComplexity:
20
+ Enabled: false
21
+
22
+ Style/Documentation:
23
+ Enabled: false
data/.travis.yml CHANGED
@@ -7,3 +7,4 @@ before_install:
7
7
  script:
8
8
  - bundle exec rake test:units FOG_MOCK=true COVERAGE=true
9
9
  - bundle exec rake test:integration FOG_MOCK=true
10
+ - bundle exec rake rubocop
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
1
  # Fog::Scaleway
2
2
 
3
+ [![Gem](https://img.shields.io/gem/v/fog-scaleway.svg?style=flat-square)](https://rubygems.org/gems/fog-scaleway)
3
4
  [![Travis](https://img.shields.io/travis/kaorimatz/fog-scaleway.svg?style=flat-square)](https://travis-ci.org/kaorimatz/fog-scaleway)
4
5
  [![Coveralls](https://img.shields.io/coveralls/kaorimatz/fog-scaleway.svg?style=flat-square)](https://coveralls.io/github/kaorimatz/fog-scaleway)
6
+ [![Gemnasium](https://img.shields.io/gemnasium/kaorimatz/fog-scaleway.svg?style=flat-square)](https://gemnasium.com/kaorimatz/fog-scaleway)
5
7
 
6
8
  Fog provider gem to support [Scaleway](https://www.scaleway.com/).
7
9
 
@@ -10,7 +12,7 @@ Fog provider gem to support [Scaleway](https://www.scaleway.com/).
10
12
  Add this line to your application's Gemfile:
11
13
 
12
14
  ```ruby
13
- gem 'fog-scaleway', git: 'https://github.com/kaorimatz/fog-scaleway.git'
15
+ gem 'fog-scaleway'
14
16
  ```
15
17
 
16
18
  And then execute:
@@ -23,8 +25,9 @@ Put your credentials to the fog configuration file:
23
25
 
24
26
  ```yaml
25
27
  default:
26
- scaleway_organization: <YOUR_ORGANIZATION_UUID>
27
- scaleway_token: <YOUR_TOKEN>
28
+ scaleway_organization: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # Your organization ID
29
+ scaleway_token: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx # Your token
30
+ scaleway_region: par1 # par1 or ams1
28
31
  ```
29
32
 
30
33
  Create a connection to the service:
@@ -45,7 +48,7 @@ server.terminate
45
48
 
46
49
  ## Development
47
50
 
48
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test:integration` to run the integration tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
51
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test FOG_MOCK=true` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
49
52
 
50
53
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
51
54
 
data/Rakefile CHANGED
@@ -2,20 +2,23 @@ require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
3
  require 'rubocop/rake_task'
4
4
 
5
- Rake::TestTask.new do |t|
5
+ Rake::TestTask.new('test:units') do |t|
6
6
  t.libs << 'test'
7
- t.name = 'test:units'
8
7
  t.description = 'Run unit tests'
9
8
  t.test_files = FileList['test/units/**/test_*.rb']
10
9
  t.warning = false
11
10
  end
12
11
 
13
- Rake::TestTask.new do |t|
12
+ Rake::TestTask.new('test:integration') do |t|
14
13
  t.libs << 'test'
15
- t.name = 'test:integration'
16
14
  t.description = 'Run integration tests'
17
15
  t.test_files = FileList['test/integration/**/test_*.rb']
18
16
  t.warning = false
19
17
  end
20
18
 
21
- RuboCop::RakeTask.new
19
+ desc 'Run all tests'
20
+ task test: ['test:units', 'test:integration']
21
+
22
+ RuboCop::RakeTask.new(:rubocop)
23
+
24
+ task default: [:test, :rubocop]
@@ -12,9 +12,10 @@ module Fog
12
12
  class Conflict < Error; end
13
13
  class APIError < Error; end
14
14
 
15
- requires :scaleway_token
16
- requires :scaleway_organization
17
- secrets :scaleway_token
15
+ requires :scaleway_token
16
+ requires :scaleway_organization
17
+ recognizes :scaleway_region
18
+ secrets :scaleway_token
18
19
 
19
20
  model_path 'fog/scaleway/models/compute'
20
21
 
@@ -114,6 +115,7 @@ module Fog
114
115
  def initialize(options)
115
116
  @token = options[:scaleway_token]
116
117
  @organization = options[:scaleway_organization]
118
+ @region = options[:scaleway_region] || 'par1'
117
119
  end
118
120
 
119
121
  def request(params)
@@ -138,7 +140,11 @@ module Fog
138
140
  private
139
141
 
140
142
  def client
141
- @client ||= Fog::Scaleway::Client.new('https://api.scaleway.com', @token)
143
+ @client ||= Fog::Scaleway::Client.new(endpoint, @token)
144
+ end
145
+
146
+ def endpoint
147
+ "https://cp-#{@region}.scaleway.com"
142
148
  end
143
149
 
144
150
  def camelize(str)
@@ -30,7 +30,7 @@ module Fog
30
30
 
31
31
  def create
32
32
  options = {}
33
- options[:expires] = !!expires unless expires.nil?
33
+ options[:expires] = expires != false unless expires.nil?
34
34
 
35
35
  if (token = service.create_token(options).body['token'])
36
36
  merge_attributes(token)
@@ -45,7 +45,7 @@ module Fog
45
45
 
46
46
  options = {}
47
47
  options[:description] = description unless description.nil?
48
- options[:expires] = !!expires unless expires.nil?
48
+ options[:expires] = expires != false unless expires.nil?
49
49
 
50
50
  if (token = service.update_token(identity, options).body['token'])
51
51
  merge_attributes(token)
@@ -106,49 +106,34 @@ module Fog
106
106
  def poweron(async = true)
107
107
  requires :identity
108
108
 
109
- if (task = service.execute_server_action(identity, 'poweron').body['task'])
110
- service.tasks.new(task).tap do |task|
111
- unless async
112
- task.wait_for { task.success? }
113
- reload
114
- end
115
- end
116
- end
109
+ execute_action('poweron', async)
117
110
  end
118
111
 
119
112
  def poweroff(async = true)
120
113
  requires :identity
121
114
 
122
- if (task = service.execute_server_action(identity, 'poweroff').body['task'])
123
- service.tasks.new(task).tap do |task|
124
- unless async
125
- task.wait_for { task.success? }
126
- reload
127
- end
128
- end
129
- end
115
+ execute_action('poweroff', async)
130
116
  end
131
117
 
132
118
  def reboot(async = true)
133
119
  requires :identity
134
120
 
135
- if (task = service.execute_server_action(identity, 'reboot').body['task'])
136
- service.tasks.new(task).tap do |task|
137
- unless async
138
- task.wait_for { task.success? }
139
- reload
140
- end
141
- end
142
- end
121
+ execute_action('reboot', async)
143
122
  end
144
123
 
145
124
  def terminate(async = true)
146
125
  requires :identity
147
126
 
148
- if (task = service.execute_server_action(identity, 'terminate').body['task'])
149
- service.tasks.new(task).tap do |task|
127
+ execute_action('terminate', async)
128
+ end
129
+
130
+ def execute_action(action, async = true)
131
+ requires :identity
132
+
133
+ if (task = service.execute_server_action(identity, action).body['task'])
134
+ service.tasks.new(task).tap do |t|
150
135
  unless async
151
- task.wait_for { task.success? }
136
+ t.wait_for { t.success? }
152
137
  reload
153
138
  end
154
139
  end
@@ -31,8 +31,8 @@ module Fog
31
31
 
32
32
  body = jsonify(body)
33
33
 
34
- user = data[:users].values.find do |user|
35
- user['email'] == body['email']
34
+ user = data[:users].values.find do |u|
35
+ u['email'] == body['email']
36
36
  end
37
37
 
38
38
  raise_invalid_auth('Invalid credentials') unless user
@@ -11,7 +11,7 @@ module Fog
11
11
  def delete_security_group_rule(security_group_id, rule_id)
12
12
  security_group = lookup(:security_groups, security_group_id)
13
13
 
14
- unless data[:security_group_rules][security_group_id].delete(rule_id)
14
+ unless data[:security_group_rules][security_group['id']].delete(rule_id)
15
15
  raise_unknown_resource(rule_id)
16
16
  end
17
17
 
@@ -41,6 +41,7 @@ module Fog
41
41
  'platform_id' => Fog::Mock.random_numbers(2),
42
42
  'node_id' => Fog::Mock.random_numbers(2),
43
43
  'cluster_id' => Fog::Mock.random_numbers(2),
44
+ 'zone_id' => @region,
44
45
  'chassis_id' => Fog::Mock.random_numbers(2)
45
46
  }
46
47
 
@@ -2,13 +2,13 @@ module Fog
2
2
  module Scaleway
3
3
  class Compute
4
4
  class Real
5
- def get_dashboard
5
+ def get_dashboard # rubocop:disable Style/AccessorMethodName
6
6
  get('/dashboard')
7
7
  end
8
8
  end
9
9
 
10
10
  class Mock
11
- def get_dashboard
11
+ def get_dashboard # rubocop:disable Style/AccessorMethodName
12
12
  running_servers = data[:servers].select do |_id, s|
13
13
  s['state'] == 'running'
14
14
  end
@@ -11,7 +11,7 @@ module Fog
11
11
  def get_security_group_rule(security_group_id, rule_id)
12
12
  security_group = lookup(:security_groups, security_group_id)
13
13
 
14
- rule = data[:security_group_rules][security_group_id][rule_id]
14
+ rule = data[:security_group_rules][security_group['id']][rule_id]
15
15
 
16
16
  raise_unknown_resource(rule_id) unless rule
17
17
 
@@ -11,7 +11,7 @@ module Fog
11
11
  def list_security_group_rules(security_group_id)
12
12
  security_group = lookup(:security_groups, security_group_id)
13
13
 
14
- rules = data[:security_group_rules][security_group_id].values
14
+ rules = data[:security_group_rules][security_group['id']].values
15
15
 
16
16
  response(status: 200, body: { 'rules' => rules })
17
17
  end
@@ -17,7 +17,7 @@ module Fog
17
17
  lookup(:bootscripts, body['bootscript']['id'])
18
18
  elsif body['bootscript'].is_a?(String)
19
19
  lookup(:bootscripts, body['bootscript'])
20
- end
20
+ end
21
21
 
22
22
  volumes = {}
23
23
  body['volumes'].each do |index, volume|
@@ -15,7 +15,7 @@ module Fog
15
15
  def update_user_data(server_id, key, value)
16
16
  server = lookup(:servers, server_id)
17
17
 
18
- data[:user_data][server_id][key] = value
18
+ data[:user_data][server['id']][key] = value
19
19
 
20
20
  response(status: 204)
21
21
  end
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module Scaleway
3
- VERSION = '0.1.0'.freeze
3
+ VERSION = '0.2.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fog-scaleway
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Satoshi Matsumoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-27 00:00:00.000000000 Z
11
+ date: 2016-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -158,6 +158,8 @@ extensions: []
158
158
  extra_rdoc_files: []
159
159
  files:
160
160
  - .gitignore
161
+ - .rubocop.yml
162
+ - .rubocop_todo.yml
161
163
  - .ruby-version
162
164
  - .travis.yml
163
165
  - Gemfile
@@ -278,7 +280,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
278
280
  version: '0'
279
281
  requirements: []
280
282
  rubyforge_project:
281
- rubygems_version: 2.6.6
283
+ rubygems_version: 2.6.7
282
284
  signing_key:
283
285
  specification_version: 4
284
286
  summary: Fog provider for Scaleway