Ejemplo n.º 1
0
 def destroy(self):
     """ In order to destroy a cpu pool, it must be deactivated """
     self.pool_lock.acquire()
     try:
         if self.get_activated():
             raise PoolError(XEND_ERROR_BAD_POOL_STATE, 'activated')
         XendBase.destroy(self)
     finally:
         self.pool_lock.release()
     XendNode.instance().save_cpu_pools()
Ejemplo n.º 2
0
 def destroy(self):
     """ In order to destroy a cpu pool, it must be deactivated """
     self.pool_lock.acquire()
     try:
         if self.get_activated():
             raise PoolError(XEND_ERROR_BAD_POOL_STATE, 'activated')
         XendBase.destroy(self)
     finally:
         self.pool_lock.release()
     XendNode.instance().save_cpu_pools()
Ejemplo n.º 3
0
    def destroy(self):
        # check no VIFs or PIFs attached
        if len(self.get_VIFs()) > 0:
            raise NetworkError("Cannot destroy network with VIFs attached",
                               self.get_name_label())

        if len(self.get_PIFs()) > 0:
            raise NetworkError("Cannot destroy network with PIFs attached",
                               self.get_name_label())

        XendBase.destroy(self)
        Brctl.bridge_del(self.get_name_label())
        XendNode.instance().save_networks()
Ejemplo n.º 4
0
    def destroy(self):
        # check no VIFs or PIFs attached
        if len(self.get_VIFs()) > 0:
            raise NetworkError("Cannot destroy network with VIFs attached",
                               self.get_name_label())

        if len(self.get_PIFs()) > 0:
            raise NetworkError("Cannot destroy network with PIFs attached",
                               self.get_name_label())        
        
        XendBase.destroy(self)
        Brctl.bridge_del(self.get_name_label())
        XendNode.instance().save_networks()
Ejemplo n.º 5
0
    def destroy(self):
        # Figure out if this is a physical device
        if self.get_interface_name() == \
           self.get_device():
            raise PIFIsPhysical()

        self.unplug()

        if _destroy_VLAN(self.get_device(), self.get_VLAN()):
            XendBase.destroy(self)
            import XendNode
            XendNode.instance().save_PIFs()
        else:
            raise NetworkError("Unable to delete VLAN", self.get_uuid())
Ejemplo n.º 6
0
    def destroy(self):
        # Figure out if this is a physical device
        if self.get_interface_name() == \
           self.get_device():
            raise PIFIsPhysical()

        self.unplug()

        if _destroy_VLAN(self.get_device(), self.get_VLAN()):
            XendBase.destroy(self)
            import XendNode
            XendNode.instance().save_PIFs()
        else:
            raise NetworkError("Unable to delete VLAN", self.get_uuid())
Ejemplo n.º 7
0
    def __init__(self, record, new_uuid, managed_pool=True):
        XendBase.__init__(self, new_uuid, record)
        try:
            self._managed = managed_pool
            self.name_label = None

            name = record.get('name_label', 'Pool-Unnamed')
            self._checkName(name)
            self.name_label = name
            self.name_description = record.get('name_description',
                                               self.name_label)
            self.proposed_cpus = [ int(cpu)
                                   for cpu in record.get('proposed_CPUs', []) ]
            self.auto_power_on = bool(record.get('auto_power_on', False))
            self.ncpu = int(record.get('ncpu', 1))
            self.sched_policy = record.get('sched_policy', '')
            self.other_config = record.get('other_config', {})
        except Exception, ex:
            XendBase.destroy(self)
            raise ex
Ejemplo n.º 8
0
    def __init__(self, record, new_uuid, managed_pool=True):
        XendBase.__init__(self, new_uuid, record)
        try:
            self._managed = managed_pool
            self.name_label = None

            name = record.get('name_label', 'Pool-Unnamed')
            self._checkName(name)
            self.name_label = name
            self.name_description = record.get('name_description',
                                               self.name_label)
            self.proposed_cpus = [
                int(cpu) for cpu in record.get('proposed_CPUs', [])
            ]
            self.auto_power_on = bool(record.get('auto_power_on', False))
            self.ncpu = int(record.get('ncpu', 1))
            self.sched_policy = record.get('sched_policy', '')
            self.other_config = record.get('other_config', {})
        except Exception, ex:
            XendBase.destroy(self)
            raise ex
Ejemplo n.º 9
0
    def recreate(self, record, uuid):
        """Called on xend start / restart"""
        pif_uuid = uuid
        metrics_uuid = record['metrics']

        # Create instances
        metrics = XendPIFMetrics(metrics_uuid, pif_uuid)
        pif = XendPIF(record, pif_uuid, metrics_uuid)

        # If physical PIF, check exists
        # If VLAN, create if not exist
        ifs = [dev for dev, _1, _2 in linux_get_phy_ifaces()]
        if pif.get_VLAN() == -1:
            if pif.get_device() not in ifs:
                XendBase.destroy(pif)
                metrics.destroy()
                return None
        else:
            if pif.get_interface_name() not in ifs:
                _create_VLAN(pif.get_device(), pif.get_VLAN())
                pif.plug()

        return pif_uuid
Ejemplo n.º 10
0
    def recreate(self, record, uuid):
        """Called on xend start / restart"""        
        pif_uuid = uuid
        metrics_uuid = record['metrics']

        # Create instances
        metrics = XendPIFMetrics(metrics_uuid, pif_uuid)
        pif = XendPIF(record, pif_uuid, metrics_uuid)

        # If physical PIF, check exists
        # If VLAN, create if not exist
        ifs = [dev for dev, _1, _2 in linux_get_phy_ifaces()]
        if pif.get_VLAN() == -1:
            if pif.get_device() not in ifs:
                XendBase.destroy(pif)
                metrics.destroy()
                return None
        else:
            if pif.get_interface_name() not in ifs:
                _create_VLAN(pif.get_device(), pif.get_VLAN())
                pif.plug()

        return pif_uuid