Created
March 10, 2016 16:46
-
-
Save magixx/d5e6f539f0d39d74af2d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NodeFactory(object): | |
@staticmethod | |
def create(node_type): | |
if node_type == 'SANode': | |
return SANode | |
else: | |
return Node | |
class Node(object): | |
def __init__(self, resource_id, **kwargs): | |
self.resource_id = resource_id | |
self.configuration = kwargs | |
# Set locals to whatever it was given | |
for key, value in self.configuration.iteritems(): | |
setattr(self, key, value) | |
self.tools = None | |
def __del__(self): | |
""" | |
Destructor. | |
""" | |
self.cleanup() | |
def setup(self): | |
print ("Running setup for resource: %s") | |
def cleanup(self): | |
print ("Running cleanup for resource: %s") | |
class SANode(Node): | |
def __init__(self, resource_id, **kwargs): | |
super(SANode, self).__init__(resource_id, **kwargs) | |
self.product_type = 'lunasa' | |
self.partitions = [] | |
def _get_serial(self): | |
return '123' | |
w = NodeFactory.create('SANode') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment