softlayer_api 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -131,7 +131,7 @@ module SoftLayer
131
131
  has_active_transaction = has_sl_property? :activeTransaction
132
132
 
133
133
  reloading_os = has_active_transaction && has_os_reload && (self.lastOperatingSystemReload['id'] == self.activeTransaction['id'])
134
- provisioned = has_sl_property? :provisionDate
134
+ provisioned = has_sl_property?(:provisionDate) && ! self['provisionDate'].empty?
135
135
 
136
136
  # a server is ready when it is provisioned, not reloading the OS
137
137
  # (and if wait_for_transactions is true, when there are no active transactions).
@@ -313,4 +313,4 @@ module SoftLayer
313
313
  return softlayer_client[:Virtual_Guest].object_with_id(self.id)
314
314
  end
315
315
  end #class VirtualServer
316
- end
316
+ end
@@ -0,0 +1,161 @@
1
+ #--
2
+ # Copyright (c) 2014 SoftLayer Technologies, Inc. All rights reserved.
3
+ #
4
+ # For licensing information see the LICENSE.md file in the project root.
5
+ #++
6
+
7
+ module SoftLayer
8
+ #
9
+ # This class is used to order a virtual server using a product package.
10
+ #
11
+ # Ordering a server using a product package is a more complex process than
12
+ # ordering with simple attributes (as is done by the VirtualServerServerOrder class).
13
+ # However with that complexity comes the the ability to specify the configuration
14
+ # of the server in exacting detail.
15
+ #
16
+ # To use this class, you first select a product package. The product package
17
+ # defines the base configuration of the server as well as the set of configuration
18
+ # options available for that server. To fully configure the server you must select
19
+ # the value for each configuration option.
20
+ #
21
+ # This class roughly Corresponds to the SoftLayer_Container_Product_Order_Virtual_Guest
22
+ # data type in the SoftLayer API
23
+ #
24
+ # http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Product_Order_Virtual_Guest
25
+ #
26
+ class VirtualServerOrder_Package < Server
27
+ # The following properties are required in a server order.
28
+
29
+ # The product package object (an instance of SoftLayer::ProductPackage) identifying the base
30
+ # configuration for the server. A Virtual Server product package is returned by
31
+ # SoftLayer::ProductPackage.virtual_server_package
32
+ attr_reader :package
33
+
34
+ # An instance of SoftLayer::Datacenter. The server will be provisioned in this data center.
35
+ # The set of datacenters available is determined by the package and may be obtained from
36
+ # the SoftLayer::ProductPackage object using the #datacenter_options method.
37
+ attr_accessor :datacenter
38
+
39
+ # The hostname of the server being created (i.e. 'sldn' is the hostname of sldn.softlayer.com).
40
+ attr_accessor :hostname
41
+
42
+ # The domain of the server being created (i.e. 'softlayer.com' is the domain of sldn.softlayer.com)
43
+ attr_accessor :domain
44
+
45
+ # The value of this property should be a hash. The keys of the hash are ProdcutItemCategory
46
+ # codes (like 'os' and 'ram') while the values may be Integers or Objects. The Integer values
47
+ # should be the +id+ of a +SoftLayer_Product_Item_Price+ representing the configuration option
48
+ # chosen for that category. Objects must respond to the +price_id+ message and return an integer
49
+ # that is the +id+ of a +SoftLayer_Product_Item_Price+. Instances of the ProductConfigurationOption
50
+ # class behave this way.
51
+ #
52
+ # At a minimum, the configuation_options should include entries for each of the categories
53
+ # required by the package (i.e. those returned from ProductPackage#required_categories)
54
+ attr_accessor :configuration_options
55
+
56
+ # The following properties are optional, but allow further fine tuning of
57
+ # the server
58
+
59
+ # Boolean, If true, an hourly server will be ordered, otherwise a monthly server will be ordered
60
+ # Corresponds to +useHourlyPricing+ in the SoftLayer_Container_Product_Order_Virtual_Guest container
61
+ # documentation
62
+ attr_accessor :hourly
63
+
64
+ # An instance of the SoftLayer::ImageTemplate class. Represents the image template that should
65
+ # be installed on the server.
66
+ attr_accessor :image_template
67
+
68
+ # The URI of a script to execute on the server after it has been provisioned. This may be
69
+ # any object which accepts the to_s message. The resulting string will be passed to SoftLayer API.
70
+ attr_accessor :provision_script_URI
71
+
72
+ # An array of the ids of SSH keys to install on the server upon provisioning
73
+ # To obtain a list of existing SSH keys, call getSshKeys on the SoftLayer_Account service:
74
+ # client[:Account].getSshKeys()
75
+ attr_accessor :ssh_key_ids
76
+
77
+ # String, User metadata associated with the instance
78
+ # Corresponds to +userData+ in the +SoftLayer_Virtual_Guest+ documentation
79
+ attr_accessor :user_metadata
80
+
81
+ ##
82
+ # You initialize a VirtualServerOrder_Package by passing in the package that you
83
+ # are ordering from.
84
+ def initialize(client = nil)
85
+ @softlayer_client = client || Client.default_client
86
+ raise "#{__method__} requires a client but none was given and Client::default_client is not set" if !@softlayer_client
87
+
88
+ @configuration_options = []
89
+ @package = SoftLayer::ProductPackage.virtual_server_package(@softlayer_client)
90
+ end
91
+
92
+ ##
93
+ # Present the order for verification by the SoftLayer ordering system.
94
+ # The order is verified, but not executed. This should not
95
+ # change the billing of your account.
96
+ #
97
+ # If you add a block to the method call, it will receive the product
98
+ # order template before it is sent to the API. You may **carefully** make
99
+ # changes to the template to provide specialized configuration.
100
+ #
101
+ def verify
102
+ product_order = virtual_server_order
103
+ product_order = yield product_order if block_given?
104
+ softlayer_client[:Product_Order].verifyOrder(product_order)
105
+ end
106
+
107
+ ##
108
+ # Submit the order to be executed by the SoftLayer ordering system.
109
+ # If successful this will probably result in additional billing items
110
+ # applied to your account!
111
+ #
112
+ # If you add a block to the method call, it will receive the product
113
+ # order template before it is sent to the API. You may **carefully** make
114
+ # changes to the template to provide specialized configuration.
115
+ #
116
+ # The return value of this call is a product order receipt. After
117
+ # submitting the order, it will proceed to Sales for authorization.
118
+ #
119
+ def place_order!
120
+ product_order = virtual_server_order
121
+ product_order = yield product_order if block_given?
122
+ softlayer_client[:Product_Order].placeOrder(product_order)
123
+ end
124
+
125
+ protected
126
+
127
+ ##
128
+ # Construct and return a hash representing a +SoftLayer_Container_Product_Order_Virtual_Guest+
129
+ # based on the configuration options given.
130
+ def virtual_server_order
131
+ product_order = {
132
+ 'packageId' => @package.id,
133
+ 'useHourlyPricing' => !!@hourly,
134
+ 'virtualGuests' => [{
135
+ 'domain' => @domain,
136
+ 'hostname' => @hostname
137
+ }]
138
+ }
139
+
140
+ #Note that the use of image_template and SoftLayer::ProductPackage os/guest_diskX configuration category
141
+ #item prices is mutually exclusive.
142
+ product_order['imageTemplateGlobalIdentifier'] = @image_template.global_id if @image_template
143
+ product_order['location'] = @datacenter.id if @datacenter
144
+ product_order['provisionScripts'] = [@provision_script_URI.to_s] if @provision_script_URI
145
+ product_order['sshKeys'] = [{ 'sshKeyIds' => @ssh_key_ids }] if @ssh_key_ids
146
+ product_order['virtualGuests'][0]['userData'] = @user_metadata if @user_metadata
147
+
148
+ product_order['prices'] = @configuration_options.collect do |key, value|
149
+ if value.respond_to?(:price_id)
150
+ price_id = value.price_id
151
+ else
152
+ price_id = value.to_i
153
+ end
154
+
155
+ { 'id' => price_id }
156
+ end
157
+
158
+ product_order
159
+ end
160
+ end # VirtualServerOrder_Package
161
+ end # SoftLayer
@@ -12,7 +12,7 @@ require 'rubygems'
12
12
  module SoftLayer
13
13
  # The version number (including major, minor, and bugfix numbers)
14
14
  # This should change in accordance with the concept of Semantic Versioning
15
- VERSION = "3.0.0" # version history in the CHANGELOG.textile file at the root of the source
15
+ VERSION = "3.0.1" # version history in the CHANGELOG.textile file at the root of the source
16
16
 
17
17
  # The base URL of the SoftLayer API available to the public internet.
18
18
  API_PUBLIC_ENDPOINT = 'https://api.softlayer.com/xmlrpc/v3/'
data/lib/softlayer_api.rb CHANGED
@@ -22,19 +22,33 @@ require 'softlayer/ModelBase'
22
22
  require 'softlayer/Datacenter'
23
23
  require 'softlayer/DynamicAttribute'
24
24
  require 'softlayer/Account'
25
+ require 'softlayer/AccountPassword'
25
26
  require 'softlayer/Server'
26
27
  require 'softlayer/BareMetalServer'
27
28
  require 'softlayer/BareMetalServerOrder'
28
29
  require 'softlayer/BareMetalServerOrder_Package'
29
30
  require 'softlayer/ImageTemplate'
30
31
  require 'softlayer/NetworkComponent'
32
+ require 'softlayer/NetworkMessageDelivery'
33
+ require 'softlayer/NetworkService'
34
+ require 'softlayer/NetworkStorageAllowedHost'
35
+ require 'softlayer/NetworkStorageCredential'
36
+ require 'softlayer/NetworkStorageGroup'
37
+ require 'softlayer/NetworkStorage'
31
38
  require 'softlayer/ProductPackage'
32
39
  require 'softlayer/ProductItemCategory'
33
40
  require 'softlayer/ServerFirewall'
34
41
  require 'softlayer/ServerFirewallOrder'
42
+ require 'softlayer/SoftwarePassword'
43
+ require 'softlayer/Software'
35
44
  require 'softlayer/Ticket'
45
+ require 'softlayer/UserCustomerExternalBinding'
46
+ require 'softlayer/UserCustomer'
47
+ require 'softlayer/VirtualDiskImage'
48
+ require 'softlayer/VirtualDiskImageSoftware'
36
49
  require 'softlayer/VirtualServer'
37
50
  require 'softlayer/VirtualServerOrder'
51
+ require 'softlayer/VirtualServerOrder_Package'
38
52
  require 'softlayer/VirtualServerUpgradeOrder'
39
53
  require 'softlayer/VLANFirewall'
40
54
  require 'softlayer/VLANFirewallOrder'
metadata CHANGED
@@ -1,103 +1,103 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: softlayer_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - SoftLayer Development Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-30 00:00:00.000000000 Z
11
+ date: 2015-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: configparser
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.1.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.1.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rdoc
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 2.4.2
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.4.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: json
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '1.8'
76
- - - ! '>='
76
+ - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: 1.8.1
79
79
  type: :development
80
80
  prerelease: false
81
81
  version_requirements: !ruby/object:Gem::Requirement
82
82
  requirements:
83
- - - ~>
83
+ - - "~>"
84
84
  - !ruby/object:Gem::Version
85
85
  version: '1.8'
86
- - - ! '>='
86
+ - - ">="
87
87
  - !ruby/object:Gem::Version
88
88
  version: 1.8.1
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: coveralls
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - ! '>='
93
+ - - ">="
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - ! '>='
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
103
  description: The softlayer_api gem offers a convenient mechanism for invoking the
@@ -118,6 +118,7 @@ files:
118
118
  - examples/ticket_info.rb
119
119
  - lib/softlayer/APIParameterFilter.rb
120
120
  - lib/softlayer/Account.rb
121
+ - lib/softlayer/AccountPassword.rb
121
122
  - lib/softlayer/BareMetalServer.rb
122
123
  - lib/softlayer/BareMetalServerOrder.rb
123
124
  - lib/softlayer/BareMetalServerOrder_Package.rb
@@ -128,6 +129,12 @@ files:
128
129
  - lib/softlayer/ImageTemplate.rb
129
130
  - lib/softlayer/ModelBase.rb
130
131
  - lib/softlayer/NetworkComponent.rb
132
+ - lib/softlayer/NetworkMessageDelivery.rb
133
+ - lib/softlayer/NetworkService.rb
134
+ - lib/softlayer/NetworkStorage.rb
135
+ - lib/softlayer/NetworkStorageAllowedHost.rb
136
+ - lib/softlayer/NetworkStorageCredential.rb
137
+ - lib/softlayer/NetworkStorageGroup.rb
131
138
  - lib/softlayer/ObjectFilter.rb
132
139
  - lib/softlayer/ObjectMaskParser.rb
133
140
  - lib/softlayer/ObjectMaskProperty.rb
@@ -139,11 +146,18 @@ files:
139
146
  - lib/softlayer/ServerFirewall.rb
140
147
  - lib/softlayer/ServerFirewallOrder.rb
141
148
  - lib/softlayer/Service.rb
149
+ - lib/softlayer/Software.rb
150
+ - lib/softlayer/SoftwarePassword.rb
142
151
  - lib/softlayer/Ticket.rb
152
+ - lib/softlayer/UserCustomer.rb
153
+ - lib/softlayer/UserCustomerExternalBinding.rb
143
154
  - lib/softlayer/VLANFirewall.rb
144
155
  - lib/softlayer/VLANFirewallOrder.rb
156
+ - lib/softlayer/VirtualDiskImage.rb
157
+ - lib/softlayer/VirtualDiskImageSoftware.rb
145
158
  - lib/softlayer/VirtualServer.rb
146
159
  - lib/softlayer/VirtualServerOrder.rb
160
+ - lib/softlayer/VirtualServerOrder_Package.rb
147
161
  - lib/softlayer/VirtualServerUpgradeOrder.rb
148
162
  - lib/softlayer/base.rb
149
163
  - lib/softlayer/object_mask_helpers.rb
@@ -158,17 +172,17 @@ require_paths:
158
172
  - lib
159
173
  required_ruby_version: !ruby/object:Gem::Requirement
160
174
  requirements:
161
- - - ! '>='
175
+ - - ">="
162
176
  - !ruby/object:Gem::Version
163
177
  version: 1.9.2
164
178
  required_rubygems_version: !ruby/object:Gem::Requirement
165
179
  requirements:
166
- - - ! '>='
180
+ - - ">="
167
181
  - !ruby/object:Gem::Version
168
182
  version: '0'
169
183
  requirements: []
170
184
  rubyforge_project:
171
- rubygems_version: 2.2.2
185
+ rubygems_version: 2.4.5
172
186
  signing_key:
173
187
  specification_version: 4
174
188
  summary: Library for accessing the SoftLayer API