fog-scaleway 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.ruby-version +1 -0
- data/.travis.yml +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +21 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/fog-scaleway.gemspec +31 -0
- data/lib/fog/scaleway.rb +15 -0
- data/lib/fog/scaleway/account.rb +306 -0
- data/lib/fog/scaleway/client.rb +54 -0
- data/lib/fog/scaleway/compute.rb +350 -0
- data/lib/fog/scaleway/errors.rb +37 -0
- data/lib/fog/scaleway/models/account/organization.rb +42 -0
- data/lib/fog/scaleway/models/account/organizations.rb +22 -0
- data/lib/fog/scaleway/models/account/token.rb +60 -0
- data/lib/fog/scaleway/models/account/tokens.rb +22 -0
- data/lib/fog/scaleway/models/account/user.rb +69 -0
- data/lib/fog/scaleway/models/account/users.rb +23 -0
- data/lib/fog/scaleway/models/compute/bootscript.rb +19 -0
- data/lib/fog/scaleway/models/compute/bootscripts.rb +22 -0
- data/lib/fog/scaleway/models/compute/image.rb +83 -0
- data/lib/fog/scaleway/models/compute/images.rb +22 -0
- data/lib/fog/scaleway/models/compute/ip.rb +70 -0
- data/lib/fog/scaleway/models/compute/ips.rb +22 -0
- data/lib/fog/scaleway/models/compute/security_group.rb +77 -0
- data/lib/fog/scaleway/models/compute/security_group_rule.rb +59 -0
- data/lib/fog/scaleway/models/compute/security_group_rules.rb +34 -0
- data/lib/fog/scaleway/models/compute/security_groups.rb +22 -0
- data/lib/fog/scaleway/models/compute/server.rb +243 -0
- data/lib/fog/scaleway/models/compute/servers.rb +47 -0
- data/lib/fog/scaleway/models/compute/snapshot.rb +90 -0
- data/lib/fog/scaleway/models/compute/snapshots.rb +22 -0
- data/lib/fog/scaleway/models/compute/task.rb +31 -0
- data/lib/fog/scaleway/models/compute/tasks.rb +22 -0
- data/lib/fog/scaleway/models/compute/volume.rb +96 -0
- data/lib/fog/scaleway/models/compute/volumes.rb +22 -0
- data/lib/fog/scaleway/request_helper.rb +32 -0
- data/lib/fog/scaleway/requests/account/create_token.rb +62 -0
- data/lib/fog/scaleway/requests/account/delete_token.rb +21 -0
- data/lib/fog/scaleway/requests/account/get_organization.rb +19 -0
- data/lib/fog/scaleway/requests/account/get_organization_quotas.rb +21 -0
- data/lib/fog/scaleway/requests/account/get_token.rb +19 -0
- data/lib/fog/scaleway/requests/account/get_token_permissions.rb +21 -0
- data/lib/fog/scaleway/requests/account/get_user.rb +19 -0
- data/lib/fog/scaleway/requests/account/list_organizations.rb +19 -0
- data/lib/fog/scaleway/requests/account/list_tokens.rb +19 -0
- data/lib/fog/scaleway/requests/account/update_token.rb +27 -0
- data/lib/fog/scaleway/requests/account/update_user.rb +39 -0
- data/lib/fog/scaleway/requests/compute/create_image.rb +61 -0
- data/lib/fog/scaleway/requests/compute/create_ip.rb +68 -0
- data/lib/fog/scaleway/requests/compute/create_security_group.rb +49 -0
- data/lib/fog/scaleway/requests/compute/create_security_group_rule.rb +49 -0
- data/lib/fog/scaleway/requests/compute/create_server.rb +129 -0
- data/lib/fog/scaleway/requests/compute/create_snapshot.rb +54 -0
- data/lib/fog/scaleway/requests/compute/create_volume.rb +88 -0
- data/lib/fog/scaleway/requests/compute/delete_image.rb +27 -0
- data/lib/fog/scaleway/requests/compute/delete_ip.rb +29 -0
- data/lib/fog/scaleway/requests/compute/delete_security_group.rb +31 -0
- data/lib/fog/scaleway/requests/compute/delete_security_group_rule.rb +23 -0
- data/lib/fog/scaleway/requests/compute/delete_server.rb +40 -0
- data/lib/fog/scaleway/requests/compute/delete_snapshot.rb +29 -0
- data/lib/fog/scaleway/requests/compute/delete_task.rb +21 -0
- data/lib/fog/scaleway/requests/compute/delete_user_data.rb +21 -0
- data/lib/fog/scaleway/requests/compute/delete_volume.rb +31 -0
- data/lib/fog/scaleway/requests/compute/execute_server_action.rb +101 -0
- data/lib/fog/scaleway/requests/compute/get_bootscript.rb +19 -0
- data/lib/fog/scaleway/requests/compute/get_container.rb +19 -0
- data/lib/fog/scaleway/requests/compute/get_dashboard.rb +37 -0
- data/lib/fog/scaleway/requests/compute/get_image.rb +19 -0
- data/lib/fog/scaleway/requests/compute/get_ip.rb +19 -0
- data/lib/fog/scaleway/requests/compute/get_security_group.rb +19 -0
- data/lib/fog/scaleway/requests/compute/get_security_group_rule.rb +23 -0
- data/lib/fog/scaleway/requests/compute/get_server.rb +48 -0
- data/lib/fog/scaleway/requests/compute/get_snapshot.rb +19 -0
- data/lib/fog/scaleway/requests/compute/get_task.rb +25 -0
- data/lib/fog/scaleway/requests/compute/get_user_data.rb +25 -0
- data/lib/fog/scaleway/requests/compute/get_volume.rb +19 -0
- data/lib/fog/scaleway/requests/compute/list_bootscripts.rb +23 -0
- data/lib/fog/scaleway/requests/compute/list_containers.rb +19 -0
- data/lib/fog/scaleway/requests/compute/list_images.rb +27 -0
- data/lib/fog/scaleway/requests/compute/list_ips.rb +19 -0
- data/lib/fog/scaleway/requests/compute/list_security_group_rules.rb +21 -0
- data/lib/fog/scaleway/requests/compute/list_security_groups.rb +19 -0
- data/lib/fog/scaleway/requests/compute/list_server_actions.rb +21 -0
- data/lib/fog/scaleway/requests/compute/list_servers.rb +19 -0
- data/lib/fog/scaleway/requests/compute/list_snapshots.rb +19 -0
- data/lib/fog/scaleway/requests/compute/list_tasks.rb +19 -0
- data/lib/fog/scaleway/requests/compute/list_user_data.rb +21 -0
- data/lib/fog/scaleway/requests/compute/list_volumes.rb +19 -0
- data/lib/fog/scaleway/requests/compute/update_image.rb +31 -0
- data/lib/fog/scaleway/requests/compute/update_ip.rb +47 -0
- data/lib/fog/scaleway/requests/compute/update_security_group.rb +29 -0
- data/lib/fog/scaleway/requests/compute/update_security_group_rule.rb +31 -0
- data/lib/fog/scaleway/requests/compute/update_server.rb +71 -0
- data/lib/fog/scaleway/requests/compute/update_snapshot.rb +24 -0
- data/lib/fog/scaleway/requests/compute/update_user_data.rb +25 -0
- data/lib/fog/scaleway/requests/compute/update_volume.rb +24 -0
- data/lib/fog/scaleway/version.rb +5 -0
- metadata +285 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def get_bootscript(bootscript_id)
|
6
|
+
get("/bootscripts/#{bootscript_id}")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def get_bootscript(bootscript_id)
|
12
|
+
bootscript = lookup(:bootscripts, bootscript_id)
|
13
|
+
|
14
|
+
response(status: 200, body: { 'bootscript' => bootscript })
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def get_container(container_id)
|
6
|
+
get("/containers/#{container_id}")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def get_container(container_id)
|
12
|
+
container = lookup(:containers, container_id)
|
13
|
+
|
14
|
+
response(status: 200, body: { 'container' => container })
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def get_dashboard
|
6
|
+
get('/dashboard')
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def get_dashboard
|
12
|
+
running_servers = data[:servers].select do |_id, s|
|
13
|
+
s['state'] == 'running'
|
14
|
+
end
|
15
|
+
|
16
|
+
servers_by_types = data[:servers].group_by { |s| s['commercial_type'] }
|
17
|
+
servers_count_by_types = Hash[servers_by_types.map { |t, s| [t, s.size] }]
|
18
|
+
|
19
|
+
ips_unused = data[:ips].reject { |ip| ip['server'] }.size
|
20
|
+
|
21
|
+
dashboard = {
|
22
|
+
'snapshots_count' => data[:snapshots].size,
|
23
|
+
'servers_count' => data[:servers].size,
|
24
|
+
'volumes_count' => data[:volumes].size,
|
25
|
+
'images_count' => data[:images].size,
|
26
|
+
'ips_count' => data[:ips].size,
|
27
|
+
'running_servers_count' => running_servers.size,
|
28
|
+
'servers_by_types' => servers_count_by_types,
|
29
|
+
'ips_unused' => ips_unused
|
30
|
+
}
|
31
|
+
|
32
|
+
response(status: 200, body: { 'dashboard' => dashboard })
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def get_image(image_id)
|
6
|
+
get("/images/#{image_id}")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def get_image(image_id)
|
12
|
+
image = lookup(:images, image_id)
|
13
|
+
|
14
|
+
response(status: 200, body: { 'image' => image })
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def get_ip(ip_id)
|
6
|
+
get("/ips/#{ip_id}")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def get_ip(ip_id)
|
12
|
+
ip = lookup(:ips, ip_id)
|
13
|
+
|
14
|
+
response(status: 200, body: { 'ip' => ip })
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def get_security_group(security_group_id)
|
6
|
+
get("/security_groups/#{security_group_id}")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def get_security_group(security_group_id)
|
12
|
+
security_group = lookup(:security_groups, security_group_id)
|
13
|
+
|
14
|
+
response(status: 200, body: { 'security_group' => security_group })
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def get_security_group_rule(security_group_id, rule_id)
|
6
|
+
get("/security_groups/#{security_group_id}/rules/#{rule_id}")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def get_security_group_rule(security_group_id, rule_id)
|
12
|
+
security_group = lookup(:security_groups, security_group_id)
|
13
|
+
|
14
|
+
rule = data[:security_group_rules][security_group_id][rule_id]
|
15
|
+
|
16
|
+
raise_unknown_resource(rule_id) unless rule
|
17
|
+
|
18
|
+
response(status: 200, body: { 'rule' => rule })
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def get_server(server_id)
|
6
|
+
get("/servers/#{server_id}")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def get_server(server_id)
|
12
|
+
server = lookup(:servers, server_id)
|
13
|
+
|
14
|
+
elapsed_time = Time.now - Time.parse(server['modification_date'])
|
15
|
+
|
16
|
+
if server['state'] == 'starting' && elapsed_time >= Fog::Mock.delay
|
17
|
+
server['state'] = 'running'
|
18
|
+
server['state_detail'] = 'booted'
|
19
|
+
server['modification_date'] = now
|
20
|
+
elsif server['state'] == 'stopping' && elapsed_time >= Fog::Mock.delay
|
21
|
+
case server['state_detail']
|
22
|
+
when 'stopping'
|
23
|
+
server['ipv6'] = nil
|
24
|
+
server['location'] = nil
|
25
|
+
server['private_ip'] = nil
|
26
|
+
|
27
|
+
if server['public_ip'] && server['public_ip']['dynamic']
|
28
|
+
server['public_ip'] = nil
|
29
|
+
end
|
30
|
+
|
31
|
+
server['state'] = 'stopped'
|
32
|
+
server['state_detail'] = ''
|
33
|
+
server['modification_date'] = now
|
34
|
+
when 'rebooting'
|
35
|
+
server['state'] = 'running'
|
36
|
+
server['state_detail'] = 'booted'
|
37
|
+
server['modification_date'] = now
|
38
|
+
when 'terminating'
|
39
|
+
terminate_server(server)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
response(status: 200, body: { 'server' => server })
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def get_snapshot(snapshot_id)
|
6
|
+
get("/snapshots/#{snapshot_id}")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def get_snapshot(snapshot_id)
|
12
|
+
snapshot = lookup(:snapshots, snapshot_id)
|
13
|
+
|
14
|
+
response(status: 200, body: { 'snapshot' => snapshot })
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def get_task(task_id)
|
6
|
+
get("/tasks/#{task_id}")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def get_task(task_id)
|
12
|
+
task = lookup(:tasks, task_id)
|
13
|
+
|
14
|
+
if Time.now - Time.parse(task['started_at']) >= Fog::Mock.delay
|
15
|
+
task['status'] = 'success'
|
16
|
+
task['terminated_at'] = now
|
17
|
+
task['progress'] = 100
|
18
|
+
end
|
19
|
+
|
20
|
+
response(status: 200, body: { 'task' => task })
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def get_user_data(server_id, key)
|
6
|
+
get("/servers/#{server_id}/user_data/#{key}")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def get_user_data(server_id, key)
|
12
|
+
server = lookup(:servers, server_id)
|
13
|
+
|
14
|
+
user_data = data[:user_data][server['id']][key]
|
15
|
+
|
16
|
+
raise Excon::Error::NotFound unless user_data
|
17
|
+
|
18
|
+
response(status: 200,
|
19
|
+
headers: { 'Content-Type' => 'text/plain' },
|
20
|
+
body: user_data)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def get_volume(volume_id)
|
6
|
+
get("/volumes/#{volume_id}")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def get_volume(volume_id)
|
12
|
+
volume = lookup(:volumes, volume_id)
|
13
|
+
|
14
|
+
response(status: 200, body: { 'volume' => volume })
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def list_bootscripts(filters = {})
|
6
|
+
get('/bootscripts', filters)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def list_bootscripts(filters = {})
|
12
|
+
bootscripts = data[:bootscripts].values
|
13
|
+
|
14
|
+
if (arch = filters[:arch])
|
15
|
+
bootscripts.select! { |b| b['architecture'] == arch }
|
16
|
+
end
|
17
|
+
|
18
|
+
response(status: 200, body: { 'bootscripts' => bootscripts })
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def list_containers
|
6
|
+
get('/containers')
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def list_containers
|
12
|
+
containers = data[:containers].values
|
13
|
+
|
14
|
+
response(status: 200, body: { 'containers' => containers })
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def list_images(filters = {})
|
6
|
+
get('/images', filters)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def list_images(filters = {})
|
12
|
+
images = data[:images].values
|
13
|
+
|
14
|
+
if (organization = filters[:organization])
|
15
|
+
images.select! { |i| i['organization'] == organization }
|
16
|
+
end
|
17
|
+
|
18
|
+
if (arch = filters[:arch])
|
19
|
+
images.select! { |b| b['arch'] == arch }
|
20
|
+
end
|
21
|
+
|
22
|
+
response(status: 200, body: { 'images' => images })
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def list_ips
|
6
|
+
get('/ips')
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def list_ips
|
12
|
+
ips = data[:ips].values
|
13
|
+
|
14
|
+
response(status: 200, body: { 'ips' => ips })
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def list_security_group_rules(security_group_id)
|
6
|
+
get("/security_groups/#{security_group_id}/rules")
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def list_security_group_rules(security_group_id)
|
12
|
+
security_group = lookup(:security_groups, security_group_id)
|
13
|
+
|
14
|
+
rules = data[:security_group_rules][security_group_id].values
|
15
|
+
|
16
|
+
response(status: 200, body: { 'rules' => rules })
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Fog
|
2
|
+
module Scaleway
|
3
|
+
class Compute
|
4
|
+
class Real
|
5
|
+
def list_security_groups
|
6
|
+
get('/security_groups')
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Mock
|
11
|
+
def list_security_groups
|
12
|
+
security_groups = data[:security_groups].values
|
13
|
+
|
14
|
+
response(status: 200, body: { 'security_groups' => security_groups })
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|