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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03f366af928abd2f482a610a276cd7511d1be2af
4
- data.tar.gz: af46d443b445216869a0ae92d8cffc6256652e4c
3
+ metadata.gz: 1f38f58b9bfa3c89cbd23e16fd8d781dc6431e5c
4
+ data.tar.gz: 2c6256c539c8c625de23af738e4982fc158305e5
5
5
  SHA512:
6
- metadata.gz: a680334c5285ce54b790d242739a4a1b1a6cd7951fcd21953d975de3bc3a8156565c085ae742b1f799c638520f5e5502ce7818e732eccc4f4489353d94441c27
7
- data.tar.gz: 86fe3c96f303573a3cd1f65de3b3aa5e8734ccd3f81bb9b7f7027445844e160ed11e839040d2fd7ddb6fbcaec7f4ab98ce5e2b6ef16ff52e6e6d523b4fcaeb48
6
+ metadata.gz: ebc75ce94e2206cfe4a5c092021439b76c0ed22b54b4e3705b5e1feeaa3ca59cc8da78e62c8832242d6b06616cdfb05ec0d91ca00bb17f2e7c8752644a4947d1
7
+ data.tar.gz: 6753697708c67ebf2a8cc85561971dd3da05e26634bba80c93c2f2e690504ac2b036db3eab406aadfd54a3baf5e8b877a55be75a92929128b52e036d879e3d8e
data/.travis.yml CHANGED
@@ -7,7 +7,7 @@ matrix:
7
7
  - rvm: 1.8.7
8
8
  gemfile: gemfiles/Gemfile.1.8.7
9
9
  - rvm: 1.9.2
10
- gemfile: gemfiles/Gemfile.1.9.2+
10
+ gemfile: gemfiles/Gemfile.1.9.2-
11
11
  env: COVERAGE=true
12
12
  - rvm: 1.9.3
13
13
  gemfile: gemfiles/Gemfile.1.9.2+
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Fog::profitbricks
2
2
 
3
- TODO: Write a gem description
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/[my-github-username]/fog-profitbricks/fork )
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`)
@@ -1,7 +1,7 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'mime-types', '< 2.0'
4
4
  gem 'nokogiri', '< 1.6'
5
5
  gem 'rest-client', '~> 1.6.8'
6
6
 
7
- gemspec :path => '../'
7
+ gemspec :path => '../'
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'activesupport', '>= 3.0', '< 4'
4
4
  gem 'mime-types', '< 2.0'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'mime-types', '< 2.0'
4
+
5
+ gemspec :path => '../'
@@ -0,0 +1,11 @@
1
+ module Fog
2
+ module Models
3
+ module ProfitBricks
4
+ class Base < Fog::Model
5
+ def wait_for(timeout=Fog.timeout, interval=5, &block)
6
+ super
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,59 +1,62 @@
1
+ require "fog/profitbricks/models/base"
2
+
1
3
  module Fog
2
- module Compute
3
- class ProfitBricks
4
- class Datacenter < Fog::Model
5
- identity :id, :aliases => 'dataCenterId'
6
- attribute :name, :aliases => 'dataCenterName'
7
- attribute :version, :aliases => 'dataCenterVersion'
8
- attribute :state, :aliases => 'provisioningState'
9
- attribute :request_id, :aliases => 'requestId'
10
- attribute :region
11
-
12
- attr_accessor :options
13
-
14
- def initialize(attributes={})
15
- super
16
- end
17
-
18
- def save
19
- requires :name, :region
20
-
21
- data = service.create_data_center(name, region)
22
- merge_attributes(data.body['createDataCenterResponse'])
23
- true
24
- end
25
-
26
- def update
27
- requires :id
28
- data = service.update_data_center(id, options)
29
- merge_attributes(data.body['updateDataCenterResponse'])
30
- true
31
- end
32
-
33
- def destroy
34
- requires :id
35
- service.delete_data_center(id)
36
- true
37
- end
38
-
39
- def clear(confirm = false)
40
- requires :id
41
- if confirm == true
42
- service.clear_data_center(id)
43
- true
44
- else
45
- raise ArgumentError.new('Confirm with true boolean to clear datacenter')
46
- end
47
- end
48
-
49
- def ready?
50
- self.state == 'AVAILABLE'
51
- end
52
-
53
- def failed?
54
- self.state == 'ERROR'
55
- end
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 'fog/core/collection'
2
- require 'fog/profitbricks/models/compute/datacenter'
1
+ require "fog/core/collection"
2
+ require "fog/profitbricks/models/compute/datacenter"
3
3
 
4
4
  module Fog
5
- module Compute
6
- class ProfitBricks
7
- class Datacenters < Fog::Collection
8
- model Fog::Compute::ProfitBricks::Datacenter
5
+ module Compute
6
+ class ProfitBricks
7
+ class Datacenters < Fog::Collection
8
+ model Fog::Compute::ProfitBricks::Datacenter
9
9
 
10
- def all
11
- load (service.get_all_data_centers.body['getAllDataCentersResponse'])
12
- end
10
+ def all
11
+ load(service.get_all_data_centers.body["getAllDataCentersResponse"])
12
+ end
13
13
 
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
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
- module Compute
3
- class ProfitBricks
4
- class Flavor < Fog::Model
5
- identity :id, :aliases => 'flavorId'
6
- attribute :name, :aliases => 'flavorName'
7
- attribute :cores
8
- attribute :ram
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
- def initialize(attributes={})
11
- super
12
- end
13
+ def initialize(attributes = {})
14
+ super
15
+ end
13
16
 
14
- def save
15
- requires :name, :ram, :cores
16
- data = service.create_flavor(name, cores, ram)
17
- merge_attributes(data.body['createFlavorResponse'])
18
- true
19
- end
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
- def update
22
- Fog::Mock.not_implemented
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 'fog/core/collection'
2
- require 'fog/profitbricks/models/compute/flavor'
1
+ require "fog/core/collection"
2
+ require "fog/profitbricks/models/compute/flavor"
3
3
 
4
4
  module Fog
5
- module Compute
6
- class ProfitBricks
7
- class Flavors < Fog::Collection
8
- model Fog::Compute::ProfitBricks::Flavor
5
+ module Compute
6
+ class ProfitBricks
7
+ class Flavors < Fog::Collection
8
+ model Fog::Compute::ProfitBricks::Flavor
9
9
 
10
- def all()
11
- load (service.get_all_flavors.body['getAllFlavorsResponse'])
12
- end
10
+ def all()
11
+ load(service.get_all_flavors.body["getAllFlavorsResponse"])
12
+ end
13
13
 
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
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
- module Compute
3
- class ProfitBricks
4
- class Image < Fog::Model
5
- identity :id, :aliases => 'imageId'
6
- attribute :name, :aliases => 'imageName'
7
- attribute :type, :aliases => 'imageType'
8
- attribute :size, :aliases => 'imageSize'
9
- attribute :cpu_hotplug, :aliases => 'cpuHotPlug'
10
- attribute :cpu_hotunplug, :aliases => 'cpuHotUnplug'
11
- attribute :ram_hotplug, :aliases => 'memoryHotPlug'
12
- attribute :ram_hotunplug, :aliases => 'memoryHotUnPlug'
13
- attribute :disc_hotplug, :aliases => 'discVirtioHotPlug'
14
- attribute :disc_hotunplug, :aliases => 'discVirtioUnHotPlug'
15
- attribute :nic_hotplug, :aliases => 'nicHotPlug'
16
- attribute :nic_hotunplug, :aliases => 'nicHotUnPlug'
17
- attribute :server_ids, :aliases => 'serverIds'
18
- attribute :os_type, :aliases => 'osType'
19
- attribute :region, :aliases => 'location'
20
- attribute :bootable
21
- attribute :writeable
22
- attribute :public
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
- def initialize(attributes={})
25
- super
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 'fog/core/collection'
2
- require 'fog/profitbricks/models/compute/image'
1
+ require "fog/core/collection"
2
+ require "fog/profitbricks/models/compute/image"
3
3
 
4
4
  module Fog
5
- module Compute
6
- class ProfitBricks
7
- class Images < Fog::Collection
8
- model Fog::Compute::ProfitBricks::Image
5
+ module Compute
6
+ class ProfitBricks
7
+ class Images < Fog::Collection
8
+ model Fog::Compute::ProfitBricks::Image
9
9
 
10
- def all
11
- load (service.get_all_images.body['getAllImagesResponse'])
12
- end
10
+ def all
11
+ load(service.get_all_images.body["getAllImagesResponse"])
12
+ end
13
13
 
14
- def get(id)
15
- image = service.get_image(id).body['getImageResponse']
16
- new(image)
17
- rescue Fog::Errors::NotFound
18
- nil
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
- module Compute
3
- class ProfitBricks
4
- class Interface < Fog::Model
5
- identity :id, :aliases => 'nicId'
6
- attribute :name, :aliases => 'nicName'
7
- attribute :mac_address, :aliases => 'macAddress'
8
- attribute :lan_id, :aliases => 'lanId'
9
- attribute :dhcp_active, :aliases => 'dhcpActive'
10
- attribute :ips, :aliases => 'ips'
11
- attribute :server_id, :aliases => 'serverId'
12
- attribute :internet_access, :aliases => 'internetAccess'
13
- attribute :state, :aliases => 'provisioningState'
14
- attribute :firewall
15
- attribute :data_center_id, :aliases => 'dataCenterId'
16
- attribute :data_center_version, :aliases => 'dataCenterVersion'
17
- attribute :request_id, :aliases => 'requestId'
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
- attr_accessor :options
22
+ attr_accessor :options
20
23
 
21
- def initialize(attributes={})
22
- super
23
- end
24
+ def initialize(attributes = {})
25
+ super
26
+ end
24
27
 
25
- def save
26
- requires :server_id, :lan_id
28
+ def save
29
+ requires :server_id, :lan_id
27
30
 
28
- data = service.create_nic(server_id, lan_id, options={})
29
- merge_attributes(data.body['createNicResponse'])
30
- true
31
- end
31
+ data = service.create_nic(server_id, lan_id, options = {})
32
+ merge_attributes(data.body["createNicResponse"])
33
+ true
34
+ end
32
35
 
33
- def update
34
- requires :id
36
+ def update
37
+ requires :id
35
38
 
36
- data = service.update_nic(id, options)
37
- merge_attributes(data.body['updateNicResponse'])
38
- true
39
- end
39
+ data = service.update_nic(id, options)
40
+ merge_attributes(data.body["updateNicResponse"])
41
+ true
42
+ end
40
43
 
41
- def destroy
42
- requires :id
43
- service.delete_nic(id)
44
- true
45
- end
44
+ def destroy
45
+ requires :id
46
+ service.delete_nic(id)
47
+ true
48
+ end
46
49
 
47
- def set_internet_access(options={})
48
- service.set_internet_access(
49
- options[:data_center_id], options[:lan_id], options[:internet_access]
50
- )
51
- true
52
- end
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
- def ready?
55
- self.state == 'AVAILABLE'
56
- end
57
+ def ready?
58
+ state == "AVAILABLE"
59
+ end
57
60
 
58
- def failed?
59
- self.state == 'ERROR'
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 'fog/core/collection'
2
- require 'fog/profitbricks/models/compute/interface'
1
+ require "fog/core/collection"
2
+ require "fog/profitbricks/models/compute/interface"
3
3
 
4
4
  module Fog
5
- module Compute
6
- class ProfitBricks
7
- class Interfaces < Fog::Collection
8
- model Fog::Compute::ProfitBricks::Interface
5
+ module Compute
6
+ class ProfitBricks
7
+ class Interfaces < Fog::Collection
8
+ model Fog::Compute::ProfitBricks::Interface
9
9
 
10
- def all
11
- load(service.get_all_nic.body['getAllNicResponse'])
12
- end
10
+ def all
11
+ load(service.get_all_nic.body["getAllNicResponse"])
12
+ end
13
13
 
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
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
- module Compute
3
- class ProfitBricks
4
- class Region < Fog::Model
5
- identity :id, :aliases => 'locationId'
6
- attribute :name, :aliases => 'locationName'
7
- attribute :country, :aliases => 'country'
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
- def initialize(attributes={})
10
- super
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 'fog/core/collection'
2
- require 'fog/profitbricks/models/compute/region'
1
+ require "fog/core/collection"
2
+ require "fog/profitbricks/models/compute/region"
3
3
 
4
4
  module Fog
5
- module Compute
6
- class ProfitBricks
7
- class Regions < Fog::Collection
8
- model Fog::Compute::ProfitBricks::Region
5
+ module Compute
6
+ class ProfitBricks
7
+ class Regions < Fog::Collection
8
+ model Fog::Compute::ProfitBricks::Region
9
9
 
10
- def all()
11
- load (service.get_all_locations.body['getAllLocationsResponse'])
12
- end
10
+ def all()
11
+ load(service.get_all_locations.body["getAllLocationsResponse"])
12
+ end
13
13
 
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
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 'fog/compute/models/server'
1
+ require "fog/compute/models/server"
2
2
 
3
3
  module Fog
4
- module Compute
5
- class ProfitBricks
6
- class Server < Fog::Compute::Server
7
- identity :id, :aliases => 'serverId'
8
- attribute :name, :aliases => 'serverName'
9
- attribute :cores
10
- attribute :ram
11
- attribute :attached_volumes, :aliases => 'connectedStorages'
12
- attribute :interfaces, :aliases => 'nics'
13
- attribute :internet_access, :aliases => 'internetAccess'
14
- attribute :zone, :aliases => 'availabilityZone'
15
- attribute :creation_time, :aliases => 'creationTime'
16
- attribute :modification_time, :aliases => 'lastModificationTime'
17
- attribute :machine_state, :aliases => 'virtualMachineState'
18
- attribute :state, :aliases => 'provisioningState'
19
- attribute :os_type, :aliases => 'osType'
20
- attribute :cpu_hotplug, :aliases => 'cpuHotPlug'
21
- attribute :ram_hotplug, :aliases => 'ramHotPlug'
22
- attribute :nic_hotplug, :aliases => 'nicHotPlug'
23
- attribute :nic_hotunplug, :aliases => 'nicHotUnPlug'
24
- attribute :disc_hotplug, :aliases => 'discVirtioHotPlug'
25
- attribute :disc_hotunplug, :aliases => 'discVirtioHotUnPlug'
26
- attribute :data_center_id, :aliases => 'dataCenterId'
27
- attribute :data_center_version, :aliases => 'dataCenterVersion'
28
- attribute :request_id, :aliases => 'requestId'
29
-
30
- attr_accessor :options
31
- attr_accessor :flavor_id
32
-
33
- def initialize(attributes={})
34
- super
35
- end
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 'fog/core/collection'
2
- require 'fog/profitbricks/models/compute/server'
1
+ require "fog/core/collection"
2
+ require "fog/profitbricks/models/compute/server"
3
3
 
4
4
  module Fog
5
- module Compute
6
- class ProfitBricks
7
- class Servers < Fog::Collection
8
- model Fog::Compute::ProfitBricks::Server
5
+ module Compute
6
+ class ProfitBricks
7
+ class Servers < Fog::Collection
8
+ model Fog::Compute::ProfitBricks::Server
9
9
 
10
- def all
11
- load (service.get_all_servers.body['getAllServersResponse'])
12
- end
10
+ def all
11
+ load(service.get_all_servers.body["getAllServersResponse"])
12
+ end
13
13
 
14
- def get(id)
15
- server = service.get_server(id).body['getServerResponse']
16
- new(server)
17
- rescue Excon::Errors::NotFound
18
- nil
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
- module Compute
3
- class ProfitBricks
4
- class Volume < Fog::Model
5
- identity :id, :aliases => 'storageId'
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
- attr_accessor :options
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
- def initialize(attributes={})
20
- super
21
- end
20
+ attr_accessor :options
22
21
 
23
- def save
24
- requires :data_center_id, :size
22
+ def initialize(attributes = {})
23
+ super
24
+ end
25
25
 
26
- data = service.create_storage(data_center_id, size, options)
27
- merge_attributes(data.body['createStorageResponse'])
28
- true
29
- end
26
+ def save
27
+ requires :data_center_id, :size
30
28
 
31
- def update
32
- requires :id
29
+ data = service.create_storage(data_center_id, size, options)
30
+ merge_attributes(data.body["createStorageResponse"])
31
+ true
32
+ end
33
33
 
34
- data = service.update_storage(id, options)
35
- merge_attributes(data.body['updateStorageResponse'])
36
- true
37
- end
34
+ def update
35
+ requires :id
38
36
 
39
- def attach(server_id, options={})
40
- requires :id
41
-
42
- options = {
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
- data = service.connect_storage_to_server(id, server_id, options)
48
- reload
49
- end
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
- def detach(server_id)
52
- requires :id
50
+ data = service.connect_storage_to_server(id, server_id, options)
51
+ reload
52
+ end
53
53
 
54
- data = service.disconnect_storage_from_server(id, server_id)
55
- reload
56
- end
54
+ def detach(server_id)
55
+ requires :id
57
56
 
58
- def destroy
59
- requires :id
60
- service.delete_storage(id)
61
- true
62
- end
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
- def ready?
65
- self.state == 'AVAILABLE'
66
- end
67
+ def ready?
68
+ state == "AVAILABLE"
69
+ end
67
70
 
68
- def failed?
69
- self.state == 'ERROR'
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 'fog/core/collection'
2
- require 'fog/profitbricks/models/compute/volume'
1
+ require "fog/core/collection"
2
+ require "fog/profitbricks/models/compute/volume"
3
3
 
4
4
  module Fog
5
- module Compute
6
- class ProfitBricks
7
- class Volumes < Fog::Collection
8
- model Fog::Compute::ProfitBricks::Volume
5
+ module Compute
6
+ class ProfitBricks
7
+ class Volumes < Fog::Collection
8
+ model Fog::Compute::ProfitBricks::Volume
9
9
 
10
- def all
11
- load(service.get_all_storages.body['getAllStoragesResponse'])
12
- end
10
+ def all
11
+ load(service.get_all_storages.body["getAllStoragesResponse"])
12
+ end
13
13
 
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
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
@@ -37,6 +37,7 @@ module Fog
37
37
  @storage['size'] = value.to_i
38
38
  when 'connectedStorages'
39
39
  @server['connectedStorages'] << @storage
40
+ @storage = {}
40
41
  when 'nicId', 'nicName', 'macAddress', 'gatewayIp',
41
42
  'dhcpActive', 'ips'
42
43
  @nic[name] = value
@@ -39,6 +39,7 @@ module Fog
39
39
  @storage['size'] = value.to_i
40
40
  when 'connectedStorages'
41
41
  @response['getServerResponse']['connectedStorages'] << @storage
42
+ @storage = {}
42
43
  when 'nicId', 'nicName', 'macAddress', 'gatewayIp',
43
44
  'dhcpActive', 'ips'
44
45
  @nic[name] = value
@@ -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["machine_state"] = "RUNNING"
42
- server["provisioning_state"] = "AVAILABLE"
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["machine_state"] = "SHUTOFF"
42
- server["provisioning_state"] = "INACTIVE"
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
@@ -1,5 +1,5 @@
1
1
  module Fog
2
2
  module ProfitBricks
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  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.1
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: 2014-10-24 00:00:00.000000000 Z
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