Add set_power_state to node api
Change-Id: Idcddc3e5de59dc72595577dae17e0b6350d07668
This commit is contained in:
parent
986fa74186
commit
707c57628a
@ -203,6 +203,22 @@ class IronicNode(base.APIResourceWrapper):
|
|||||||
node = ironicclient(request).node.update(uuid, [patch])
|
node = ironicclient(request).node.update(uuid, [patch])
|
||||||
return cls(node, request)
|
return cls(node, request)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def set_power_state(cls, request, uuid, power_state):
|
||||||
|
"""Set the power_state of node
|
||||||
|
|
||||||
|
:param request: request object
|
||||||
|
:type request: django.http.HttpRequest
|
||||||
|
|
||||||
|
:param uuid: ID of IronicNode
|
||||||
|
:type uuid: str
|
||||||
|
|
||||||
|
:param power_state: desired power_state
|
||||||
|
:type power_state: str
|
||||||
|
"""
|
||||||
|
node = ironicclient(request).node.set_power_state(uuid, power_state)
|
||||||
|
return cls(node, request)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def list_ports(cls, request, uuid):
|
def list_ports(cls, request, uuid):
|
||||||
"""Return a list of ports associated with this IronicNode
|
"""Return a list of ports associated with this IronicNode
|
||||||
@ -347,6 +363,11 @@ class BareMetalNode(base.APIResourceWrapper):
|
|||||||
raise NotImplementedError(
|
raise NotImplementedError(
|
||||||
"set_maintenance is not defined for Nova BareMetal nodes")
|
"set_maintenance is not defined for Nova BareMetal nodes")
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def set_power_state(cls, request, uuid, power_state):
|
||||||
|
raise NotImplementedError(
|
||||||
|
"set_power_state is not defined for Nova BareMetal nodes")
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def power_state(self):
|
def power_state(self):
|
||||||
"""Return a power state of this BareMetalNode
|
"""Return a power state of this BareMetalNode
|
||||||
@ -509,6 +530,12 @@ class Node(base.APIResourceWrapper):
|
|||||||
request, uuid, maintenance)
|
request, uuid, maintenance)
|
||||||
return cls(node)
|
return cls(node)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def set_power_state(cls, request, uuid, power_state):
|
||||||
|
node = NodeClient(request).node_class.set_power_state(
|
||||||
|
request, uuid, power_state)
|
||||||
|
return cls(node)
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def instance(self):
|
def instance(self):
|
||||||
"""Return the Nova Instance associated with this Node
|
"""Return the Nova Instance associated with this Node
|
||||||
|
@ -259,7 +259,9 @@ class BaseAutoDiscoverNodeFormset(BaseNodeFormset):
|
|||||||
api.node.Node.set_maintenance(request,
|
api.node.Node.set_maintenance(request,
|
||||||
node.uuid,
|
node.uuid,
|
||||||
True)
|
True)
|
||||||
#TODO(tzumainn): now we need to boot the node
|
api.node.Node.set_power_state(request,
|
||||||
|
node.uuid,
|
||||||
|
'reboot')
|
||||||
except Exception:
|
except Exception:
|
||||||
success = False
|
success = False
|
||||||
exceptions.handle(request, _('Unable to register node.'))
|
exceptions.handle(request, _('Unable to register node.'))
|
||||||
|
@ -106,6 +106,11 @@ class NodeAPITests(test.APITestCase):
|
|||||||
with self.assertRaises(NotImplementedError):
|
with self.assertRaises(NotImplementedError):
|
||||||
api.node.Node.set_maintenance(self.request, node.uuid, False)
|
api.node.Node.set_maintenance(self.request, node.uuid, False)
|
||||||
|
|
||||||
|
def test_node_set_power_state(self):
|
||||||
|
node = self.baremetalclient_nodes.first()
|
||||||
|
with self.assertRaises(NotImplementedError):
|
||||||
|
api.node.Node.set_power_state(self.request, node.uuid, 'on')
|
||||||
|
|
||||||
def test_node_instance(self):
|
def test_node_instance(self):
|
||||||
node = self.baremetalclient_nodes.first()
|
node = self.baremetalclient_nodes.first()
|
||||||
instance = self.novaclient_servers.first()
|
instance = self.novaclient_servers.first()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user