fog-softlayer 0.3.23 → 0.3.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/fog/softlayer/models/network/subnet.rb +49 -8
- data/lib/fog/softlayer/network.rb +3 -0
- data/lib/fog/softlayer/requests/network/create_subnet.rb +27 -0
- data/lib/fog/softlayer/requests/network/get_datacenter_routers.rb +4 -1
- data/lib/fog/softlayer/requests/network/get_portable_subnet_package_id.rb +33 -0
- data/lib/fog/softlayer/requests/network/get_portable_subnet_price_code.rb +31 -0
- data/lib/fog/softlayer/requests/network/get_subnet.rb +1 -1
- data/lib/fog/softlayer/requests/network/get_subnet_package_id.rb +6 -2
- data/lib/fog/softlayer/requests/network/get_subnet_price_code.rb +4 -4
- data/lib/fog/softlayer/version.rb +1 -1
- data/tests/softlayer/requests/network/network_tests.rb +2 -2
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZjA1MDg2NWU4OWViM2IyNTU4Y2Y1OTViOWEwMjIwZTM4ZTBjZjg4OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NjFkODczNzBmOGQ2ZjlhNTIxYzE3ZWNjMTA3YjA3MmIxNzI5ZmMzZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2E0NWIxYTJjYzRiM2M5ZjdkODdjMTE5OTQ1OGJiYzA3ZDliZThhMzZlNGIx
|
10
|
+
N2E3NzcwOWExMzcyNGZkOGRjY2FlYzRjMjUxMDU2MjAxMzljYjdjY2JkMmVl
|
11
|
+
YmU2Y2FjNTVhYmZkYTJiOTVlZGIzYWQ0NzA4OGEzNDZlYTgxNjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MzM3MmY5MTUxYzliNTRmNTFkNzY2NmZkYmY4MWQwNzk5NmY4MzkwOGEzMTJh
|
14
|
+
ZDM1YjM5ZjllNWVhNWEzYzQ1MzFlMTcyMzZlNjY4ZjQ4MjViM2VmYzFjZWRi
|
15
|
+
YTkxNDE4NzNkMzA0N2I2YmVlYTgzZWNkNjNhMDkzM2U5NDYyYWI=
|
@@ -23,24 +23,49 @@ module Fog
|
|
23
23
|
attribute :broadcast, :aliases => 'broadcastAddress'
|
24
24
|
attribute :gateway
|
25
25
|
attribute :datacenter, :squash => :name
|
26
|
+
attribute :address_space, :aliases => 'addressSpace'
|
26
27
|
|
27
28
|
def addresses
|
28
|
-
@addresses ||=
|
29
|
-
|
29
|
+
@addresses ||= begin
|
30
|
+
if attributes['ipAddresses'].nil?
|
31
|
+
[]
|
32
|
+
else
|
33
|
+
attributes['ipAddresses'].map do |address|
|
34
|
+
service.ips.get(address['id'])
|
35
|
+
end
|
36
|
+
end
|
30
37
|
end
|
31
38
|
end
|
32
39
|
|
40
|
+
#def addresses=(addresses)
|
41
|
+
# @addresses = addresses
|
42
|
+
#end
|
43
|
+
|
44
|
+
def portable?
|
45
|
+
type == 'ROUTED_TO_VLAN'
|
46
|
+
end
|
47
|
+
|
48
|
+
def private?
|
49
|
+
address_space == 'PRIVATE'
|
50
|
+
end
|
51
|
+
|
52
|
+
def public?
|
53
|
+
not private?
|
54
|
+
end
|
55
|
+
|
33
56
|
def save
|
34
57
|
requires :network_id, :cidr, :ip_version
|
35
58
|
identity ? update : create
|
36
59
|
end
|
37
60
|
|
38
|
-
def create
|
39
|
-
requires :
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
61
|
+
def create(address_count=4)
|
62
|
+
requires :vlan_id
|
63
|
+
response = service.create_subnet(build_order(address_count)).body
|
64
|
+
merge_attributes(response)
|
65
|
+
#merge_attributes(service.create_subnet(self.network_id,
|
66
|
+
# self.cidr,
|
67
|
+
# self.ip_version,
|
68
|
+
# self.attributes).body['subnet'])
|
44
69
|
self
|
45
70
|
end
|
46
71
|
|
@@ -56,6 +81,22 @@ module Fog
|
|
56
81
|
service.delete_subnet(self.id)
|
57
82
|
true
|
58
83
|
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def build_order(address_count)
|
88
|
+
order = {
|
89
|
+
'complexType' => 'SoftLayer_Container_Product_Order_Network_Subnet',
|
90
|
+
'location' => datacenter,
|
91
|
+
'quantity' =>1,
|
92
|
+
'packageId' =>0,
|
93
|
+
'prices' =>[
|
94
|
+
{'id' => portable? ? service.get_portable_subnet_price_code(address_count, public?) : service.get_subnet_price_code }
|
95
|
+
]
|
96
|
+
}
|
97
|
+
order['endPointVlanId'] = vlan_id if portable?
|
98
|
+
order
|
99
|
+
end
|
59
100
|
end
|
60
101
|
end
|
61
102
|
end
|
@@ -39,6 +39,7 @@ module Fog
|
|
39
39
|
|
40
40
|
request :list_networks
|
41
41
|
request :create_network
|
42
|
+
request :create_subnet
|
42
43
|
request :delete_network
|
43
44
|
request :get_network
|
44
45
|
|
@@ -46,6 +47,8 @@ module Fog
|
|
46
47
|
request :get_public_vlan_price_code
|
47
48
|
request :get_subnet_package_id
|
48
49
|
request :get_subnet_price_code
|
50
|
+
request :get_portable_subnet_package_id
|
51
|
+
request :get_portable_subnet_price_code
|
49
52
|
request :get_datacenters
|
50
53
|
request :get_datacenter_routers
|
51
54
|
request :get_references_by_tag_name
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
|
3
|
+
# © Copyright IBM Corporation 2014.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
|
8
|
+
module Fog
|
9
|
+
module Network
|
10
|
+
class Softlayer
|
11
|
+
|
12
|
+
class Mock
|
13
|
+
def create_subnet(order)
|
14
|
+
raise ArgumentError, "Order argument for #{self.class.name}##{__method__} must be Hash." unless order.is_a?(Hash)
|
15
|
+
# TODO: more than a stub
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class Real
|
20
|
+
def create_subnet(order)
|
21
|
+
raise ArgumentError, "Order argument for #{self.class.name}##{__method__} must be Hash." unless order.is_a?(Hash)
|
22
|
+
self.request(:product_order, :place_order, :body => order, :http_method => :post)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -33,7 +33,10 @@ module Fog
|
|
33
33
|
|
34
34
|
class Real
|
35
35
|
def get_datacenter_routers(id)
|
36
|
-
|
36
|
+
Excon.defaults[:read_timeout] *= 2 # this SLAPI method is incredibly slow to respond
|
37
|
+
result = request(:location_datacenter, "#{id}/get_hardware_routers", :query => 'objectMask=id;hostname')
|
38
|
+
Excon.defaults[:read_timeout] /= 2
|
39
|
+
result
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
|
3
|
+
# © Copyright IBM Corporation 2014.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
|
8
|
+
module Fog
|
9
|
+
module Network
|
10
|
+
class Softlayer
|
11
|
+
|
12
|
+
class Mock
|
13
|
+
|
14
|
+
def get_portable_subnet_package_id(address_space)
|
15
|
+
address_space.downcase!; err_msg = "Argument for #{self.class.name}##{__method__} must be 'PRIVATE' or 'PUBLIC'."
|
16
|
+
raise ArgumentError, err_msg unless %{private public}.include?(address_space)
|
17
|
+
42
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
class Real
|
23
|
+
def get_portable_subnet_package_id(address_space)
|
24
|
+
address_space.downcase!; err_msg = "Argument for #{self.class.name}##{__method__} must be 'PRIVATE' or 'PUBLIC'."
|
25
|
+
raise ArgumentError, err_msg unless %{private public}.include?(address_space)
|
26
|
+
request(:product_package, '0/get_configuration', :query => 'objectMask=mask[isRequired,itemCategory]').body.map do |item|
|
27
|
+
item['itemCategory']['id'] if item['itemCategory']['categoryCode'] == "sov_sec_ip_addresses_#{address_space == 'public' ? 'pub' : 'priv'}"
|
28
|
+
end.compact.first
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Matt Eldridge (<matt.eldridge@us.ibm.com>)
|
3
|
+
# © Copyright IBM Corporation 2014.
|
4
|
+
#
|
5
|
+
# LICENSE: MIT (http://opensource.org/licenses/MIT)
|
6
|
+
#
|
7
|
+
|
8
|
+
module Fog
|
9
|
+
module Network
|
10
|
+
class Softlayer
|
11
|
+
|
12
|
+
class Mock
|
13
|
+
|
14
|
+
def get_portable_subnet_price_code(address_count, public=true)
|
15
|
+
42
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
class Real
|
21
|
+
def get_portable_subnet_price_code(address_count, public=true)
|
22
|
+
portable_subnet_package_id = get_portable_subnet_package_id(public ? 'PUBLIC' : 'PRIVATE')
|
23
|
+
request(:product_package, '0/get_item_prices', :query => 'objectMask=mask[id,categories.id,item.description]').body.map do |item|
|
24
|
+
catg = item['categories'][0]
|
25
|
+
item['id'] if catg['id'] == portable_subnet_package_id && item['item']['description'] =~ /^#{address_count}/
|
26
|
+
end.compact.first
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -20,7 +20,7 @@ module Fog
|
|
20
20
|
|
21
21
|
class Real
|
22
22
|
def get_subnet(id)
|
23
|
-
self.request(:network_subnet, "#{id}/get_object", :query => 'objectMask=mask[datacenter,ipAddresses.id,virtualGuests.fullyQualifiedDomainName,virtualGuests.id,hardware.fullyQualifiedDomainName,hardware.id]')
|
23
|
+
self.request(:network_subnet, "#{id}/get_object", :query => 'objectMask=mask[datacenter,ipAddresses.id,virtualGuests.fullyQualifiedDomainName,virtualGuests.id,hardware.fullyQualifiedDomainName,hardware.id,addressSpace]')
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -11,14 +11,18 @@ module Fog
|
|
11
11
|
|
12
12
|
class Mock
|
13
13
|
|
14
|
-
def get_subnet_package_id
|
14
|
+
def get_subnet_package_id(address_space)
|
15
|
+
address_space.downcase!; err_msg = "Argument for #{self.class.name}##{__method__} must be 'PRIVATE' or 'PUBLIC'."
|
16
|
+
raise ArgumentError, err_msg unless %{private public}.include?(address_space)
|
15
17
|
42
|
16
18
|
end
|
17
19
|
|
18
20
|
end
|
19
21
|
|
20
22
|
class Real
|
21
|
-
def get_subnet_package_id
|
23
|
+
def get_subnet_package_id(address_space)
|
24
|
+
address_space.downcase!; err_msg = "Argument for #{self.class.name}##{__method__} must be 'PRIVATE' or 'PUBLIC'."
|
25
|
+
raise ArgumentError, err_msg unless %{private public}.include?(address_space)
|
22
26
|
request(:product_package, '0/get_configuration', :query => 'objectMask=mask[isRequired,itemCategory]').body.map do |item|
|
23
27
|
item['itemCategory']['id'] if item['itemCategory']['categoryCode'] == 'static_sec_ip_addresses'
|
24
28
|
end.compact.first
|
@@ -11,17 +11,17 @@ module Fog
|
|
11
11
|
|
12
12
|
class Mock
|
13
13
|
|
14
|
-
def get_subnet_price_code
|
14
|
+
def get_subnet_price_code(address_count, public=true)
|
15
15
|
42
|
16
16
|
end
|
17
17
|
|
18
18
|
end
|
19
19
|
|
20
20
|
class Real
|
21
|
-
def get_subnet_price_code
|
22
|
-
subnet_package_id = get_subnet_package_id
|
21
|
+
def get_subnet_price_code(address_count, public=true)
|
22
|
+
subnet_package_id = get_subnet_package_id(public ? 'PUBLIC' : 'PRIVATE')
|
23
23
|
request(:product_package, '0/get_item_prices', :query => 'objectMask=mask[id,categories.id,item.description]').body.map do |item|
|
24
|
-
item['id'] if
|
24
|
+
item['id'] if catg['id'] == subnet_package_id && item['item']['description'] =~ /^#{address_count}/
|
25
25
|
end.compact.first
|
26
26
|
end
|
27
27
|
end
|
@@ -35,11 +35,11 @@ Shindo.tests("Fog::Network[:softlayer] | network requests", ["softlayer"]) do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
tests("#get_subnet_package_id") do
|
38
|
-
data_matches_schema(Integer) { @sl.get_subnet_package_id }
|
38
|
+
data_matches_schema(Integer) { @sl.get_subnet_package_id('PUBLIC') }
|
39
39
|
end
|
40
40
|
|
41
41
|
tests("#get_subnet_price_code") do
|
42
|
-
data_matches_schema(Integer) { @sl.get_subnet_price_code }
|
42
|
+
data_matches_schema(Integer) { @sl.get_subnet_price_code(4) }
|
43
43
|
end
|
44
44
|
|
45
45
|
tests("#create_network(#{@order})") do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fog-softlayer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Eldridge
|
@@ -279,6 +279,7 @@ files:
|
|
279
279
|
- lib/fog/softlayer/requests/dns/update_record.rb
|
280
280
|
- lib/fog/softlayer/requests/network/create_network.rb
|
281
281
|
- lib/fog/softlayer/requests/network/create_network_tags.rb
|
282
|
+
- lib/fog/softlayer/requests/network/create_subnet.rb
|
282
283
|
- lib/fog/softlayer/requests/network/delete_global_ip_address.rb
|
283
284
|
- lib/fog/softlayer/requests/network/delete_network.rb
|
284
285
|
- lib/fog/softlayer/requests/network/delete_network_tags.rb
|
@@ -290,6 +291,8 @@ files:
|
|
290
291
|
- lib/fog/softlayer/requests/network/get_ip_addresses.rb
|
291
292
|
- lib/fog/softlayer/requests/network/get_network.rb
|
292
293
|
- lib/fog/softlayer/requests/network/get_network_tags.rb
|
294
|
+
- lib/fog/softlayer/requests/network/get_portable_subnet_package_id.rb
|
295
|
+
- lib/fog/softlayer/requests/network/get_portable_subnet_price_code.rb
|
293
296
|
- lib/fog/softlayer/requests/network/get_private_vlan_price_code.rb
|
294
297
|
- lib/fog/softlayer/requests/network/get_public_vlan_price_code.rb
|
295
298
|
- lib/fog/softlayer/requests/network/get_references_by_tag_name.rb
|