fog-profitbricks 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +4 -2
- data/gemfiles/Gemfile.1.8.7 +2 -2
- data/gemfiles/Gemfile.1.9.2+ +1 -1
- data/gemfiles/Gemfile.1.9.2- +5 -0
- data/lib/fog/profitbricks/models/base.rb +11 -0
- data/lib/fog/profitbricks/models/compute/datacenter.rb +58 -55
- data/lib/fog/profitbricks/models/compute/datacenters.rb +18 -18
- data/lib/fog/profitbricks/models/compute/flavor.rb +24 -21
- data/lib/fog/profitbricks/models/compute/flavors.rb +18 -18
- data/lib/fog/profitbricks/models/compute/image.rb +29 -26
- data/lib/fog/profitbricks/models/compute/images.rb +17 -17
- data/lib/fog/profitbricks/models/compute/interface.rb +54 -51
- data/lib/fog/profitbricks/models/compute/interfaces.rb +18 -18
- data/lib/fog/profitbricks/models/compute/region.rb +14 -11
- data/lib/fog/profitbricks/models/compute/regions.rb +18 -18
- data/lib/fog/profitbricks/models/compute/server.rb +107 -102
- data/lib/fog/profitbricks/models/compute/servers.rb +17 -17
- data/lib/fog/profitbricks/models/compute/volume.rb +61 -58
- data/lib/fog/profitbricks/models/compute/volumes.rb +18 -18
- data/lib/fog/profitbricks/parsers/compute/get_all_servers.rb +1 -0
- data/lib/fog/profitbricks/parsers/compute/get_server.rb +1 -0
- data/lib/fog/profitbricks/requests/compute/start_server.rb +2 -2
- data/lib/fog/profitbricks/requests/compute/stop_server.rb +2 -2
- data/lib/fog/profitbricks/version.rb +1 -1
- data/tests/profitbricks/requests/compute/server_tests.rb +3 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f38f58b9bfa3c89cbd23e16fd8d781dc6431e5c
|
4
|
+
data.tar.gz: 2c6256c539c8c625de23af738e4982fc158305e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebc75ce94e2206cfe4a5c092021439b76c0ed22b54b4e3705b5e1feeaa3ca59cc8da78e62c8832242d6b06616cdfb05ec0d91ca00bb17f2e7c8752644a4947d1
|
7
|
+
data.tar.gz: 6753697708c67ebf2a8cc85561971dd3da05e26634bba80c93c2f2e690504ac2b036db3eab406aadfd54a3baf5e8b877a55be75a92929128b52e036d879e3d8e
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Fog::profitbricks
|
2
2
|
|
3
|
-
|
3
|
+
![Gem Version](https://badge.fury.io/rb/fog-profitbricks.svg) [![Build Status](https://travis-ci.org/fog/fog-profitbricks.svg?branch=master)](https://travis-ci.org/fog/fog-profitbricks) [![Dependency Status](https://gemnasium.com/fog/fog-profitbricks.svg)](https://gemnasium.com/fog/fog-profitbricks) [![Coverage Status](https://img.shields.io/coveralls/fog/fog-profitbricks.svg)](https://coveralls.io/r/fog/fog-profitbricks?branch=master) [![Code Climate](https://codeclimate.com/github/fog/fog-profitbricks.png)](https://codeclimate.com/github/fog/fog-profitbricks)
|
4
|
+
|
5
|
+
Module for the 'fog' gem to support ProfitBricks
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
@@ -22,7 +24,7 @@ TODO: Write usage instructions here
|
|
22
24
|
|
23
25
|
## Contributing
|
24
26
|
|
25
|
-
1. Fork it ( https://github.com/
|
27
|
+
1. Fork it ( https://github.com/fog/fog-profitbricks/fork )
|
26
28
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
29
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
30
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/gemfiles/Gemfile.1.8.7
CHANGED
data/gemfiles/Gemfile.1.9.2+
CHANGED
@@ -1,59 +1,62 @@
|
|
1
|
+
require "fog/profitbricks/models/base"
|
2
|
+
|
1
3
|
module Fog
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
4
|
+
module Compute
|
5
|
+
class ProfitBricks
|
6
|
+
class Datacenter < Fog::Models::ProfitBricks::Base
|
7
|
+
identity :id, :aliases => "dataCenterId"
|
8
|
+
|
9
|
+
attribute :name, :aliases => "dataCenterName"
|
10
|
+
attribute :version, :aliases => "dataCenterVersion"
|
11
|
+
attribute :state, :aliases => "provisioningState"
|
12
|
+
attribute :request_id, :aliases => "requestId"
|
13
|
+
attribute :region
|
14
|
+
|
15
|
+
attr_accessor :options
|
16
|
+
|
17
|
+
def initialize(attributes = {})
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def save
|
22
|
+
requires :name, :region
|
23
|
+
|
24
|
+
data = service.create_data_center(name, region)
|
25
|
+
merge_attributes(data.body["createDataCenterResponse"])
|
26
|
+
true
|
27
|
+
end
|
28
|
+
|
29
|
+
def update
|
30
|
+
requires :id
|
31
|
+
data = service.update_data_center(id, options)
|
32
|
+
merge_attributes(data.body["updateDataCenterResponse"])
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
requires :id
|
38
|
+
service.delete_data_center(id)
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
def clear(confirm = false)
|
43
|
+
requires :id
|
44
|
+
if confirm == true
|
45
|
+
service.clear_data_center(id)
|
46
|
+
true
|
47
|
+
else
|
48
|
+
raise ArgumentError.new("Confirm with true boolean to clear datacenter")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def ready?
|
53
|
+
state == "AVAILABLE"
|
54
|
+
end
|
55
|
+
|
56
|
+
def failed?
|
57
|
+
state == "ERROR"
|
57
58
|
end
|
59
|
+
end
|
58
60
|
end
|
61
|
+
end
|
59
62
|
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/profitbricks/models/compute/datacenter"
|
3
3
|
|
4
4
|
module Fog
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
module Compute
|
6
|
+
class ProfitBricks
|
7
|
+
class Datacenters < Fog::Collection
|
8
|
+
model Fog::Compute::ProfitBricks::Datacenter
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def all
|
11
|
+
load(service.get_all_data_centers.body["getAllDataCentersResponse"])
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
14
|
+
def get(id)
|
15
|
+
datacenter = service.get_data_center(id).body["getDataCenterResponse"]
|
16
|
+
Excon::Errors
|
17
|
+
new(datacenter)
|
18
|
+
rescue Excon::Errors::NotFound
|
19
|
+
nil
|
22
20
|
end
|
21
|
+
end
|
23
22
|
end
|
24
|
-
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,27 +1,30 @@
|
|
1
|
+
require "fog/profitbricks/models/base"
|
2
|
+
|
1
3
|
module Fog
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
module Compute
|
5
|
+
class ProfitBricks
|
6
|
+
class Flavor < Fog::Models::ProfitBricks::Base
|
7
|
+
identity :id, :aliases => "flavorId"
|
8
|
+
|
9
|
+
attribute :name, :aliases => "flavorName"
|
10
|
+
attribute :cores
|
11
|
+
attribute :ram
|
9
12
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
+
def initialize(attributes = {})
|
14
|
+
super
|
15
|
+
end
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
def save
|
18
|
+
requires :name, :ram, :cores
|
19
|
+
data = service.create_flavor(name, cores, ram)
|
20
|
+
merge_attributes(data.body["createFlavorResponse"])
|
21
|
+
true
|
22
|
+
end
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
24
|
+
def update
|
25
|
+
Fog::Mock.not_implemented
|
25
26
|
end
|
27
|
+
end
|
26
28
|
end
|
27
|
-
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/profitbricks/models/compute/flavor"
|
3
3
|
|
4
4
|
module Fog
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
module Compute
|
6
|
+
class ProfitBricks
|
7
|
+
class Flavors < Fog::Collection
|
8
|
+
model Fog::Compute::ProfitBricks::Flavor
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def all()
|
11
|
+
load(service.get_all_flavors.body["getAllFlavorsResponse"])
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
14
|
+
def get(id)
|
15
|
+
flavor = service.get_flavor(id).body["getFlavorResponse"]
|
16
|
+
Excon::Errors
|
17
|
+
new(flavor)
|
18
|
+
rescue Excon::Errors::NotFound
|
19
|
+
nil
|
22
20
|
end
|
21
|
+
end
|
23
22
|
end
|
24
|
-
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,30 +1,33 @@
|
|
1
|
+
require "fog/profitbricks/models/base"
|
2
|
+
|
1
3
|
module Fog
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
4
|
+
module Compute
|
5
|
+
class ProfitBricks
|
6
|
+
class Image < Fog::Models::ProfitBricks::Base
|
7
|
+
identity :id, :aliases => "imageId"
|
8
|
+
|
9
|
+
attribute :name, :aliases => "imageName"
|
10
|
+
attribute :type, :aliases => "imageType"
|
11
|
+
attribute :size, :aliases => "imageSize"
|
12
|
+
attribute :cpu_hotplug, :aliases => "cpuHotPlug"
|
13
|
+
attribute :cpu_hotunplug, :aliases => "cpuHotUnplug"
|
14
|
+
attribute :ram_hotplug, :aliases => "memoryHotPlug"
|
15
|
+
attribute :ram_hotunplug, :aliases => "memoryHotUnPlug"
|
16
|
+
attribute :disc_hotplug, :aliases => "discVirtioHotPlug"
|
17
|
+
attribute :disc_hotunplug, :aliases => "discVirtioUnHotPlug"
|
18
|
+
attribute :nic_hotplug, :aliases => "nicHotPlug"
|
19
|
+
attribute :nic_hotunplug, :aliases => "nicHotUnPlug"
|
20
|
+
attribute :server_ids, :aliases => "serverIds"
|
21
|
+
attribute :os_type, :aliases => "osType"
|
22
|
+
attribute :region, :aliases => "location"
|
23
|
+
attribute :bootable
|
24
|
+
attribute :writeable
|
25
|
+
attribute :public
|
23
26
|
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
end
|
27
|
+
def initialize(attributes = {})
|
28
|
+
super
|
28
29
|
end
|
30
|
+
end
|
29
31
|
end
|
30
|
-
end
|
32
|
+
end
|
33
|
+
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/profitbricks/models/compute/image"
|
3
3
|
|
4
4
|
module Fog
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
module Compute
|
6
|
+
class ProfitBricks
|
7
|
+
class Images < Fog::Collection
|
8
|
+
model Fog::Compute::ProfitBricks::Image
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def all
|
11
|
+
load(service.get_all_images.body["getAllImagesResponse"])
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
14
|
+
def get(id)
|
15
|
+
image = service.get_image(id).body["getImageResponse"]
|
16
|
+
new(image)
|
17
|
+
rescue Fog::Errors::NotFound
|
18
|
+
nil
|
21
19
|
end
|
20
|
+
end
|
22
21
|
end
|
23
|
-
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,64 +1,67 @@
|
|
1
|
+
require "fog/profitbricks/models/base"
|
2
|
+
|
1
3
|
module Fog
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
4
|
+
module Compute
|
5
|
+
class ProfitBricks
|
6
|
+
class Interface < Fog::Models::ProfitBricks::Base
|
7
|
+
identity :id, :aliases => "nicId"
|
8
|
+
|
9
|
+
attribute :name, :aliases => "nicName"
|
10
|
+
attribute :mac_address, :aliases => "macAddress"
|
11
|
+
attribute :lan_id, :aliases => "lanId"
|
12
|
+
attribute :dhcp_active, :aliases => "dhcpActive"
|
13
|
+
attribute :ips, :aliases => "ips"
|
14
|
+
attribute :server_id, :aliases => "serverId"
|
15
|
+
attribute :internet_access, :aliases => "internetAccess"
|
16
|
+
attribute :state, :aliases => "provisioningState"
|
17
|
+
attribute :firewall
|
18
|
+
attribute :data_center_id, :aliases => "dataCenterId"
|
19
|
+
attribute :data_center_version, :aliases => "dataCenterVersion"
|
20
|
+
attribute :request_id, :aliases => "requestId"
|
18
21
|
|
19
|
-
|
22
|
+
attr_accessor :options
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
def initialize(attributes = {})
|
25
|
+
super
|
26
|
+
end
|
24
27
|
|
25
|
-
|
26
|
-
|
28
|
+
def save
|
29
|
+
requires :server_id, :lan_id
|
27
30
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
31
|
+
data = service.create_nic(server_id, lan_id, options = {})
|
32
|
+
merge_attributes(data.body["createNicResponse"])
|
33
|
+
true
|
34
|
+
end
|
32
35
|
|
33
|
-
|
34
|
-
|
36
|
+
def update
|
37
|
+
requires :id
|
35
38
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
data = service.update_nic(id, options)
|
40
|
+
merge_attributes(data.body["updateNicResponse"])
|
41
|
+
true
|
42
|
+
end
|
40
43
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
44
|
+
def destroy
|
45
|
+
requires :id
|
46
|
+
service.delete_nic(id)
|
47
|
+
true
|
48
|
+
end
|
46
49
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
def set_internet_access(options = {})
|
51
|
+
service.set_internet_access(
|
52
|
+
options[:data_center_id], options[:lan_id], options[:internet_access]
|
53
|
+
)
|
54
|
+
true
|
55
|
+
end
|
53
56
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
+
def ready?
|
58
|
+
state == "AVAILABLE"
|
59
|
+
end
|
57
60
|
|
58
|
-
|
59
|
-
|
60
|
-
end
|
61
|
-
end
|
61
|
+
def failed?
|
62
|
+
state == "ERROR"
|
62
63
|
end
|
64
|
+
end
|
63
65
|
end
|
64
|
-
end
|
66
|
+
end
|
67
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/profitbricks/models/compute/interface"
|
3
3
|
|
4
4
|
module Fog
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
module Compute
|
6
|
+
class ProfitBricks
|
7
|
+
class Interfaces < Fog::Collection
|
8
|
+
model Fog::Compute::ProfitBricks::Interface
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def all
|
11
|
+
load(service.get_all_nic.body["getAllNicResponse"])
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
14
|
+
def get(id)
|
15
|
+
interface = service.get_nic(id).body["getNicResponse"]
|
16
|
+
Excon::Errors
|
17
|
+
new(interface)
|
18
|
+
rescue Excon::Errors::NotFound
|
19
|
+
nil
|
22
20
|
end
|
21
|
+
end
|
23
22
|
end
|
24
|
-
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,15 +1,18 @@
|
|
1
|
+
require "fog/profitbricks/models/base"
|
2
|
+
|
1
3
|
module Fog
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
module Compute
|
5
|
+
class ProfitBricks
|
6
|
+
class Region < Fog::Models::ProfitBricks::Base
|
7
|
+
identity :id, :aliases => "locationId"
|
8
|
+
|
9
|
+
attribute :name, :aliases => "locationName"
|
10
|
+
attribute :country, :aliases => "country"
|
8
11
|
|
9
|
-
|
10
|
-
|
11
|
-
end
|
12
|
-
end
|
12
|
+
def initialize(attributes = {})
|
13
|
+
super
|
13
14
|
end
|
15
|
+
end
|
14
16
|
end
|
15
|
-
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/profitbricks/models/compute/region"
|
3
3
|
|
4
4
|
module Fog
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
module Compute
|
6
|
+
class ProfitBricks
|
7
|
+
class Regions < Fog::Collection
|
8
|
+
model Fog::Compute::ProfitBricks::Region
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def all()
|
11
|
+
load(service.get_all_locations.body["getAllLocationsResponse"])
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
14
|
+
def get(id)
|
15
|
+
region = service.get_location(id).body["getLocationResponse"]
|
16
|
+
Excon::Errors
|
17
|
+
new(region)
|
18
|
+
rescue Excon::Errors::NotFound
|
19
|
+
nil
|
22
20
|
end
|
21
|
+
end
|
23
22
|
end
|
24
|
-
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,107 +1,112 @@
|
|
1
|
-
require
|
1
|
+
require "fog/compute/models/server"
|
2
2
|
|
3
3
|
module Fog
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
def save
|
38
|
-
requires :data_center_id
|
39
|
-
|
40
|
-
if (cores and ram)
|
41
|
-
data = service.create_server(data_center_id, cores, ram, options || {})
|
42
|
-
elsif flavor_id
|
43
|
-
flavor = service.flavors.get(flavor_id)
|
44
|
-
data = service.create_server(data_center_id, flavor.cores, flavor.ram, options || {})
|
45
|
-
else
|
46
|
-
raise ArgumentError, 'cores/ram or flavor_id is required for this operation'
|
47
|
-
end
|
48
|
-
|
49
|
-
merge_attributes(data.body['createServerResponse'])
|
50
|
-
true
|
51
|
-
end
|
52
|
-
|
53
|
-
def update
|
54
|
-
requires :id
|
55
|
-
|
56
|
-
data = service.update_server(id, options)
|
57
|
-
merge_attributes(data.body['updateServerResponse'])
|
58
|
-
true
|
59
|
-
end
|
60
|
-
|
61
|
-
def reset
|
62
|
-
requires :id
|
63
|
-
service.reset_server(id)
|
64
|
-
true
|
65
|
-
end
|
66
|
-
|
67
|
-
def start
|
68
|
-
requires :id
|
69
|
-
service.start_server(id)
|
70
|
-
true
|
71
|
-
end
|
72
|
-
|
73
|
-
def stop
|
74
|
-
requires :id
|
75
|
-
service.stop_server(id)
|
76
|
-
true
|
77
|
-
end
|
78
|
-
|
79
|
-
def destroy
|
80
|
-
requires :id
|
81
|
-
service.delete_server(id)
|
82
|
-
true
|
83
|
-
end
|
84
|
-
|
85
|
-
def volumes
|
86
|
-
service.volumes.find_all do |volume|
|
87
|
-
volume.server_ids =~ /#{id}/
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
def interfaces
|
92
|
-
service.interfaces.find_all do |nic|
|
93
|
-
nic.server_id == id
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def ready?
|
98
|
-
self.state == 'AVAILABLE'
|
99
|
-
end
|
100
|
-
|
101
|
-
def failed?
|
102
|
-
self.state == 'ERROR'
|
103
|
-
end
|
104
|
-
end
|
4
|
+
module Compute
|
5
|
+
class ProfitBricks
|
6
|
+
class Server < Fog::Compute::Server
|
7
|
+
identity :id, :aliases => "serverId"
|
8
|
+
|
9
|
+
attribute :name, :aliases => "serverName"
|
10
|
+
attribute :cores
|
11
|
+
attribute :ram
|
12
|
+
attribute :attached_volumes, :aliases => "connectedStorages"
|
13
|
+
attribute :interfaces, :aliases => "nics"
|
14
|
+
attribute :internet_access, :aliases => "internetAccess"
|
15
|
+
attribute :zone, :aliases => "availabilityZone"
|
16
|
+
attribute :creation_time, :aliases => "creationTime"
|
17
|
+
attribute :modification_time, :aliases => "lastModificationTime"
|
18
|
+
attribute :machine_state, :aliases => "virtualMachineState"
|
19
|
+
attribute :state, :aliases => "provisioningState"
|
20
|
+
attribute :os_type, :aliases => "osType"
|
21
|
+
attribute :cpu_hotplug, :aliases => "cpuHotPlug"
|
22
|
+
attribute :ram_hotplug, :aliases => "ramHotPlug"
|
23
|
+
attribute :nic_hotplug, :aliases => "nicHotPlug"
|
24
|
+
attribute :nic_hotunplug, :aliases => "nicHotUnPlug"
|
25
|
+
attribute :disc_hotplug, :aliases => "discVirtioHotPlug"
|
26
|
+
attribute :disc_hotunplug, :aliases => "discVirtioHotUnPlug"
|
27
|
+
attribute :data_center_id, :aliases => "dataCenterId"
|
28
|
+
attribute :data_center_version, :aliases => "dataCenterVersion"
|
29
|
+
attribute :request_id, :aliases => "requestId"
|
30
|
+
|
31
|
+
attr_accessor :options
|
32
|
+
attr_accessor :flavor_id
|
33
|
+
|
34
|
+
def initialize(attributes = {})
|
35
|
+
super
|
105
36
|
end
|
37
|
+
|
38
|
+
def wait_for(timeout=Fog.timeout, interval=5, &block)
|
39
|
+
super
|
40
|
+
end
|
41
|
+
|
42
|
+
def save
|
43
|
+
requires :data_center_id
|
44
|
+
|
45
|
+
if (cores and ram)
|
46
|
+
data = service.create_server(data_center_id, cores, ram, options || {})
|
47
|
+
elsif flavor_id
|
48
|
+
flavor = service.flavors.get(flavor_id)
|
49
|
+
data = service.create_server(data_center_id, flavor.cores, flavor.ram, options || {})
|
50
|
+
else
|
51
|
+
raise ArgumentError, "cores/ram or flavor_id is required for this operation"
|
52
|
+
end
|
53
|
+
|
54
|
+
merge_attributes(data.body["createServerResponse"])
|
55
|
+
true
|
56
|
+
end
|
57
|
+
|
58
|
+
def update
|
59
|
+
requires :id
|
60
|
+
|
61
|
+
data = service.update_server(id, options)
|
62
|
+
merge_attributes(data.body["updateServerResponse"])
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
66
|
+
def reset
|
67
|
+
requires :id
|
68
|
+
service.reset_server(id)
|
69
|
+
true
|
70
|
+
end
|
71
|
+
|
72
|
+
def start
|
73
|
+
requires :id
|
74
|
+
service.start_server(id)
|
75
|
+
true
|
76
|
+
end
|
77
|
+
|
78
|
+
def stop
|
79
|
+
requires :id
|
80
|
+
service.stop_server(id)
|
81
|
+
true
|
82
|
+
end
|
83
|
+
|
84
|
+
def destroy
|
85
|
+
requires :id
|
86
|
+
service.delete_server(id)
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
90
|
+
def volumes
|
91
|
+
service.volumes.find_all do |volume|
|
92
|
+
volume.server_ids =~ /#{id}/
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def interfaces
|
97
|
+
service.interfaces.find_all do |nic|
|
98
|
+
nic.server_id == id
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
def ready?
|
103
|
+
state == "AVAILABLE"
|
104
|
+
end
|
105
|
+
|
106
|
+
def failed?
|
107
|
+
state == "ERROR"
|
108
|
+
end
|
109
|
+
end
|
106
110
|
end
|
111
|
+
end
|
107
112
|
end
|
@@ -1,23 +1,23 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/profitbricks/models/compute/server"
|
3
3
|
|
4
4
|
module Fog
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
module Compute
|
6
|
+
class ProfitBricks
|
7
|
+
class Servers < Fog::Collection
|
8
|
+
model Fog::Compute::ProfitBricks::Server
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def all
|
11
|
+
load(service.get_all_servers.body["getAllServersResponse"])
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
14
|
+
def get(id)
|
15
|
+
server = service.get_server(id).body["getServerResponse"]
|
16
|
+
new(server)
|
17
|
+
rescue Excon::Errors::NotFound
|
18
|
+
nil
|
21
19
|
end
|
20
|
+
end
|
22
21
|
end
|
23
|
-
end
|
22
|
+
end
|
23
|
+
end
|
@@ -1,74 +1,77 @@
|
|
1
|
+
require "fog/profitbricks/models/base"
|
2
|
+
|
1
3
|
module Fog
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
attribute :name, :aliases => 'storageName'
|
7
|
-
attribute :size
|
8
|
-
attribute :creation_time, :aliases => 'creationTime'
|
9
|
-
attribute :modification_time, :aliases => 'lastModificationTime'
|
10
|
-
attribute :server_ids, :aliases => 'serverIds'
|
11
|
-
attribute :mount_image, :aliases => 'mountImage'
|
12
|
-
attribute :state, :aliases => 'provisioningState'
|
13
|
-
attribute :data_center_id, :aliases => 'dataCenterId'
|
14
|
-
attribute :data_center_version, :aliases => 'dataCenterVersion'
|
15
|
-
attribute :request_id, :aliases => 'requestId'
|
4
|
+
module Compute
|
5
|
+
class ProfitBricks
|
6
|
+
class Volume < Fog::Models::ProfitBricks::Base
|
7
|
+
identity :id, :aliases => "storageId"
|
16
8
|
|
17
|
-
|
9
|
+
attribute :name, :aliases => "storageName"
|
10
|
+
attribute :size
|
11
|
+
attribute :creation_time, :aliases => "creationTime"
|
12
|
+
attribute :modification_time, :aliases => "lastModificationTime"
|
13
|
+
attribute :server_ids, :aliases => "serverIds"
|
14
|
+
attribute :mount_image, :aliases => "mountImage"
|
15
|
+
attribute :state, :aliases => "provisioningState"
|
16
|
+
attribute :data_center_id, :aliases => "dataCenterId"
|
17
|
+
attribute :data_center_version, :aliases => "dataCenterVersion"
|
18
|
+
attribute :request_id, :aliases => "requestId"
|
18
19
|
|
19
|
-
|
20
|
-
super
|
21
|
-
end
|
20
|
+
attr_accessor :options
|
22
21
|
|
23
|
-
|
24
|
-
|
22
|
+
def initialize(attributes = {})
|
23
|
+
super
|
24
|
+
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
true
|
29
|
-
end
|
26
|
+
def save
|
27
|
+
requires :data_center_id, :size
|
30
28
|
|
31
|
-
|
32
|
-
|
29
|
+
data = service.create_storage(data_center_id, size, options)
|
30
|
+
merge_attributes(data.body["createStorageResponse"])
|
31
|
+
true
|
32
|
+
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
true
|
37
|
-
end
|
34
|
+
def update
|
35
|
+
requires :id
|
38
36
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
'busType' => options[:bus_type],
|
44
|
-
'deviceNumber' => options[:device_number]
|
45
|
-
}
|
37
|
+
data = service.update_storage(id, options)
|
38
|
+
merge_attributes(data.body["updateStorageResponse"])
|
39
|
+
true
|
40
|
+
end
|
46
41
|
|
47
|
-
|
48
|
-
|
49
|
-
|
42
|
+
def attach(server_id, options = {})
|
43
|
+
requires :id
|
44
|
+
|
45
|
+
options = {
|
46
|
+
"busType" => options[:bus_type],
|
47
|
+
"deviceNumber" => options[:device_number]
|
48
|
+
}
|
50
49
|
|
51
|
-
|
52
|
-
|
50
|
+
data = service.connect_storage_to_server(id, server_id, options)
|
51
|
+
reload
|
52
|
+
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
end
|
54
|
+
def detach(server_id)
|
55
|
+
requires :id
|
57
56
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
data = service.disconnect_storage_from_server(id, server_id)
|
58
|
+
reload
|
59
|
+
end
|
60
|
+
|
61
|
+
def destroy
|
62
|
+
requires :id
|
63
|
+
service.delete_storage(id)
|
64
|
+
true
|
65
|
+
end
|
63
66
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
+
def ready?
|
68
|
+
state == "AVAILABLE"
|
69
|
+
end
|
67
70
|
|
68
|
-
|
69
|
-
|
70
|
-
end
|
71
|
-
end
|
71
|
+
def failed?
|
72
|
+
state == "ERROR"
|
72
73
|
end
|
74
|
+
end
|
73
75
|
end
|
74
|
-
end
|
76
|
+
end
|
77
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "fog/core/collection"
|
2
|
+
require "fog/profitbricks/models/compute/volume"
|
3
3
|
|
4
4
|
module Fog
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
module Compute
|
6
|
+
class ProfitBricks
|
7
|
+
class Volumes < Fog::Collection
|
8
|
+
model Fog::Compute::ProfitBricks::Volume
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
def all
|
11
|
+
load(service.get_all_storages.body["getAllStoragesResponse"])
|
12
|
+
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
14
|
+
def get(id)
|
15
|
+
volume = service.get_storage(id).body["getStorageResponse"]
|
16
|
+
Excon::Errors
|
17
|
+
new(volume)
|
18
|
+
rescue Excon::Errors::NotFound
|
19
|
+
nil
|
22
20
|
end
|
21
|
+
end
|
23
22
|
end
|
24
|
-
end
|
23
|
+
end
|
24
|
+
end
|
@@ -38,8 +38,8 @@ module Fog
|
|
38
38
|
if server = self.data[:servers].find {
|
39
39
|
|attrib| attrib["serverId"] == server_id
|
40
40
|
}
|
41
|
-
server["
|
42
|
-
server["
|
41
|
+
server["virtualMachineState"] = "RUNNING"
|
42
|
+
server["provisioningState"] = "AVAILABLE"
|
43
43
|
else
|
44
44
|
raise Fog::Errors::NotFound.new("The requested server resource could not be found")
|
45
45
|
end
|
@@ -38,8 +38,8 @@ module Fog
|
|
38
38
|
if server = self.data[:servers].find {
|
39
39
|
|attrib| attrib["serverId"] == server_id
|
40
40
|
}
|
41
|
-
server["
|
42
|
-
server["
|
41
|
+
server["virtualMachineState"] = "SHUTOFF"
|
42
|
+
server["provisioningState"] = "INACTIVE"
|
43
43
|
else
|
44
44
|
raise Fog::Errors::NotFound.new("The requested server resource could not be found")
|
45
45
|
end
|
@@ -166,16 +166,19 @@ Shindo.tests('Fog::Compute[:profitbricks] | server request', ['profitbricks', 'c
|
|
166
166
|
tests('#stop_server').succeeds do
|
167
167
|
# puts '#stop_server'
|
168
168
|
service.stop_server(@server_id)
|
169
|
+
service.servers.get(@server_id).wait_for { state == "INACTIVE" }
|
169
170
|
end
|
170
171
|
|
171
172
|
tests('#start_server').succeeds do
|
172
173
|
# puts '#start_server'
|
173
174
|
service.start_server(@server_id)
|
175
|
+
service.servers.get(@server_id).wait_for { state == "AVAILABLE" }
|
174
176
|
end
|
175
177
|
|
176
178
|
tests('#reset_server').succeeds do
|
177
179
|
# puts '#reset_server'
|
178
180
|
service.reset_server(@server_id)
|
181
|
+
service.servers.get(@server_id).wait_for { state == "AVAILABLE" }
|
179
182
|
end
|
180
183
|
|
181
184
|
tests('#disconnect_storage_from_server').formats(@minimal_format) do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-profitbricks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan Devenport
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fog-core
|
@@ -172,10 +172,12 @@ files:
|
|
172
172
|
- fog-profitbricks.gemspec
|
173
173
|
- gemfiles/Gemfile.1.8.7
|
174
174
|
- gemfiles/Gemfile.1.9.2+
|
175
|
+
- gemfiles/Gemfile.1.9.2-
|
175
176
|
- lib/fog/bin/profitbricks.rb
|
176
177
|
- lib/fog/profitbricks.rb
|
177
178
|
- lib/fog/profitbricks/compute.rb
|
178
179
|
- lib/fog/profitbricks/core.rb
|
180
|
+
- lib/fog/profitbricks/models/base.rb
|
179
181
|
- lib/fog/profitbricks/models/compute/datacenter.rb
|
180
182
|
- lib/fog/profitbricks/models/compute/datacenters.rb
|
181
183
|
- lib/fog/profitbricks/models/compute/flavor.rb
|