Document API
This commit is contained in:
parent
84fcd1c8e6
commit
1b113d4983
|
@ -38,7 +38,7 @@ def main():
|
|||
|
||||
service = client.get_service(name='keystone-api')
|
||||
print(service)
|
||||
service.stop()
|
||||
service.restart()
|
||||
|
||||
nodes = service.get_nodes()
|
||||
print(nodes)
|
||||
|
|
|
@ -19,18 +19,30 @@ import six
|
|||
@six.add_metaclass(abc.ABCMeta)
|
||||
class NodeCollection(object):
|
||||
|
||||
@abc.abstractmethod
|
||||
def oom(self):
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def reboot(self):
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def pick(self):
|
||||
"""Pick one Node out of collection
|
||||
|
||||
:return: NodeCollection consisting just one node
|
||||
"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def reboot(self):
|
||||
"""Reboot all nodes gracefully
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def oom(self):
|
||||
"""Fill all node's RAM
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def poweroff(self):
|
||||
pass
|
||||
"""Power off all nodes abruptly
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def reset(self):
|
||||
"""Reset (cold restart) all nodes
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
|
|
@ -21,8 +21,23 @@ class Service(object):
|
|||
|
||||
@abc.abstractmethod
|
||||
def get_nodes(self):
|
||||
"""Get nodes where this Service is running
|
||||
|
||||
:return: NodesCollection
|
||||
"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def stop(self):
|
||||
pass
|
||||
def restart(self):
|
||||
"""Restart the Service
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def terminate(self):
|
||||
"""Terminate the Service gracefully
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def kill(self):
|
||||
"""Terminate the Service abruptly
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
|
|
@ -34,6 +34,11 @@ class FuelNodeCollection(node_collection.NodeCollection):
|
|||
self.power_management = power_management
|
||||
self.hosts = hosts
|
||||
|
||||
def pick(self):
|
||||
return FuelNodeCollection(cloud_management=self.cloud_management,
|
||||
power_management=self.power_management,
|
||||
hosts=[random.choice(self.hosts)])
|
||||
|
||||
def reboot(self):
|
||||
task = {
|
||||
'command': 'ps aux'
|
||||
|
@ -44,11 +49,6 @@ class FuelNodeCollection(node_collection.NodeCollection):
|
|||
def oom(self):
|
||||
print('OOM!')
|
||||
|
||||
def pick(self):
|
||||
return FuelNodeCollection(cloud_management=self.cloud_management,
|
||||
power_management=self.power_management,
|
||||
hosts=[random.choice(self.hosts)])
|
||||
|
||||
def poweroff(self):
|
||||
self.power_management.poweroff([n['mac'] for n in self.hosts])
|
||||
|
||||
|
@ -78,7 +78,7 @@ class KeystoneService(FuelService):
|
|||
def get_nodes(self):
|
||||
return self.get_fuel_nodes(role='controller')
|
||||
|
||||
def stop(self):
|
||||
def restart(self):
|
||||
task = {
|
||||
'command': 'service apache2 restart'
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue