Ejemplo n.º 1
0
 def __init__(self):
     from stackone.core.utils.ordereddict import OrderedDict
     self.DEFAULT_VIRTUAL_IDE_CONTOLLER_KEYS = OrderedDict({'200': [None, None], '201': [None, None]})
     self.virtual_ide_unit_number_count = 0
     self.key = 0
     self.virtual_disk_unit_number_count = 0
     self.virtual_network_unit_number_count = 0
Ejemplo n.º 2
0
class VirtualController(object):
    def __init__(self):
        from stackone.core.utils.ordereddict import OrderedDict
        self.DEFAULT_VIRTUAL_IDE_CONTOLLER_KEYS = OrderedDict({'200': [None, None], '201': [None, None]})
        self.virtual_ide_unit_number_count = 0
        self.key = 0
        self.virtual_disk_unit_number_count = 0
        self.virtual_network_unit_number_count = 0

    def get_virtual_ide_controller_key(self):
        for k,v in self.DEFAULT_VIRTUAL_IDE_CONTOLLER_KEYS.items():
            for index,item in enumerate(v):
                if not item:
                    v[index] = True
                    return (k, index)
        return (201, 2)

    def increment_virtual_disk_unit_number_count(self):
        self.virtual_disk_unit_number_count += 1

    def increment_virtual_network_unit_number_count(self):
        self.virtual_network_unit_number_count += 1

    def get_virtual_disk_unit_number_count(self):
        cnt = self.virtual_disk_unit_number_count
        self.increment_virtual_disk_unit_number_count()
        return cnt

    def get_virtual_network_unit_number_count(self):
        cnt = self.virtual_network_unit_number_count
        self.increment_virtual_network_unit_number_count()
        return cnt

    def get_key(self):
        key = self.key
        self.increment_key()
        return key

    def increment_key(self):
        self.key += 1