def proxy_device(self):
        """
        Return this component's corresponding proxy device, creating
        it in the proxy_deviceclass if it does not exist.

        Default assumes that the names must match.
        """

        device = GUIDManager(self.dmd).getObject(getattr(self, "openstackProxyDeviceUUID", None))
        if device:
            guid = IGlobalIdentifier(self).getGUID()

            # this shouldn't happen, but if we've somehow become half-connected
            # (we know about the device, it doesn't know about us), reconnect.
            if getattr(device, "openstackProxyComponentUUID", None) != guid:
                LOG.info(
                    "%s component '%s' linkage to device '%s' is broken.  Re-claiming it."
                    % (self.meta_type, self.name(), device.name())
                )
                self.claim_proxy_device(device)

            return device

        # Does a device with a matching name exist?  Claim that one.
        device = self.dmd.Devices.findDevice(self.name())
        if device:
            self_pdc_path = self.proxy_deviceclass().getPrimaryPath()
            device_path = device.getPrimaryPath()[: len(self_pdc_path)]
            if device_path == self_pdc_path and device.id != self.device().id:
                self.claim_proxy_device(device)
                return device
            else:
                return self.create_proxy_device()
        else:
            return self.create_proxy_device()
    def release_proxy_device(self):
        device = GUIDManager(self.dmd).getObject(getattr(self, 'openstackProxyDeviceUUID', None))
        if device:
            LOG.debug("device %s is now detached from %s component '%s'" % (device.name(), self.meta_type, self.name()))
            device.openstackProxyComponentUUID = None

        self.openstackProxyDeviceUUID = None
        LOG.debug("%s component '%s' is now detached from any devices" % (self.meta_type, self.name()))
Exemple #3
0
    def release_proxy_device(self):
        device = GUIDManager(self.dmd).getObject(
            getattr(self, 'openstackProxyDeviceUUID', None))
        if device:
            LOG.debug("device %s is now detached from %s component '%s'" %
                      (device.name(), self.meta_type, self.name()))
            device.openstackProxyComponentUUID = None

        self.openstackProxyDeviceUUID = None
        LOG.debug("%s component '%s' is now detached from any devices" %
                  (self.meta_type, self.name()))