Ejemplo n.º 1
0
 def _check_version_header(self):
     if "x-ms-version" not in self._headers:
         versions = self._get_versions()
         if WIRE_SERVER_VERSION not in versions.Versions.Supported.Version:
             raise exception.MetadaNotFoundException(
                 "Unsupported Azure WireServer version: %s" %
                 WIRE_SERVER_VERSION)
         self._headers["x-ms-version"] = WIRE_SERVER_VERSION
Ejemplo n.º 2
0
def get_metadata_service():
    # Return the first service that loads correctly
    cl = classloader.ClassLoader()
    for class_path in CONF.metadata_services:
        service = cl.load_class(class_path)()
        try:
            if service.load():
                return service
        except Exception as ex:
            LOG.error("Failed to load metadata service '%s'" % class_path)
            LOG.exception(ex)
    raise exception.MetadaNotFoundException("No available service found")
Ejemplo n.º 3
0
    def _get_wire_server_endpoint_address(self):
        total_time = 300
        poll_time = 5
        retries = total_time / poll_time

        while True:
            try:
                options = dhcp.get_dhcp_options()
                endpoint = (options or {}).get(WIRESERVER_DHCP_OPTION)
                if not endpoint:
                    raise exception.MetadaNotFoundException(
                        "Cannot find Azure WireServer endpoint address")
                return socket.inet_ntoa(endpoint)
            except Exception:
                if not retries:
                    raise
                time.sleep(poll_time)
                retries -= 1