openstack 3.1.1 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f864493d851c849bb709231ab61e47e2923dfd5b
4
- data.tar.gz: 2e754b1dc07e46a9194861d231db48b7e2b3add6
3
+ metadata.gz: d38f9aecda8d0669fc12af8dd23ffab397aa9918
4
+ data.tar.gz: 6a1b99ea421f84a89820153a1b2388b7d83a4302
5
5
  SHA512:
6
- metadata.gz: 02dcde3c9f8c56e4027162917c260faa5d0a2286b894724157d9ba586391dd70eae4ab2004de92143b8ad7b8476fc38078b17f9f3c7db8df97bc189bef832cb3
7
- data.tar.gz: bd6b76291d03319bc21d3ff5a3673423d548c189bddcabd0b0660e020a36052abc93cb4fd3ad65b5d915785729c5b84416a26a165637a0ee99298287b3e8f779
6
+ metadata.gz: 827c41dd88de063fb6614dcb3a09f801a632644052a4ea4f4360233eb24d41bce913c7b94b5c904bfa5048d802d932dde26931b5f3e108da22a6a5d2ca9b081e
7
+ data.tar.gz: 0fbea0cc05bd5e862c646ebc4b8fe09c21cfd539f06d746828c6e0b82965b486ec974448e08987cf086d20d83253f4f7fe89c756aa4756ecdd6989037050bb8a
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.1.1
1
+ 3.2.0
@@ -33,6 +33,8 @@ module OpenStack
33
33
  require 'openstack/network/subnet'
34
34
  require 'openstack/network/router'
35
35
  require 'openstack/network/port'
36
+ require 'openstack/network/qos_policy'
37
+ require 'openstack/network/qos_bandwidth_limit_rule'
36
38
  require 'openstack/identity/connection'
37
39
  require 'openstack/identity/tenant'
38
40
  require 'openstack/identity/user'
@@ -18,8 +18,9 @@ module Network
18
18
  @connection.authok
19
19
  end
20
20
 
21
- def list_networks
22
- response = @connection.req("GET", "/networks")
21
+ def list_networks(options = {})
22
+ path = options.empty? ? "/networks" : "/networks?#{options.to_query}"
23
+ response = @connection.req("GET", path)
23
24
  nets_hash = JSON.parse(response.body)["networks"]
24
25
  nets_hash.inject([]){|res, current| res << OpenStack::Network::Network.new(current); res}
25
26
  end
@@ -158,6 +159,27 @@ module Network
158
159
  end
159
160
  end
160
161
 
162
+ def create_qos_policy(options)
163
+ data = JSON.generate(:policy => options)
164
+ response = @connection.req("POST", "/qos/policies", {:data => data})
165
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
166
+ OpenStack::Network::QoSPolicy.new(@connection, JSON.parse(response.body)["policy"])
167
+ end
168
+
169
+ def list_qos_policies(options = {})
170
+ path = options.empty? ? "/qos/policies" : "/qos/policies?#{options.to_query}"
171
+ response = @connection.req("GET", path)
172
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
173
+ qos_hash = JSON.parse(response.body)["policies"]
174
+ qos_hash.inject([]){|res, current| res << OpenStack::Network::QoSPolicy.new(@connection, current); res}
175
+ end
176
+
177
+ def get_qos_policy(policy_id)
178
+ response = @connection.req("GET", "/qos/policies/#{policy_id}")
179
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
180
+ OpenStack::Network::QoSPolicy.new(@connection, JSON.parse(response.body)["policy"])
181
+ end
182
+
161
183
  end
162
184
 
163
185
  end
@@ -12,6 +12,7 @@ module Network
12
12
  attr_reader :device_id
13
13
  attr_reader :device_owner
14
14
  attr_reader :tenant_id
15
+ attr_reader :qos_policy_id
15
16
 
16
17
  def initialize(port_hash={})
17
18
  @id = port_hash["id"]
@@ -24,6 +25,7 @@ module Network
24
25
  @device_id = port_hash["device_id"]
25
26
  @device_owner = port_hash["device_owner"]
26
27
  @tenant_id = port_hash["tenant_id"]
28
+ @qos_policy_id = port_hash["qos_policy_id"]
27
29
  end
28
30
 
29
31
 
@@ -0,0 +1,44 @@
1
+ module OpenStack
2
+ module Network
3
+ class QoSBandwidthLimitRule
4
+
5
+ attr_reader :id
6
+ attr_reader :policy_id
7
+ attr_reader :max_kbps
8
+ attr_reader :max_burst_kbps
9
+
10
+ def initialize(policy, rule_hash={})
11
+ @policy = policy
12
+ populate(rule_hash)
13
+ end
14
+
15
+ def populate(rule_hash=nil)
16
+ if @id and not rule_hash
17
+ response = @policy.connection.req("GET", "/qos/policies/#{@policy_id}/bandwidth_limit_rules/#{@id}")
18
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
19
+ rule_hash = JSON.parse(response.body)["bandwidth_limit_rule"]
20
+ end
21
+
22
+ @id = rule_hash["id"]
23
+ @policy_id = rule_hash["policy_id"] || @policy.id
24
+ @max_kbps = rule_hash["max_kbps"]
25
+ @max_burst_kbps = rule_hash["max_burst_kbps"]
26
+ end
27
+
28
+ def delete!
29
+ response = @policy.connection.req('DELETE', "/qos/policies/#{@policy_id}/bandwidth_limit_rules/#{@id}")
30
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
31
+ true
32
+ end
33
+
34
+ def update(options)
35
+ data = JSON.generate(:bandwidth_limit_rule => options)
36
+ response = @policy.connection.req("PUT", "/qos/policies/#{@policy_id}/bandwidth_limit_rules/#{@id}", {:data => data})
37
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
38
+ populate(JSON.parse(response.body)["bandwidth_limit_rule"])
39
+ true
40
+ end
41
+
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,80 @@
1
+ module OpenStack
2
+ module Network
3
+ class QoSPolicy
4
+
5
+ attr_reader :connection
6
+ attr_reader :tenant_id
7
+ attr_reader :id
8
+ attr_reader :name
9
+ attr_reader :description
10
+ attr_reader :shared
11
+
12
+ def initialize(connection, qos_hash={})
13
+ @connection = connection
14
+ populate(qos_hash)
15
+ end
16
+
17
+ def populate(qos_hash=nil)
18
+ if @id and not qos_hash
19
+ response = @connection.req("GET", "/qos/policies/#{@id}")
20
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
21
+ qos_hash = JSON.parse(response.body)["policy"]
22
+ end
23
+
24
+ @id = qos_hash["id"]
25
+ @tenant_id = qos_hash["tenant_id"]
26
+ @name = qos_hash["name"]
27
+ @description = qos_hash["description"]
28
+ @shared = qos_hash["shared"]
29
+ end
30
+
31
+ def delete!
32
+ response = @connection.req('DELETE', "/qos/policies/#{@id}")
33
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
34
+ true
35
+ end
36
+
37
+ def update(options)
38
+ data = JSON.generate(:policy => options)
39
+ response = @connection.req("PUT", "/qos/policies/#{@id}", {:data => data})
40
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
41
+ populate(JSON.parse(response.body)["policy"])
42
+ end
43
+
44
+ def get_bandwidth_limit_rules
45
+ response = @connection.req("GET", "/qos/policies/#{@id}/bandwidth_limit_rules")
46
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
47
+ rules_hash = JSON.parse(response.body)["bandwidth_limit_rules"]
48
+ rules_hash.inject([]){|res, current| res << OpenStack::Network::QoSBandwidthLimitRule.new(self, current); res}
49
+ end
50
+
51
+ def get_bandwidth_limit_rule(rule_id)
52
+ response = @connection.req("GET", "/qos/policies/#{@id}/bandwidth_limit_rules/#{rule_id}")
53
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
54
+ OpenStack::Network::QoSBandwidthLimitRule.new(self, JSON.parse(response.body)["bandwidth_limit_rule"])
55
+ end
56
+
57
+ def create_bandwidth_limit_rule(options)
58
+ data = JSON.generate(:bandwidth_limit_rule => options)
59
+ response = @connection.req("POST", "/qos/policies/#{@id}/bandwidth_limit_rules", {:data => data})
60
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
61
+ OpenStack::Network::QoSBandwidthLimitRule.new(self, JSON.parse(response.body)["bandwidth_limit_rule"])
62
+ end
63
+
64
+ def add_port_id(port_id)
65
+ data = JSON.generate(:port => {:qos_policy_id => @id})
66
+ response = @connection.req("PUT", "/ports/#{port_id}", {:data => data})
67
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
68
+ true
69
+ end
70
+
71
+ def remove_port_id(port_id)
72
+ data = JSON.generate(:port => {:qos_policy_id => nil})
73
+ response = @connection.req("PUT", "/ports/#{port_id}", {:data => data})
74
+ OpenStack::Exception.raise_exception(response) unless response.code.match(/^20.$/)
75
+ true
76
+ end
77
+
78
+ end
79
+ end
80
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstack
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Prince
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2016-09-15 00:00:00.000000000 Z
15
+ date: 2016-09-30 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: mocha
@@ -104,6 +104,8 @@ files:
104
104
  - lib/openstack/network/connection.rb
105
105
  - lib/openstack/network/network.rb
106
106
  - lib/openstack/network/port.rb
107
+ - lib/openstack/network/qos_bandwidth_limit_rule.rb
108
+ - lib/openstack/network/qos_policy.rb
107
109
  - lib/openstack/network/router.rb
108
110
  - lib/openstack/network/subnet.rb
109
111
  - lib/openstack/swift/connection.rb