mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[hp|network] Add request method for update_network.
This commit is contained in:
parent
fe4760f772
commit
d102e74e2b
2 changed files with 62 additions and 1 deletions
|
@ -17,7 +17,7 @@ module Fog
|
|||
request :delete_network
|
||||
request :get_network
|
||||
request :list_networks
|
||||
#request :update_network
|
||||
request :update_network
|
||||
|
||||
module Utils
|
||||
|
||||
|
|
61
lib/fog/hp/requests/network/update_network.rb
Normal file
61
lib/fog/hp/requests/network/update_network.rb
Normal file
|
@ -0,0 +1,61 @@
|
|||
module Fog
|
||||
module HP
|
||||
class Network
|
||||
|
||||
class Real
|
||||
# Update attributes for an existing network
|
||||
#
|
||||
# ==== Parameters
|
||||
# * options<~Hash>:
|
||||
# * 'name'<~String> - Name of the network
|
||||
# * 'admin_state_up'<~Boolean> - The administrative state of the network, true or false
|
||||
# * 'shared'<~Boolean> - true or false
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * network<~Hash>:
|
||||
# * 'id'<~String>: - UUId for the network
|
||||
# * 'name'<~String>: - Name of the network
|
||||
# * 'tenant_id'<~String>: - TenantId that owns the network
|
||||
# * 'status'<~String>: - Status of the network i.e. "ACTIVE"
|
||||
# * 'subnets'<~Array>: - Subnets for the network
|
||||
# * 'id'<~Integer>: - UUId for the subnet
|
||||
# * 'admin_state_up'<~Boolean>: - true or false
|
||||
# * 'shared'<~Boolean>: - true or false
|
||||
def update_network(network_id, options = {})
|
||||
data = { 'network' => {} }
|
||||
|
||||
l_options = [:name, :admin_state_up, :shared]
|
||||
l_options.select{|o| options[o]}.each do |key|
|
||||
data['network'][key] = options[key]
|
||||
end
|
||||
|
||||
request(
|
||||
:body => Fog::JSON.encode(data),
|
||||
:expects => 200,
|
||||
:method => 'PUT',
|
||||
:path => "networks/#{network_id}"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def update_network(network_id, options = {})
|
||||
response = Excon::Response.new
|
||||
if network = list_networks.body['networks'].detect {|_| _['id'] == network_id}
|
||||
network['name'] = options[:name]
|
||||
network['shared'] = options[:shared]
|
||||
network['admin_state_up'] = options[:admin_state_up]
|
||||
response.body = { 'network' => network }
|
||||
response.status = 200
|
||||
response
|
||||
else
|
||||
raise Fog::HP::Network::NotFound
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue