def disk_target(self):
     device = self.parent.get('device')
     if device == 'floppy':
         data = utils_random.regex(r'(ioemu:)?fd[a-zA-Z0-9_]+')
     elif device in ['lun', 'disk']:
         data = utils_random.regex(
             r'(ioemu:)?(hd|sd|vd|xvd|ubd)[a-zA-Z0-9_]+')
     else:
         return self.go_on()
     return data
 def disk_target(self):
     device = self.parent.get('device')
     if device == 'floppy':
         data = utils_random.regex(r'(ioemu:)?fd[a-zA-Z0-9_]+')
     elif device in ['lun', 'disk']:
         data = utils_random.regex(
             r'(ioemu:)?(hd|sd|vd|xvd|ubd)[a-zA-Z0-9_]+')
     else:
         return self.go_on()
     return data
예제 #3
0
def get_data(node, xml=None):
    data_type = node.get('type')
    if data_type in ['short', 'integer', 'int', 'long', 'unsignedShort',
                     'unsignedInt', 'unsignedLong', 'positiveInteger']:
        data_max = 100
        data_min = -100
        if data_type.startswith('unsigned'):
            data_min = 0
        elif data_type == 'positiveInteger':
            data_min = 1

        xml_min = node.findall("./param[@name='minInclusive']")
        xml_max = node.findall("./param[@name='maxInclusive']")
        if xml_min:
            data_min = int(xml_min[0].text)
        if xml_max:
            data_max = int(xml_max[0].text)
        return str(random.randint(data_min, data_max))
    elif data_type == 'double':
        return str(random.expovariate(0.1))
    elif data_type == 'dateTime':
        return "2014-12-25T00:00:01"
    elif data_type == 'NCName':
        return "NCName"
    elif data_type == 'string':
        pattern = node.findall("./param[@name='pattern']")
        pattern = pattern[0].text if pattern else None

        if data_type == 'string' and pattern is None:
            # TODO: Check what happening
            return "NoneString"

        return utils_random.regex(pattern)
    else:
        logging.error("Unhandled data type %s" % data_type)