fog-scaleway 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +23 -0
- data/.travis.yml +1 -0
- data/README.md +7 -4
- data/Rakefile +8 -5
- data/lib/fog/scaleway/compute.rb +10 -4
- data/lib/fog/scaleway/models/account/token.rb +2 -2
- data/lib/fog/scaleway/models/compute/server.rb +12 -27
- data/lib/fog/scaleway/requests/account/create_token.rb +2 -2
- data/lib/fog/scaleway/requests/compute/delete_security_group_rule.rb +1 -1
- data/lib/fog/scaleway/requests/compute/execute_server_action.rb +1 -0
- data/lib/fog/scaleway/requests/compute/get_dashboard.rb +2 -2
- data/lib/fog/scaleway/requests/compute/get_security_group_rule.rb +1 -1
- data/lib/fog/scaleway/requests/compute/list_security_group_rules.rb +1 -1
- data/lib/fog/scaleway/requests/compute/update_server.rb +1 -1
- data/lib/fog/scaleway/requests/compute/update_user_data.rb +1 -1
- data/lib/fog/scaleway/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 51b03e240e9f4cd20d0e1fa7720d3f7ee8ba5bb3
|
4
|
+
data.tar.gz: 16d35624f89537158d15e49f1f234ec6435c9ad6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcc876f2188e9e01af2598617028b98d7b6306bcbcf5851272402773e5d5dca816071b4d68ce539b0a44d1da3e1e853c53830cd3b04f2a0faa365719d17012d9
|
7
|
+
data.tar.gz: d500fe46c3a918d3e67fddd2a9d25d369ce6c2cb03f5f70e02fee0527fad556fe4aeec9a49bc0b589037b3f1254219320ab1f75312b687d6379787ef39e9956a
|
data/.rubocop.yml
ADDED
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
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'
|
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:
|
27
|
-
scaleway_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
|
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
|
-
|
19
|
+
desc 'Run all tests'
|
20
|
+
task test: ['test:units', 'test:integration']
|
21
|
+
|
22
|
+
RuboCop::RakeTask.new(:rubocop)
|
23
|
+
|
24
|
+
task default: [:test, :rubocop]
|
data/lib/fog/scaleway/compute.rb
CHANGED
@@ -12,9 +12,10 @@ module Fog
|
|
12
12
|
class Conflict < Error; end
|
13
13
|
class APIError < Error; end
|
14
14
|
|
15
|
-
requires
|
16
|
-
requires
|
17
|
-
|
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(
|
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] =
|
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] =
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
149
|
-
|
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
|
-
|
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 |
|
35
|
-
|
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][
|
14
|
+
unless data[:security_group_rules][security_group['id']].delete(rule_id)
|
15
15
|
raise_unknown_resource(rule_id)
|
16
16
|
end
|
17
17
|
|
@@ -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][
|
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][
|
14
|
+
rules = data[:security_group_rules][security_group['id']].values
|
15
15
|
|
16
16
|
response(status: 200, body: { 'rules' => rules })
|
17
17
|
end
|
data/lib/fog/scaleway/version.rb
CHANGED
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.
|
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-
|
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.
|
283
|
+
rubygems_version: 2.6.7
|
282
284
|
signing_key:
|
283
285
|
specification_version: 4
|
284
286
|
summary: Fog provider for Scaleway
|