def get_nova_client(auth_token=None, bypass_url=None, previous_tries=0):
        if previous_tries > 3:
            return None

        # first try to use auth details from auth_ref so we
        # don't need to auth with keystone every time
        auth_ref = get_auth_ref()
        auth_details = get_auth_details()
        keystone = get_keystone_client(auth_ref)

        if not auth_token:
            auth_token = keystone.auth_token
        if not bypass_url:
            bypass_url = get_endpoint_url_for_service('compute',
                                                      auth_ref,
                                                      get_endpoint_type(
                                                          auth_details))

        nova = nova_client.Client('2', auth_token=auth_token,
                                  bypass_url=bypass_url,
                                  insecure=auth_details['OS_API_INSECURE'])

        try:
            flavors = nova.flavors.list()
            # Exceptions are only thrown when we try and do something
            [flavor.id for flavor in flavors]

        except (nova_exc.Unauthorized, nova_exc.AuthorizationFailure,
                __HOLE__) as e:
            # NOTE(mancdaz)nova doesn't properly pass back unauth errors, but
            # in fact tries to re-auth, all by itself. But we didn't pass it
            # an auth_url, so it bombs out horribly with an error.

            auth_ref = force_reauth()
            keystone = get_keystone_client(auth_ref)
            auth_token = keystone.auth_token

            nova = get_nova_client(auth_token, bypass_url, previous_tries + 1)

            # we only want to pass ClientException back to the calling poller
            # since this encapsulates all of our actual API failures. Other
            # exceptions will be treated as script/environmental issues and
            # sent to status_err
        except nova_exc.ClientException:
            raise
        except Exception as e:
            status_err(str(e))

        return nova
dataset/ETHPy150Open rcbops/rpc-openstack/maas/plugins/maas_common.py/get_nova_client