def setup_clients(cls):
     """
     Create various client connections. Such as NSXv3 and L2 Gateway.
     """
     super(BaseL2GatewayTest, cls).setup_clients()
     cls.l2gw_created = {}
     cls.l2gwc_created = {}
     try:
         manager = getattr(cls.os_adm, "manager", cls.os_adm)
         net_client = getattr(manager, "networks_client")
         _params = manager.default_params_withy_timeout_values.copy()
     except AttributeError as attribute_err:
         LOG.warning(
             _LW("Failed to locate the attribute, Error: %(err_msg)s") %
             {"err_msg": attribute_err.__str__()})
         _params = {}
     cls.l2gw_client = l2_gateway_client.L2GatewayClient(
         net_client.auth_provider,
         net_client.service,
         net_client.region,
         net_client.endpoint_type,
         **_params)
     cls.nsxv3_client_obj = nsxv3_client.NSXV3Client(
         CONF.nsxv3.nsx_manager,
         CONF.nsxv3.nsx_user,
         CONF.nsxv3.nsx_password)
     cls.l2gwc_client = \
         l2_gateway_connection_client.L2GatewayConnectionClient(
             net_client.auth_provider,
             net_client.service,
             net_client.region,
             net_client.endpoint_type,
             **_params)
 def setup_clients(cls):
     """
     Create various client connections. Such as NSXv3 and L2 Gateway.
     """
     super(BaseL2GatewayTest, cls).setup_clients()
     cls.l2gw_created = {}
     cls.l2gwc_created = {}
     try:
         manager = getattr(cls.os_adm, "manager", cls.os_adm)
         net_client = getattr(manager, "networks_client")
         _params = manager.default_params_withy_timeout_values.copy()
     except AttributeError as attribute_err:
         LOG.warning(
             _LW("Failed to locate the attribute, Error: %(err_msg)s") %
             {"err_msg": attribute_err.__str__()})
         _params = {}
     cls.l2gw_client = l2_gateway_client.L2GatewayClient(
         net_client.auth_provider, net_client.service, net_client.region,
         net_client.endpoint_type, **_params)
     cls.nsxv3_client_obj = nsxv3_client.NSXV3Client(
         CONF.nsxv3.nsx_manager, CONF.nsxv3.nsx_user,
         CONF.nsxv3.nsx_password)
     cls.l2gwc_client = \
         l2_gateway_connection_client.L2GatewayConnectionClient(
             net_client.auth_provider,
             net_client.service,
             net_client.region,
             net_client.endpoint_type,
             **_params)
Exemple #3
0
 def setup_clients(cls):
     super(TaaSJsonTest, cls).setup_clients()
     try:
         cls.tclient = taas_client.get_client(cls.manager)
         cls.nsx = nsxv3_client.NSXV3Client(CONF.nsxv3.nsx_manager,
                                            CONF.nsxv3.nsx_user,
                                            CONF.nsxv3.nsx_password)
     except AttributeError as attribute_err:
         LOG.warning(
             _LW("Failed to locate the attribute, Error: %(err_msg)s") %
             {"err_msg": attribute_err.__str__()})
def get_client(client_mgr):
    """
    Create a l2-gateway client from manager or networks_client
    """
    try:
        manager = getattr(client_mgr, "manager", client_mgr)
        net_client = getattr(manager, "networks_client")
        _params = manager.default_params_withy_timeout_values.copy()
    except AttributeError as attribute_err:
        LOG.warning(
            _LW("Failed to locate the attribute, Error: %(err_msg)s") %
            {"err_msg": attribute_err.__str__()})
        _params = {}
    client = L2GatewayClient(net_client.auth_provider, net_client.service,
                             net_client.region, net_client.endpoint_type,
                             **_params)
    return client
def get_client(client_mgr):
    """
    Create a l2-gateway client from manager or networks_client
    """
    try:
        manager = getattr(client_mgr, "manager", client_mgr)
        net_client = getattr(manager, "networks_client")
        _params = manager.default_params_withy_timeout_values.copy()
    except AttributeError as attribute_err:
        LOG.warning(_LW("Failed to locate the attribute, Error: %(err_msg)s") %
                    {"err_msg": attribute_err.__str__()})
        _params = {}
    client = L2GatewayClient(net_client.auth_provider,
                             net_client.service,
                             net_client.region,
                             net_client.endpoint_type,
                             **_params)
    return client
    def get_nsx_resource_by_name(self, nsx_resources, nsx_name):
        """
        Get the NSX component created from OpenStack by name.

        The name should be converted from os_name to nsx_name.
        If found exact one match return it, otherwise report error.
        """
        nsx_resource = [n for n in nsx_resources if
                        n['display_name'] == nsx_name]
        if len(nsx_resource) == 0:
            LOG.warning(_LW("Backend nsx resource %s NOT found!"), nsx_name)
            return None
        if len(nsx_resource) > 1:
            LOG.error(_LE("More than 1 nsx resources found: %s!"),
                      nsx_resource)
            return None
        else:
            LOG.info(_LI("Found nsgroup: %s"), nsx_resource[0])
            return nsx_resource[0]
    def get_nsx_resource_by_name(self, nsx_resources, nsx_name):
        """
        Get the NSX component created from OpenStack by name.

        The name should be converted from os_name to nsx_name.
        If found exact one match return it, otherwise report error.
        """
        nsx_resource = [
            n for n in nsx_resources if n['display_name'] == nsx_name
        ]
        if len(nsx_resource) == 0:
            LOG.warning(_LW("Backend nsx resource %s NOT found!"), nsx_name)
            return None
        if len(nsx_resource) > 1:
            LOG.error(_LE("More than 1 nsx resources found: %s!"),
                      nsx_resource)
            return None
        else:
            LOG.info(_LI("Found nsgroup: %s"), nsx_resource[0])
            return nsx_resource[0]