mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Openstack Ironic maintenance mode
Openstack Ironic maintenance mode, adding set/unset maintenance actions.
This commit is contained in:
parent
299dc58624
commit
cca648b475
5 changed files with 94 additions and 2 deletions
|
@ -36,6 +36,8 @@ module Fog
|
|||
request :patch_node
|
||||
request :set_node_power_state
|
||||
request :set_node_provision_state
|
||||
request :set_node_maintenance
|
||||
request :unset_node_maintenance
|
||||
|
||||
# Chassis requests
|
||||
request :create_chassis
|
||||
|
@ -65,8 +67,6 @@ module Fog
|
|||
|
||||
## Node requests
|
||||
# request :validate_node
|
||||
# request :set_maintenance
|
||||
# request :unset_maintenance
|
||||
# request :get_boot_device
|
||||
# request :set_boot_device
|
||||
# request :list_supported_boot_devices
|
||||
|
|
|
@ -75,6 +75,18 @@ module Fog
|
|||
service.list_ports_detailed({:node_uuid => self.uuid}).body['ports']
|
||||
end
|
||||
|
||||
def set_node_maintenance(parameters=nil)
|
||||
requires :uuid
|
||||
service.set_node_maintenance(uuid, parameters)
|
||||
true
|
||||
end
|
||||
|
||||
def unset_node_maintenance(parameters=nil)
|
||||
requires :uuid
|
||||
service.unset_node_maintenance(uuid, parameters)
|
||||
true
|
||||
end
|
||||
|
||||
def metadata
|
||||
requires :uuid
|
||||
service.get_node(self.uuid).headers
|
||||
|
|
36
lib/fog/openstack/requests/baremetal/set_node_maintenance.rb
Normal file
36
lib/fog/openstack/requests/baremetal/set_node_maintenance.rb
Normal file
|
@ -0,0 +1,36 @@
|
|||
module Fog
|
||||
module Baremetal
|
||||
class OpenStack
|
||||
class Real
|
||||
def set_node_maintenance(node_uuid, parameters=nil)
|
||||
if parameters
|
||||
query = parameters.each { |k, v| parameters[k] = URI::encode(v) }
|
||||
else
|
||||
query = {}
|
||||
end
|
||||
|
||||
request(
|
||||
:expects => [200, 202, 204],
|
||||
:method => 'PUT',
|
||||
:path => "nodes/#{node_uuid}/maintenance",
|
||||
:query => query
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def set_node_maintenance(node_uuid, parameters=nil)
|
||||
response = Excon::Response.new
|
||||
response.status = 202
|
||||
response.headers = {
|
||||
"X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf",
|
||||
"Content-Type" => "application/json",
|
||||
"Content-Length" => "356",
|
||||
"Date" => Date.new
|
||||
}
|
||||
response
|
||||
end
|
||||
end # mock
|
||||
end # openstack
|
||||
end # baremetal
|
||||
end # fog
|
|
@ -0,0 +1,36 @@
|
|||
module Fog
|
||||
module Baremetal
|
||||
class OpenStack
|
||||
class Real
|
||||
def unset_node_maintenance(node_uuid, parameters=nil)
|
||||
if parameters
|
||||
query = parameters.each { |k, v| parameters[k] = URI::encode(v) }
|
||||
else
|
||||
query = {}
|
||||
end
|
||||
|
||||
request(
|
||||
:expects => [200, 202, 204],
|
||||
:method => 'DELETE',
|
||||
:path => "nodes/#{node_uuid}/maintenance",
|
||||
:query => query
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
class Mock
|
||||
def unset_node_maintenance(node_uuid, parameters=nil)
|
||||
response = Excon::Response.new
|
||||
response.status = 202
|
||||
response.headers = {
|
||||
"X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf",
|
||||
"Content-Type" => "application/json",
|
||||
"Content-Length" => "356",
|
||||
"Date" => Date.new
|
||||
}
|
||||
response
|
||||
end
|
||||
end # mock
|
||||
end # openstack
|
||||
end # baremetal
|
||||
end # fog
|
|
@ -68,6 +68,14 @@ Shindo.tests('Fog::Baremetal[:openstack] | Baremetal node requests', ['openstack
|
|||
@instance['uuid'], 'manage').body
|
||||
end
|
||||
|
||||
tests('#set_node_maintenance').succeeds do
|
||||
Fog::Baremetal[:openstack].set_node_maintenance(@instance['uuid'])
|
||||
end
|
||||
|
||||
tests('#unset_node_maintenance').succeeds do
|
||||
Fog::Baremetal[:openstack].unset_node_maintenance(@instance['uuid'])
|
||||
end
|
||||
|
||||
tests('#delete_node').succeeds do
|
||||
Fog::Baremetal[:openstack].delete_node(@instance['uuid'])
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue