Ejemplo n.º 1
0
 def createDevice(self, config):
     bridge = config.get('bridge')
     if bridge is not None:
         bridge_result = commands.getstatusoutput("/sbin/ifconfig %s" % bridge)
         if bridge_result[0] != 0:
             raise VmError('Network bridge does not exist: %s' % bridge)
     DevController.createDevice(self, config)
Ejemplo n.º 2
0
 def destroyDevice(self, devid):
     try:
         DevController.destroyDevice(self, int(devid))
         time.sleep(5)
         t = xstransact()
         frontpath = self.frontendPath(int(devid))
         backpath = t.Read(frontpath, "backend")
         if backpath:
             t.Remove(backpath)
             log.debug('in try: removed %s' % backpath)
         t.Remove(frontpath)
         log.debug('in try: removed %s' % frontpath)
     except ValueError:
         devid_end = type(devid) is str and devid.split('/')[-1] or None
         for i in self.deviceIDs():
             d = self.readBackend(i, 'dev')
             if d == devid or (devid_end and d == devid_end):
                 DevController.destroyDevice(self, i)
                 time.sleep(5)
                 frontpath = self.frontendPath(int(devid))
                 backpath = t.Read(frontpath, "backend")
                 if backpath:
                     t.Remove(backpath)
                     log.debug('in err: removed %s' % backpath)
                 t.Remove(frontpath)
                 log.debug('in err: removed %s' % frontpath)
                 return
         raise VmError("Device %s not connected" % devid)
Ejemplo n.º 3
0
 def destroyDevice(self, devid):
     try:
         DevController.destroyDevice(self, int(devid))
         time.sleep(5)
         t = xstransact()
         frontpath = self.frontendPath(int(devid))
         backpath = t.Read(frontpath, "backend")
         if backpath:
             t.Remove(backpath)
             log.debug("in try: removed %s" % backpath)
         t.Remove(frontpath)
         log.debug("in try: removed %s" % frontpath)
     except ValueError:
         devid_end = type(devid) is str and devid.split("/")[-1] or None
         for i in self.deviceIDs():
             d = self.readBackend(i, "dev")
             if d == devid or (devid_end and d == devid_end):
                 DevController.destroyDevice(self, i)
                 time.sleep(5)
                 frontpath = self.frontendPath(int(devid))
                 backpath = t.Read(frontpath, "backend")
                 if backpath:
                     t.Remove(backpath)
                     log.debug("in err: removed %s" % backpath)
                 t.Remove(frontpath)
                 log.debug("in err: removed %s" % frontpath)
                 return
         raise VmError("Device %s not connected" % devid)
Ejemplo n.º 4
0
 def createDevice(self, config):
     bridge = config.get('bridge')
     if bridge is not None:
         bridge_result = commands.getstatusoutput("/sbin/ifconfig %s" %
                                                  bridge)
         if bridge_result[0] != 0:
             raise VmError('Network bridge does not exist: %s' % bridge)
     DevController.createDevice(self, config)
Ejemplo n.º 5
0
    def destroyDevice(self, devid):
        try:
            DevController.destroyDevice(self, int(devid))
        except ValueError:
            devid_end = type(devid) is str and devid.split('/')[-1] or None

            for i in self.deviceIDs():
                d = self.readBackend(i, 'dev')
                if d == devid or (devid_end and d == devid_end):
                    DevController.destroyDevice(self, i)
                    return
            raise VmError("Device %s not connected" % devid)
Ejemplo n.º 6
0
    def destroyDevice(self, devid):
        try:
            DevController.destroyDevice(self, int(devid))
        except ValueError:
            devid_end = type(devid) is str and devid.split('/')[-1] or None

            for i in self.deviceIDs():
                d = self.readBackend(i, 'dev')
                if d == devid or (devid_end and d == devid_end):
                    DevController.destroyDevice(self, i)
                    return
            raise VmError("Device %s not connected" % devid)
Ejemplo n.º 7
0
    def getDeviceConfiguration(self, devid, transaction = None):
        config = DevController.getDeviceConfiguration(self, devid, transaction)

        vscsi_devs = []

        devs = self.readBackendList(devid, "vscsi-devs")
        vscsipath = "vscsi-devs/"
        for dev in devs:
            devpath = vscsipath + dev
            pdev = self.readBackend(devid, devpath + '/p-dev')
            pdevname = self.readBackend(devid, devpath + '/p-devname')
            vdev = self.readBackend(devid, devpath + '/v-dev')
            state = self.readBackend(devid, devpath + '/state')
            localdevid = self.readBackend(devid, devpath + '/devid')
            dev_dict = {'p-dev': pdev,
                        'p-devname': pdevname,
                        'v-dev': vdev,
                        'state': state,
                        'devid': localdevid }
            vscsi_devs.append(dev_dict)

        config['devs'] = vscsi_devs
        config['feature-host'] = self.readBackend(devid, 'feature-host')
        config['uuid'] = self.readBackend(devid, 'uuid')
        return config
Ejemplo n.º 8
0
    def configuration(self, devid):
        """@see DevController.configuration"""

        result = DevController.configuration(self, devid)

        (script, ip, bridge, mac, typ, vifname,
         rate) = self.readBackend(devid, 'script', 'ip', 'bridge', 'mac',
                                  'type', 'vifname', 'rate')

        if script:
            result.append([
                'script',
                script.replace(xroot.network_script_dir + os.sep, "")
            ])
        if ip:
            for i in ip.split(" "):
                result.append(['ip', i])
        if bridge:
            result.append(['bridge', bridge])
        if mac:
            result.append(['mac', mac])
        if typ:
            result.append(['type', typ])
        if vifname:
            result.append(['vifname', vifname])
        if rate:
            result.append(['rate', formatRate(rate)])

        return result
Ejemplo n.º 9
0
    def getDeviceConfiguration(self, devid, transaction=None):
        result = DevController.getDeviceConfiguration(self, devid, transaction)
        num_devs = self.readBackend(devid, 'num_devs')
        pci_devs = []

        for i in range(int(num_devs)):
            dev_config = self.readBackend(devid, 'dev-%d' % i)

            pci_match = re.match(
                r"((?P<domain>[0-9a-fA-F]{1,4})[:,])?" +
                r"(?P<bus>[0-9a-fA-F]{1,2})[:,]" +
                r"(?P<slot>[0-9a-fA-F]{1,2})[.,]" +
                r"(?P<func>[0-9a-fA-F]{1,2})", dev_config)

            if pci_match != None:
                pci_dev_info = pci_match.groupdict()
                pci_devs.append({
                    'domain': '0x%(domain)s' % pci_dev_info,
                    'bus': '0x%(bus)s' % pci_dev_info,
                    'slot': '0x%(slot)s' % pci_dev_info,
                    'func': '0x%(func)s' % pci_dev_info
                })

        result['devs'] = pci_devs
        result['uuid'] = self.readBackend(devid, 'uuid')
        return result
Ejemplo n.º 10
0
    def configuration(self, devid):
        """@see DevController.configuration"""

        result = DevController.configuration(self, devid)

        (script, ip, bridge, mac, typ, vifname, rate) = self.readBackend(
            devid, 'script', 'ip', 'bridge', 'mac', 'type', 'vifname', 'rate')

        if script:
            result.append(['script',
                           script.replace(xroot.network_script_dir + os.sep,
                                          "")])
        if ip:
            for i in ip.split(" "):
                result.append(['ip', i])
        if bridge:
            result.append(['bridge', bridge])
        if mac:
            result.append(['mac', mac])
        if typ:
            result.append(['type', typ])
        if vifname:
            result.append(['vifname', vifname])
        if rate:
            result.append(['rate', formatRate(rate)])

        return result
Ejemplo n.º 11
0
    def getDeviceConfiguration(self, devid, transaction = None):
        result = DevController.getDeviceConfiguration(self, devid, transaction)

        if transaction is None:
            devinfo = self.readBackend(devid, *CONFIG_ENTRIES)
        else:
            devinfo = self.readBackendTxn(transaction, devid, *CONFIG_ENTRIES)
        return dict([(CONFIG_ENTRIES[i], devinfo[i])
                     for i in range(len(CONFIG_ENTRIES))
                     if devinfo[i] is not None])
Ejemplo n.º 12
0
    def getDeviceConfiguration(self, devid, transaction=None):
        result = DevController.getDeviceConfiguration(self, devid, transaction)

        if transaction is None:
            devinfo = self.readBackend(devid, *CONFIG_ENTRIES)
        else:
            devinfo = self.readBackendTxn(transaction, devid, *CONFIG_ENTRIES)
        return dict([(CONFIG_ENTRIES[i], devinfo[i])
                     for i in range(len(CONFIG_ENTRIES))
                     if devinfo[i] is not None])
Ejemplo n.º 13
0
    def destroyDevice(self, devid):
        """@see DevController.destroyDevice"""

        # If we are given a device name, then look up the device ID from it,
        # and destroy that ID instead.  If what we are given is an integer,
        # then assume it's a device ID and pass it straight through to our
        # superclass's method.

        try:
            DevController.destroyDevice(self, int(devid))
        except ValueError:
            devid_end = type(devid) is str and devid.split('/')[-1] or None

            for i in self.deviceIDs():
                d = self.readBackend(i, 'dev')
                if d == devid or (devid_end and d == devid_end):
                    DevController.destroyDevice(self, i)
                    return
            raise VmError("Device %s not connected" % devid)
Ejemplo n.º 14
0
    def configuration(self, devid):

        result = DevController.configuration(self, devid)

        instance = self.readBackend(devid, 'instance')

        if instance:
            result.append(['instance', instance])

        return result
Ejemplo n.º 15
0
    def configuration(self, devid):

        result = DevController.configuration(self, devid)

        instance = self.readBackend(devid, 'instance')

        if instance:
            result.append(['instance', instance])

        return result
Ejemplo n.º 16
0
 def getDeviceConfiguration(self, devid, transaction = None):
     result = DevController.getDeviceConfiguration(self, devid, transaction)
     if transaction is None:
         devinfo = self.readBackend(devid, *self.valid_cfg)
     else:
         devinfo = self.readBackendTxn(transaction, devid, *self.valid_cfg)
     config = dict(zip(self.valid_cfg, devinfo))
     config = dict([(key, val) for key, val in config.items()
                    if val != None])
     return config
Ejemplo n.º 17
0
 def getDeviceConfiguration(self, devid, transaction=None):
     result = DevController.getDeviceConfiguration(self, devid, transaction)
     if transaction is None:
         devinfo = self.readBackend(devid, *self.valid_cfg)
     else:
         devinfo = self.readBackendTxn(transaction, devid, *self.valid_cfg)
     config = dict(zip(self.valid_cfg, devinfo))
     config = dict([(key, val) for key, val in config.items()
                    if val != None])
     return config
Ejemplo n.º 18
0
    def destroyDevice(self, devid, force):
        """@see DevController.destroyDevice"""

        # vbd device IDs can be either string or integer.  Further, the
        # following string values are possible:
        #    - devicetype/deviceid (vbd/51728)
        #    - devicetype/devicename (/dev/xvdb)
        #    - devicename (xvdb)
        # Let our superclass handle integer or devicetype/deviceid forms.
        # If we are given a device name form, then look up the device ID
        # from it, and destroy that ID instead.
        try:
            DevController.destroyDevice(self, devid, force)
        except ValueError:
            dev = self.convertToDeviceNumber(devid)

            for i in self.deviceIDs():
                if i == dev:
                    DevController.destroyDevice(self, i, force)
                    return
            raise VmError("Device %s not connected" % devid)
Ejemplo n.º 19
0
    def destroyDevice(self, devid, force):
        """@see DevController.destroyDevice"""

        # vbd device IDs can be either string or integer.  Further, the
        # following string values are possible:
        #    - devicetype/deviceid (vbd/51728)
        #    - devicetype/devicename (/dev/xvdb)
        #    - devicename (xvdb)
        # Let our superclass handle integer or devicetype/deviceid forms.
        # If we are given a device name form, then look up the device ID
        # from it, and destroy that ID instead.
        try:
            DevController.destroyDevice(self, devid, force)
        except ValueError:
            dev = self.convertToDeviceNumber(devid)

            for i in self.deviceIDs():
                if i == dev:
                    DevController.destroyDevice(self, i, force)
                    return
            raise VmError("Device %s not connected" % devid)
Ejemplo n.º 20
0
    def getDeviceConfiguration(self, devid, transaction=None):
        """@see DevController.configuration"""

        result = DevController.getDeviceConfiguration(self, devid, transaction)

        for x in ('script', 'ip', 'bridge', 'mac', 'type', 'vifname', 'rate',
                  'uuid', 'model', 'accel', 'security_label'):
            if transaction is None:
                y = self.readBackend(devid, x)
            else:
                y = self.readBackendTxn(transaction, devid, x)
            if y:
                result[x] = y

        return result
Ejemplo n.º 21
0
    def getDeviceConfiguration(self, devid, transaction = None):
        """@see DevController.configuration"""

        result = DevController.getDeviceConfiguration(self, devid, transaction)

        for x in ( 'script', 'ip', 'bridge', 'mac',
                   'type', 'vifname', 'rate', 'uuid', 'model', 'accel',
                   'security_label'):
            if transaction is None:
                y = self.readBackend(devid, x)
            else:
                y = self.readBackendTxn(transaction, devid, x)
            if y:
                result[x] = y

        return result
Ejemplo n.º 22
0
    def getDeviceConfiguration(self, devid, transaction=None):
        """@see DevController.configuration"""

        if transaction is None:
            read_fn = xstransact.Read
        else:
            read_fn = transaction.read

        def front_read(x):
            return read_fn(frontpath + x)

        def back_read(x):
            return read_fn(backpath + x)

        result = DevController.getDeviceConfiguration(self, devid, transaction)

        dev = self.convertToDeviceNumber(devid)
        frontpath = self.frontendPath(dev) + "/"

        backpath = front_read("backend") + "/"

        front_mac = front_read("mac")
        back_mac = back_read("mac")

        front_trusted = back_read("remote-trusted")
        back_trusted = back_read("local-trusted")
        max_bypasses = back_read("max-bypasses")

        bridge = back_read("bridge")

        pdev = back_read("pdev")

        if front_mac:
            result["front_mac"] = front_mac
        if back_mac:
            result["back_mac"] = back_mac
        if front_trusted:
            result["front_trusted"] = front_trusted
        if back_trusted:
            result["back_trusted"] = back_trusted
        if bridge:
            result["bridge"] = bridge
        if pdev:
            result["pdev"] = pdev
        if max_bypasses:
            result["max-bypasses"] = max_bypasses
        return result
Ejemplo n.º 23
0
    def configuration(self, devid):
        """@see DevController.configuration"""

        result = DevController.configuration(self, devid)

        (dev, typ, params, mode) = self.readBackend(devid,
                                                    'dev', 'type', 'params',
                                                    'mode')

        if dev:
            result.append(['dev', dev])
        if typ and params:
            result.append(['uname', typ + ":" + params])
        if mode:
            result.append(['mode', mode])

        return result
Ejemplo n.º 24
0
    def getDeviceConfiguration(self, devid, transaction = None):
        """@see DevController.configuration"""

        if transaction is None:
            read_fn = xstransact.Read
        else:
            read_fn = transaction.read
        def front_read(x):
            return read_fn(frontpath + x)
        def back_read(x):
            return read_fn(backpath + x)
        
        result = DevController.getDeviceConfiguration(self, devid, transaction)

        dev = self.convertToDeviceNumber(devid)
        frontpath = self.frontendPath(dev) + "/"

        backpath = front_read("backend") + "/"

        front_mac = front_read("mac")
        back_mac = back_read("mac")

        front_trusted = back_read("remote-trusted")
        back_trusted = back_read("local-trusted")
        max_bypasses = back_read("max-bypasses")

        bridge = back_read("bridge")

        pdev = back_read("pdev")

        if front_mac:
            result["front_mac"] = front_mac
        if back_mac:
            result["back_mac"] = back_mac
        if front_trusted:
            result["front_trusted"] = front_trusted
        if back_trusted:
            result["back_trusted"] = back_trusted
        if bridge:
            result["bridge"] = bridge
        if pdev:
            result["pdev"] = pdev
        if max_bypasses:
            result["max-bypasses"] = max_bypasses
        return result
Ejemplo n.º 25
0
 def getDeviceConfiguration(self, devid, transaction = None):
     """@see DevController.configuration"""
     config = DevController.getDeviceConfiguration(self, devid, transaction)
     if transaction is None:
         hcinfo = self.readBackend(devid, 'usb-ver', 'num-ports')
     else:
         hcinfo = self.readBackendTxn(transaction, devid,
                                       'usb-ver', 'num-ports')
     (usbver, numports) = hcinfo
     config['usb-ver'] = str(usbver)
     config['num-ports'] = str(numports)
     for i in range(1, int(numports) + 1):
         if transaction is None:
             config['port-%i' % i] = self.readBackend(devid, 'port/%i' % i)
         else:
             config['port-%i' % i] = self.readBackendTxn(transaction, devid,
                                                          'port/%i' % i)
     return config
Ejemplo n.º 26
0
 def getDeviceConfiguration(self, devid, transaction=None):
     """@see DevController.configuration"""
     config = DevController.getDeviceConfiguration(self, devid, transaction)
     if transaction is None:
         hcinfo = self.readBackend(devid, 'usb-ver', 'num-ports')
     else:
         hcinfo = self.readBackendTxn(transaction, devid, 'usb-ver',
                                      'num-ports')
     (usbver, numports) = hcinfo
     config['usb-ver'] = str(usbver)
     config['num-ports'] = str(numports)
     for i in range(1, int(numports) + 1):
         if transaction is None:
             config['port-%i' % i] = self.readBackend(devid, 'port/%i' % i)
         else:
             config['port-%i' % i] = self.readBackendTxn(
                 transaction, devid, 'port/%i' % i)
     return config
Ejemplo n.º 27
0
    def getDeviceConfiguration(self, devid, transaction=None):
        result = DevController.getDeviceConfiguration(self, devid, transaction)
        num_devs = self.readBackend(devid, 'num_devs')
        pci_devs = []

        vslots = self.readBackend(devid, 'vslots')
        if vslots is not None:
            if vslots[-1] == ";":
                vslots = vslots[:-1]
            slot_list = vslots.split(';')

        for i in range(int(num_devs)):
            dev_config = self.readBackend(devid, 'dev-%d' % i)

            pci_match = re.match(
                r"((?P<domain>[0-9a-fA-F]{1,4})[:,])?" +
                r"(?P<bus>[0-9a-fA-F]{1,2})[:,]" +
                r"(?P<slot>[0-9a-fA-F]{1,2})[.,]" + r"(?P<func>[0-7]{1,2})$",
                dev_config)

            if pci_match != None:
                pci_dev_info = pci_match.groupdict()
                dev_dict = {
                    'domain': '0x%(domain)s' % pci_dev_info,
                    'bus': '0x%(bus)s' % pci_dev_info,
                    'slot': '0x%(slot)s' % pci_dev_info,
                    'func': '0x%(func)s' % pci_dev_info
                }

                # Per device uuid info
                dev_dict['uuid'] = self.readBackend(devid, 'uuid-%d' % i)

                #append vslot info
                if vslots is not None:
                    try:
                        dev_dict['vslt'] = slot_list[i]
                    except IndexError:
                        dev_dict['vslt'] = '0x0'

                pci_devs.append(dev_dict)

        result['devs'] = pci_devs
        result['uuid'] = self.readBackend(devid, 'uuid')
        return result
Ejemplo n.º 28
0
    def getDeviceConfiguration(self, devid, transaction = None):
        """@see DevController.configuration"""

        result = DevController.getDeviceConfiguration(self, devid, transaction)

        config_path = "device/%s/%d/" % (self.deviceClass, devid)
        devinfo = ()
        for x in ( 'script', 'ip', 'bridge', 'mac',
                   'type', 'vifname', 'rate', 'uuid', 'model', 'accel',
                   'security_label'):
            if transaction is None:
                y = self.vm._readVm(config_path + x)
            else:
                y = self.vm._readVmTxn(transaction, config_path + x)
            devinfo += (y,)
        (script, ip, bridge, mac, typ, vifname, rate, uuid,
         model, accel, security_label) = devinfo

        if script:
            result['script'] = script
        if ip:
            result['ip'] = ip
        if bridge:
            result['bridge'] = bridge
        if mac:
            result['mac'] = mac
        if typ:
            result['type'] = typ
        if vifname:
            result['vifname'] = vifname
        if rate:
            result['rate'] = rate
        if uuid:
            result['uuid'] = uuid
        if model:
            result['model'] = model
        if accel:
            result['accel'] = accel
        if security_label:
            result['security_label'] = security_label

        return result
Ejemplo n.º 29
0
    def getDeviceConfiguration(self, devid, transaction = None):
        result = DevController.getDeviceConfiguration(self, devid, transaction)
        num_devs = self.readBackend(devid, 'num_devs')
        pci_devs = []
        
        vslots = self.readBackend(devid, 'vslots')
        if vslots is not None:
            if vslots[-1] == ";":
                vslots = vslots[:-1]
            slot_list = vslots.split(';')

        for i in range(int(num_devs)):
            dev_config = self.readBackend(devid, 'dev-%d' % i)

            pci_match = re.match(r"((?P<domain>[0-9a-fA-F]{1,4})[:,])?" +
                                 r"(?P<bus>[0-9a-fA-F]{1,2})[:,]" + 
                                 r"(?P<slot>[0-9a-fA-F]{1,2})[.,]" + 
                                 r"(?P<func>[0-7]{1,2})$", dev_config)
            
            if pci_match!=None:
                pci_dev_info = pci_match.groupdict()
                dev_dict = {'domain': '0x%(domain)s' % pci_dev_info,
                                 'bus': '0x%(bus)s' % pci_dev_info,
                                 'slot': '0x%(slot)s' % pci_dev_info,
                                 'func': '0x%(func)s' % pci_dev_info}

                # Per device uuid info
                dev_dict['uuid'] = self.readBackend(devid, 'uuid-%d' % i)

                #append vslot info
                if vslots is not None:
                    try:
                        dev_dict['vslt'] = slot_list[i]
                    except IndexError:
                        dev_dict['vslt'] = '0x0'

                pci_devs.append(dev_dict)

        result['devs'] = pci_devs
        result['uuid'] = self.readBackend(devid, 'uuid')
        return result
Ejemplo n.º 30
0
    def getDeviceConfiguration(self, devid, transaction=None):
        """@see DevController.configuration"""

        result = DevController.getDeviceConfiguration(self, devid, transaction)

        config_path = "device/%s/%d/" % (self.deviceClass, devid)
        devinfo = ()
        for x in ('script', 'ip', 'bridge', 'mac', 'type', 'vifname', 'rate',
                  'uuid', 'model', 'accel', 'security_label'):
            if transaction is None:
                y = self.vm._readVm(config_path + x)
            else:
                y = self.vm._readVmTxn(transaction, config_path + x)
            devinfo += (y, )
        (script, ip, bridge, mac, typ, vifname, rate, uuid, model, accel,
         security_label) = devinfo

        if script:
            result['script'] = script
        if ip:
            result['ip'] = ip
        if bridge:
            result['bridge'] = bridge
        if mac:
            result['mac'] = mac
        if typ:
            result['type'] = typ
        if vifname:
            result['vifname'] = vifname
        if rate:
            result['rate'] = rate
        if uuid:
            result['uuid'] = uuid
        if model:
            result['model'] = model
        if accel:
            result['accel'] = accel
        if security_label:
            result['security_label'] = security_label

        return result
Ejemplo n.º 31
0
    def getDeviceConfiguration(self, devid, transaction=None):
        """Returns the configuration of a device"""
        result = DevController.getDeviceConfiguration(self, devid, transaction)

        (instance, uuid, type) = self.readBackend(devid, "instance", "uuid", "type")

        if instance:
            result["instance"] = instance
        if uuid:
            result["uuid"] = uuid
        if type:
            result["type"] = type

        if uuid:
            data = self.vm.info["devices"].get(uuid)
            if data:
                other = data[1].get("other_config")
                if other:
                    result["other_config"] = other

        return result
Ejemplo n.º 32
0
    def getDeviceConfiguration(self, devid, transaction=None):
        config = DevController.getDeviceConfiguration(self, devid, transaction)

        vscsi_devs = []

        devs = self.readBackendList(devid, "vscsi-devs")
        vscsipath = "vscsi-devs/"
        for dev in devs:
            devpath = vscsipath + dev
            pdev = self.readBackend(devid, devpath + "/p-dev")
            pdevname = self.readBackend(devid, devpath + "/p-devname")
            vdev = self.readBackend(devid, devpath + "/v-dev")
            state = self.readBackend(devid, devpath + "/state")
            localdevid = self.readBackend(devid, devpath + "/devid")
            dev_dict = {"p-dev": pdev, "p-devname": pdevname, "v-dev": vdev, "state": state, "devid": localdevid}
            vscsi_devs.append(dev_dict)

        config["devs"] = vscsi_devs
        config["feature-host"] = self.readBackend(devid, "feature-host")
        config["uuid"] = self.readBackend(devid, "uuid")
        return config
Ejemplo n.º 33
0
    def getDeviceConfiguration(self, devid, transaction = None):
        """Returns the configuration of a device.

        @note: Similar to L{configuration} except it returns a dict.
        @return: dict
        """
        config = DevController.getDeviceConfiguration(self, devid, transaction)
        if transaction is None:
            devinfo = self.readBackend(devid, 'dev', 'type', 'params', 'mode',
                                       'uuid', 'bootable')
        else:
            devinfo = self.readBackendTxn(transaction, devid,
                                          'dev', 'type', 'params', 'mode', 'uuid',
                                          'bootable')
        dev, typ, params, mode, uuid, bootable = devinfo
        
        if dev:
            if transaction is None:
                dev_type = self.readFrontend(devid, 'device-type')
            else:
                dev_type = self.readFrontendTxn(transaction, devid, 'device-type')
            if dev_type:
                dev += ':' + dev_type
            config['dev'] = dev
        if typ and params:
            config['uname'] = typ +':' + params
        else:
            config['uname'] = None
        if mode:
            config['mode'] = mode
        if uuid:
            config['uuid'] = uuid
        if bootable != None:
            config['bootable'] = int(bootable)

        proto = self.readFrontend(devid, 'protocol')
        if proto:
            config['protocol'] = proto

        return config
Ejemplo n.º 34
0
    def getDeviceConfiguration(self, devid, transaction=None):
        """Returns the configuration of a device.

        @note: Similar to L{configuration} except it returns a dict.
        @return: dict
        """
        config = DevController.getDeviceConfiguration(self, devid, transaction)
        if transaction is None:
            devinfo = self.readBackend(devid, 'dev', 'type', 'params', 'mode',
                                       'uuid', 'bootable')
        else:
            devinfo = self.readBackendTxn(transaction, devid, 'dev', 'type',
                                          'params', 'mode', 'uuid', 'bootable')
        dev, typ, params, mode, uuid, bootable = devinfo

        if dev:
            if transaction is None:
                dev_type = self.readFrontend(devid, 'device-type')
            else:
                dev_type = self.readFrontendTxn(transaction, devid,
                                                'device-type')
            if dev_type:
                dev += ':' + dev_type
            config['dev'] = dev
        if typ and params:
            config['uname'] = typ + ':' + params
        else:
            config['uname'] = None
        if mode:
            config['mode'] = mode
        if uuid:
            config['uuid'] = uuid
        if bootable != None:
            config['bootable'] = int(bootable)

        proto = self.readFrontend(devid, 'protocol')
        if proto:
            config['protocol'] = proto

        return config
Ejemplo n.º 35
0
    def getDeviceConfiguration(self, devid, transaction = None):
        result = DevController.getDeviceConfiguration(self, devid, transaction)
        num_devs = self.readBackend(devid, 'num_devs')
        pci_devs = []
        
        for i in range(int(num_devs)):
            dev_config = self.readBackend(devid, 'dev-%d' % i)

            pci_match = re.match(r"((?P<domain>[0-9a-fA-F]{1,4})[:,])?" +
                                 r"(?P<bus>[0-9a-fA-F]{1,2})[:,]" + 
                                 r"(?P<slot>[0-9a-fA-F]{1,2})[.,]" + 
                                 r"(?P<func>[0-9a-fA-F]{1,2})", dev_config)
            
            if pci_match!=None:
                pci_dev_info = pci_match.groupdict()
                pci_devs.append({'domain': '0x%(domain)s' % pci_dev_info,
                                 'bus': '0x%(bus)s' % pci_dev_info,
                                 'slot': '0x%(slot)s' % pci_dev_info,
                                 'func': '0x%(func)s' % pci_dev_info})

        result['devs'] = pci_devs
        result['uuid'] = self.readBackend(devid, 'uuid')
        return result
Ejemplo n.º 36
0
    def getDeviceConfiguration(self, devid, transaction=None):
        result = DevController.getDeviceConfiguration(self, devid, transaction)
        num_devs = self.readBackend(devid, 'num_devs')
        pci_devs = []

        for i in range(int(num_devs)):
            pci_dev = parse_pci_name(self.readBackend(devid, 'dev-%d' % i))

            # Per device uuid info
            pci_dev['uuid'] = self.readBackend(devid, 'uuid-%d' % i)
            pci_dev['key'] = self.readBackend(devid, 'key-%d' % i)
            pci_dev['vdevfn'] = '0x%s' % self.readBackend(
                devid, 'vdevfn-%d' % i)

            #append opts info
            opts = self.readBackend(devid, 'opts-%d' % i)
            if opts is not None:
                pci_dev['opts'] = opts

            pci_devs.append(pci_dev)

        result['devs'] = pci_devs
        result['uuid'] = self.readBackend(devid, 'uuid')
        return result
Ejemplo n.º 37
0
    def getDeviceConfiguration(self, devid, transaction = None):
        config = DevController.getDeviceConfiguration(self, devid, transaction)

        vscsi_devs = []

        devs = self.readBackendList(devid, "vscsi-devs")
        vscsipath = "vscsi-devs/"
        for dev in devs:
            devpath = vscsipath + dev
            pdev = self.readBackend(devid, devpath + '/p-dev')
            pdevname = self.readBackend(devid, devpath + '/p-devname')
            vdev = self.readBackend(devid, devpath + '/v-dev')
            state = self.readBackend(devid, devpath + '/state')
            localdevid = self.readBackend(devid, devpath + '/devid')
            dev_dict = {'p-dev': pdev,
                            'p-devname': pdevname,
                            'v-dev': pdevname,
                            'state': state,
                            'devid': localdevid }
            vscsi_devs.append(dev_dict)

        config['devs'] = vscsi_devs
        config['uuid'] = self.readBackend(devid, 'uuid')
        return config
Ejemplo n.º 38
0
    def getDeviceConfiguration(self, devid, transaction = None):
        result = DevController.getDeviceConfiguration(self, devid, transaction)
        num_devs = self.readBackend(devid, 'num_devs')
        pci_devs = []

        for i in range(int(num_devs)):
            pci_dev = parse_pci_name(self.readBackend(devid, 'dev-%d' % i))

            # Per device uuid info
            pci_dev['uuid'] = self.readBackend(devid, 'uuid-%d' % i)
            pci_dev['key'] = self.readBackend(devid, 'key-%d' % i)
            pci_dev['vdevfn'] = '0x%s' % self.readBackend(devid,
                                                          'vdevfn-%d' % i)

            #append opts info
            opts = self.readBackend(devid, 'opts-%d' % i)
            if opts is not None:
                pci_dev['opts'] = opts

            pci_devs.append(pci_dev)

        result['devs'] = pci_devs
        result['uuid'] = self.readBackend(devid, 'uuid')
        return result
Ejemplo n.º 39
0
    def getDeviceConfiguration(self, devid, transaction = None):
        """Returns the configuration of a device"""
        result = DevController.getDeviceConfiguration(self, devid, transaction)

        (instance, uuid, type) = \
                           self.readBackend(devid, 'instance',
                                                   'uuid',
                                                   'type')

        if instance:
            result['instance'] = instance
        if uuid:
            result['uuid'] = uuid
        if type:
            result['type'] = type

        if uuid:
            data = self.vm.info['devices'].get(uuid)
            if data:
                other = data[1].get('other_config')
                if other:
                    result['other_config'] = other

        return result
Ejemplo n.º 40
0
 def __init__(self, vm):
     """Create a VSCSI Devices.
     """
     DevController.__init__(self, vm)
Ejemplo n.º 41
0
 def __init__(self, vm):
     """Create a VSCSI Devices.
     """
     DevController.__init__(self, vm)
Ejemplo n.º 42
0
 def __init__(self, vm):
     DevController.__init__(self, vm)
Ejemplo n.º 43
0
 def __init__(self, vm):
     """Create a keypad device controller.
     """
     DevController.__init__(self, vm)
Ejemplo n.º 44
0
 def __init__(self, vm):
     DevController.__init__(self, vm)
     self.hotplug = False
Ejemplo n.º 45
0
 def destroyDevice(self, devid, force):
     DevController.destroyDevice(self, devid, True)
Ejemplo n.º 46
0
    def configuration(self, devid):
        """@see DevController.configuration"""

        result = DevController.configuration(self, devid)
        result.append(['ssa', '0'])
        return result
Ejemplo n.º 47
0
 def destroyDevice(self, devid, force):
     DevController.destroyDevice(self, devid, True)
     log.debug('pci: unregister aer watch')
     self.unwatchAerState()
Ejemplo n.º 48
0
 def destroyDevice(self, devid, force):
     # remove the backend xenstore entries no matter what
     # because we kill qemu-dm with extreme prejudice
     # not giving it a chance to remove them itself
     DevController.destroyDevice(self, devid, True)
Ejemplo n.º 49
0
 def __init__(self, vm):
     DevController.__init__(self, vm)
Ejemplo n.º 50
0
 def destroyDevice(self, devid, force):
     DevController.destroyDevice(self, devid, True)
     log.debug('pci: unregister aer watch')
     self.unwatchAerState()
Ejemplo n.º 51
0
 def destroyDevice(self, devid, force):
     # remove the backend xenstore entries no matter what
     # because we kill qemu-dm with extreme prejudice
     # not giving it a chance to remove them itself
     DevController.destroyDevice(self, devid, True)
Ejemplo n.º 52
0
 def __init__(self, vm):
     self.aerStateWatch = None
     DevController.__init__(self, vm)
Ejemplo n.º 53
0
 def __init__(self, vm):
     """Create a keypad device controller.
     """
     DevController.__init__(self, vm)
Ejemplo n.º 54
0
 def __init__(self, vm):
     self.aerStateWatch = None
     DevController.__init__(self, vm)
Ejemplo n.º 55
0
 def __init__(self, vm):
     """Create a block device controller.
     """
     DevController.__init__(self, vm)
 def __init__(self, vm):
     DevController.__init__(self, vm)
     self.hotplug = False
 def destroyDevice(self, devid, force):
     DevController.destroyDevice(self, devid, True)