def get_gw_personality(restproxy_serv, params):
    nuage_gw = nuagelib.NuageGateway(create_params=params)
    gw_resp = restproxy_serv.rest_call('GET', nuage_gw.get_resource_by_id(),
                                       '')
    if not nuage_gw.validate(gw_resp):
        raise restproxy.RESTProxyError(nuage_gw.error_msg)
    if gw_resp[VSD_RESP_OBJ]:
        return gw_resp[VSD_RESP_OBJ][0]['personality']
Exemplo n.º 2
0
def check_gw_enterprise_permissions(restproxy_serv, params):
    nuage_gw = nuagelib.NuageGateway(create_params=params)
    ent_perms = restproxy_serv.get(nuage_gw.get_ent_perm(), required=True)
    if not ent_perms:
        return False
    else:
        # check if gateway has permissions for current net partition
        if ent_perms[0]['permittedEntityID'] != (params['np_id']):
            msg = ("Gateway doesn't have enterprisepermisssions set for "
                   "net_parttion %s") % params['np_id']
            raise Exception(msg)
        return True
Exemplo n.º 3
0
def get_gateways_for_netpart(restproxy_serv, netpart_id):
    req_params = {
        'netpart_id': netpart_id
    }

    nuage_gw = nuagelib.NuageGateway(create_params=req_params)
    response = restproxy_serv.rest_call('GET',
                                        nuage_gw.get_resource_for_netpart(),
                                        '')

    if not nuage_gw.validate(response):
        raise restproxy.RESTProxyError(nuage_gw.error_msg)

    return nuage_gw.get_response_objlist(response)
def check_gw_enterprise_permissions(restproxy_serv, params):
    nuage_gw = nuagelib.NuageGateway(create_params=params)
    gw_ent_perm_resp = restproxy_serv.rest_call(
        'GET', nuage_gw.get_ent_perm(), '')
    if not nuage_gw.validate(gw_ent_perm_resp):
        raise restproxy.RESTProxyError(nuage_gw.error_msg)

    if not gw_ent_perm_resp[VSD_RESP_OBJ]:
        return False
    else:
        # check if gateway has permissions for current net partition
        if gw_ent_perm_resp[VSD_RESP_OBJ][0]['permittedEntityID'] != (
                params['np_id']):
            msg = ("Gateway doesn't have enterprisepermisssions set for "
                   "net_parttion %s") % params['np_id']
            raise Exception(msg)
        return True
Exemplo n.º 5
0
def get_gateways_for_netpart(restproxy_serv, netpart_id):
    req_params = {'netpart_id': netpart_id}

    nuage_gw = nuagelib.NuageGateway(create_params=req_params)
    return restproxy_serv.get(nuage_gw.get_resource_for_netpart(),
                              required=True)
Exemplo n.º 6
0
def get_gw_personality(restproxy_serv, params):
    nuage_gw = nuagelib.NuageGateway(create_params=params)
    gws = restproxy_serv.get(nuage_gw.get_resource_by_id(), required=True)
    return gws[0]['personality'] if gws else None