Ejemplo n.º 1
0
    def __init__(self, volumeData, newSize, callbackFunction=None):

        if ('poolID' not in volumeData) or \
           ('domainID' not in volumeData) or \
           ('volumeID' not in volumeData):
                self.log.error('create extend msg failed for volume: %s, size:'
                               ' %d', '-'.join(volumeData.values()), newSize)
                raise InvalidParameterException('volumeData dictionary',
                                                volumeData)
        if (newSize < 0) or (newSize > VOLUME_MAX_SIZE):
                raise InvalidParameterException('volumeSize', newSize)
        misc.validateUUID(volumeData['domainID'], 'domainID')
        misc.validateUUID(volumeData['volumeID'], 'volumeID')

        self.pool = volumeData['poolID']
        self.volumeData = volumeData
        self.newSize = str(dec2hex(newSize))
        self.callback = callbackFunction

        # Message structure is rigid (order must be kept and is relied upon):
        # Version (1 byte), OpCode (4 bytes), Domain UUID (16 bytes), Volume
        # UUID (16 bytes), Requested size (16 bytes), Padding to 64 bytes (14
        # bytes)
        domain = misc.packUuid(volumeData['domainID'])
        volume = misc.packUuid(volumeData['volumeID'])
        # Build base payload
        payload = MESSAGE_VERSION + EXTEND_CODE + domain + volume + \
            self.newSize.rjust(SIZE_CHARS, "0")
        # Pad payload with zeros
        self.payload = payload.ljust(MESSAGE_SIZE, "0")

        self.log.debug('new extend msg created: domain: %s, volume: %s',
                       volumeData['domainID'], volumeData['volumeID'])
Ejemplo n.º 2
0
    def __init__(self, volumeData, newSize, callbackFunction=None):

        if ('poolID' not in volumeData) or \
           ('domainID' not in volumeData) or \
           ('volumeID' not in volumeData):
                self.log.error('create extend msg failed for volume: %s, size:'
                               ' %d', '-'.join(volumeData.values()), newSize)
                raise InvalidParameterException('volumeData dictionary',
                                                volumeData)
        if (newSize < 0) or (newSize > VOLUME_MAX_SIZE):
                raise InvalidParameterException('volumeSize', newSize)
        misc.validateUUID(volumeData['domainID'], 'domainID')
        misc.validateUUID(volumeData['volumeID'], 'volumeID')

        self.pool = volumeData['poolID']
        self.volumeData = volumeData
        self.newSize = str(dec2hex(newSize))
        self.callback = callbackFunction

        # Message structure is rigid (order must be kept and is relied upon):
        # Version (1 byte), OpCode (4 bytes), Domain UUID (16 bytes), Volume
        # UUID (16 bytes), Requested size (16 bytes), Padding to 64 bytes (14
        # bytes)
        domain = misc.packUuid(volumeData['domainID'])
        volume = misc.packUuid(volumeData['volumeID'])
        # Build base payload
        payload = MESSAGE_VERSION + EXTEND_CODE + domain + volume + \
            self.newSize.rjust(SIZE_CHARS, "0")
        # Pad payload with zeros
        self.payload = payload.ljust(MESSAGE_SIZE, "0")

        self.log.debug('new extend msg created: domain: %s, volume: %s',
                       volumeData['domainID'], volumeData['volumeID'])
Ejemplo n.º 3
0
 def testValidInput(self):
     """
     Test if the function succeeds in validating valid UUIDs.
     """
     for i in range(1000):
         tmpUuid = str(uuid.uuid4())
         try:
             misc.validateUUID(tmpUuid)
         except misc.se.InvalidParameterException:
             self.fail("Could not parse VALID UUID '%s'" % tmpUuid)
Ejemplo n.º 4
0
 def testValidInput(self):
     """
     Test if the function succeeds in validating valid UUIDs.
     """
     for i in range(1000):
         tmpUuid = str(uuid.uuid4())
         try:
             misc.validateUUID(tmpUuid)
         except misc.se.InvalidParameterException:
             self.fail("Could not parse VALID UUID '%s'" % tmpUuid)