def get_node_id()

in libcloud/compute/drivers/openstack.py [0:0]


    def get_node_id(self):
        if not self.node_id:
            # if node id is not set, get it from port_details

            # In neutron version prior to 13.0.0 port_details does not exists
            if "port_details" not in self.extra or not self.extra["port_details"]:
                # if port_details is not available get if from port info using port_id
                try:
                    port = self.driver.ex_get_port(self.extra["port_id"])
                except Exception:
                    port = None
                if port:
                    self.extra["port_details"] = {
                        "device_id": port.extra["device_id"],
                        "device_owner": port.extra["device_owner"],
                        "mac_address": port.extra["mac_address"],
                    }

            if "port_details" in self.extra and self.extra["port_details"]:
                dev_owner = self.extra["port_details"]["device_owner"]
                if dev_owner and dev_owner.startswith("compute:"):
                    self.node_id = self.extra["port_details"]["device_id"]

        return self.node_id