当前位置: 首页>>代码示例>>Python>>正文


Python AuthSession.get_clientFactory方法代码示例

本文整理汇总了Python中CadVlan.Auth.AuthSession.AuthSession.get_clientFactory方法的典型用法代码示例。如果您正苦于以下问题:Python AuthSession.get_clientFactory方法的具体用法?Python AuthSession.get_clientFactory怎么用?Python AuthSession.get_clientFactory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CadVlan.Auth.AuthSession.AuthSession的用法示例。


在下文中一共展示了AuthSession.get_clientFactory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: edit_form

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def edit_form(request, id_group_user):

    try:
        lists = dict()
        lists['form'] = GroupUserForm()

        if request.method == 'POST':

            auth = AuthSession(request.session)
            client = auth.get_clientFactory()

            id_group = int(id_group_user)

            form = GroupUserForm(request.POST)

            lists['form'] = form
            lists['action'] = reverse("group-user.edit", args=[id_group])

            if form.is_valid():
                id_group_user = form.cleaned_data['id_group_user']
                name = form.cleaned_data['name']
                read = PERMISSION.get(form.cleaned_data['read'])
                write = PERMISSION.get(form.cleaned_data['write'])
                edition = PERMISSION.get(form.cleaned_data['edition'])
                delete = PERMISSION.get(form.cleaned_data['delete'])

                try:
                    client.create_grupo_usuario().alterar(
                        id_group_user, name, read, write, edition, delete)
                    messages.add_message(
                        request, messages.SUCCESS, group_user_messages.get("success_edit"))
                    return redirect('group-user.list')

                except NetworkAPIClientError, e:
                    messages.add_message(request, messages.ERROR, e)

            return render_to_response(GROUPUSER_FORM, lists, context_instance=RequestContext(request))

        id_group = int(id_group_user)

        auth = AuthSession(request.session)
        client = auth.get_clientFactory()

        group_user = client.create_grupo_usuario().search(id_group)

        if group_user is None:
            messages.add_message(
                request, messages.ERROR, group_user_messages.get("invalid_group_user"))
            return redirect('group-user.list')

        group_user = group_user.get('user_group')

        # Set Group User data
        initial = {'id_group_user':  group_user.get('id'), 'name':  group_user.get('nome'), 'read': get_permission(group_user.get('leitura')), 'write': get_permission(
            group_user.get('escrita')), 'edition': get_permission(group_user.get('edicao')), 'delete': get_permission(group_user.get('exclusao'))}
        form = GroupUserForm(initial=initial)

        lists['form'] = form
        lists['action'] = reverse("group-user.edit", args=[id_group])
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:61,代码来源:views.py

示例2: add_form

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def add_form(request):
    lists = dict()
    try:
        if request.method == 'GET':

            auth = AuthSession(request.session)
            client = auth.get_clientFactory()

            if not request.GET.__contains__('equip_name'):
                form = SearchEquipForm()
            else:
                form = SearchEquipForm(request.GET)

            if form.is_valid():

                name_equip = form.cleaned_data['equip_name']

                equip = client.create_equipamento().listar_por_nome(name_equip)
                id_equip = equip.get('equipamento').get('id')
                protocol_list = client.create_tipo_acesso().listar()

                lists['formCad'] = formCad = EquipAccessForm(protocol_list)
                formCad.fields['id_equip'].initial = id_equip
                formCad.fields['name_equip'].initial = name_equip

            lists['form'] = form
            return render_to_response(EQUIPMENTACESS_FORM, lists, context_instance=RequestContext(request))

        if request.method == 'POST':

            auth = AuthSession(request.session)
            client = auth.get_clientFactory()

            form = SearchEquipForm()
            form.fields['equip_name'].initial = request.POST['name_equip']

            protocol_list = client.create_tipo_acesso().listar()

            formCad = EquipAccessForm(protocol_list, request.POST)

            if formCad.is_valid():
                user = formCad.cleaned_data['user']
                host = formCad.cleaned_data['host']
                password = formCad.cleaned_data['password']
                second_password = formCad.cleaned_data['second_password']
                equip = formCad.cleaned_data['id_equip']
                protocol = formCad.cleaned_data['protocol']

                try:
                    client.create_equipamento_acesso().inserir(
                        equip, host, user, password, protocol, second_password)
                    messages.add_message(
                        request, messages.SUCCESS, equip_access_messages.get("success_insert"))
                    return search_list_param(request, equip)
                except EquipamentoAcessoError, e:
                    messages.add_message(
                        request, messages.ERROR, equip_access_messages.get("already_association"))
                except NetworkAPIClientError, e:
                    messages.add_message(request, messages.ERROR, e)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:61,代码来源:views.py

示例3: edit_form_perm

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def edit_form_perm(request, id_ugroup, id_perm):

    try:

        lists = dict()
        lists['edit_perms'] = True
        lists['action_edit_perms'] = reverse(
            "user-group-perm.edit", args=[id_ugroup, id_perm])

        # Get user
        auth = AuthSession(request.session)
        client_perm = auth.get_clientFactory(
        ).create_permissao_administrativa()

        # Get Group User by ID from NetworkAPI
        lists['ugroup'] = auth.get_clientFactory().create_grupo_usuario().search(
            id_ugroup).get('user_group')

        function_list = validates_dict(
            auth.get_clientFactory().create_permission().list_all(), 'perms')

        perm = client_perm.search(id_perm).get("perm")

        if request.method == "POST":

            form = PermissionGroupForm(function_list, request.POST)
            lists['form_perms'] = form

            if form.is_valid():

                id_perm = form.cleaned_data['id_group_perms']
                function = form.cleaned_data['function']
                read = convert_boolean_to_int(form.cleaned_data['read'])
                write = convert_boolean_to_int(form.cleaned_data['write'])

                client_perm.alterar(id_perm, function, read, write, id_ugroup)

                messages.add_message(
                    request, messages.SUCCESS, perm_group_messages.get("success_edit"))

                return redirect('user-group.list', id_ugroup, 1)

        # GET
        else:
            initial = {"id_group_perms": perm.get("id"), "function": perm.get("permission"), "read": convert_string_to_boolean(
                perm.get("leitura")), "write": convert_string_to_boolean(perm.get("escrita"))}
            lists['form_perms'] = PermissionGroupForm(
                function_list, initial=initial)

    except NetworkAPIClientError, e:
        logger.error(e)
        messages.add_message(request, messages.ERROR, e)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:54,代码来源:views.py

示例4: dissociate_channel_interface

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def dissociate_channel_interface(request, channel_id, interface_id):

    auth = AuthSession(request.session)
    client = auth.get_clientFactory()

    fields_get = ['id',
                  'protected',
                  'type__details',
                  'native_vlan',
                  'equipment__details',
                  'front_interface__basic',
                  'back_interface',
                  'channel__basic']

    data = dict()
    data["start_record"] = 0
    data["end_record"] = 50
    data["extends_search"] = []
    data["asorting_cols"] = []
    data["searchable_columns"] = ["channel__id"]
    data["custom_search"] = channel_id

    try:
        sw_ids = list()
        interfaces = client.create_api_interface_request().search(search=data, fields=fields_get).get('interfaces')
        interface_obj = interfaces[0]
        for i in interfaces:
            sw_ids.append(int(i.get('id')))
    except NetworkAPIClientError, e:
        logger.error(e)
        messages.add_message(request, messages.WARNING, 'Erro ao buscar o channel de Id %s.' % channel_id)
        url = request.META.get('HTTP_REFERER') if request.META.get('HTTP_REFERER') else reverse('interface.list')
        return HttpResponseRedirect(url)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:35,代码来源:views_v3.py

示例5: access_type_form

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def access_type_form(request):

    lists = dict()

    try:

        auth = AuthSession(request.session)
        client = auth.get_clientFactory()

        if request.method == 'POST':

            form = TipoAcessoForm(request.POST)
            lists['form'] = form

            if form.is_valid():

                protocolo = form.cleaned_data['nome']

                client.create_tipo_acesso().inserir(protocolo)
                messages.add_message(
                    request, messages.SUCCESS, access_type_messages.get('success_create'))

                lists['form'] = TipoAcessoForm()
        # GET METHOD
        else:
            lists['form'] = TipoAcessoForm()

    except NetworkAPIClientError, e:
        logger.error(e)
        messages.add_message(request, messages.ERROR, e)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:32,代码来源:views.py

示例6: insert_vrf

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def insert_vrf(request):
    try:
        lists = {}

        auth = AuthSession(request.session)
        client = auth.get_clientFactory()

        lists["form_vrf"] = VrfForm()  # TODO Alterar depois de edit pra ""

        if request.method == 'POST':
            # Set data in form
            vrf_form = VrfForm(request.POST)

            # Return data to form in case of error
            lists["form_vrf"] = vrf_form

            # Validate
            if vrf_form.is_valid():
                vrf = vrf_form.cleaned_data["vrf"]
                internal_name = vrf_form.cleaned_data["internal_name"]

                list_vrf = [{
                    "vrf": vrf,
                    "internal_name": internal_name

                }]

                client.create_api_vrf().create(list_vrf)
                messages.add_message(
                    request, messages.SUCCESS, vrf_messages.get("success_insert"))

                return redirect('vrf.list')
    except NetworkAPIClientError, e:
        logger.error(e)
        messages.add_message(request, messages.ERROR, e)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:37,代码来源:views.py

示例7: save_pool

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def save_pool(request):
    """
    Method to call shared_save_pool
    """
    auth = AuthSession(request.session)
    client = auth.get_clientFactory()
    return facade.shared_save_pool(request, client)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:9,代码来源:views.py

示例8: list_all

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def list_all(request):

    try:
        filter_list = dict()

        # Get user
        auth = AuthSession(request.session)
        filter_client = auth.get_clientFactory().create_filter()

        # Get all filters from NetworkAPI
        filter_list = filter_client.list_all()

        for filter_ in filter_list['filter']:
            filter_['is_more'] = str(False)

            if filter_.get('equip_types') is not None:
                if type(filter_['equip_types']) is dict:
                    filter_['equip_types'] = [filter_['equip_types']]

                if len(filter_['equip_types']) > 3:
                    filter_['is_more'] = str(True)

        filter_list['form'] = DeleteForm()

    except NetworkAPIClientError, e:
        logger.error(e)
        messages.add_message(request, messages.ERROR, e)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:29,代码来源:views.py

示例9: ajax_popular_environment

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def ajax_popular_environment(request):
    """
    Method to call popular_environment_shared
    """
    auth = AuthSession(request.session)
    client_api = auth.get_clientFactory()
    return facade.popular_environment_shared(request, client_api)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:9,代码来源:views.py

示例10: ajax_modelo_equip

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def ajax_modelo_equip(request, id_marca):
    try:

        lists = dict()
        # Get user
        auth = AuthSession(request.session)
        client = auth.get_clientFactory()

        marca = int(id_marca)

        if marca > 0:
            modelos = client.create_modelo().listar_por_marca(marca)
            lists['modelos'] = modelos.get('model')

            # Returns HTML
            response = HttpResponse(loader.render_to_string(
                EQUIPMENT_MODELO, lists, context_instance=RequestContext(request)))
            # Send response status with error
            response.status_code = 200
            return response

        else:

            # Returns HTML
            response = HttpResponse(loader.render_to_string(
                EQUIPMENT_MODELO, lists, context_instance=RequestContext(request)))
            # Send response status with error
            response.status_code = 200
            return response

    except NetworkAPIClientError, e:
        logger.error(e)
        messages.add_message(request, messages.ERROR, e)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:35,代码来源:views.py

示例11: search_list

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def search_list(request):

    try:

        lists = dict()
        lists['delete_form'] = DeleteForm()

        # Get user
        auth = AuthSession(request.session)
        client = auth.get_clientFactory()

        # Get all environments from NetworkAPI
        env_list = client.create_ambiente().list_all()
        # Get all equipment types from NetworkAPI
        type_equip_list = client.create_tipo_equipamento().listar()
        # Get all groups from NetworkAPI
        group_list = client.create_grupo_equipamento().listar()

        search_form = SearchEquipmentForm(
            env_list, type_equip_list, group_list)

        lists['search_form'] = search_form

    except NetworkAPIClientError, e:
        logger.error(e)
        messages.add_message(request, messages.ERROR, e)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:28,代码来源:views.py

示例12: ajax_view_real_shared

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def ajax_view_real_shared(request, id_equip, lists):

    try:

        lists['equip_id'] = id_equip

        # Get user
        auth = AuthSession(request.session)
        client = auth.get_clientFactory()

        # Get reals related
        vips_reals = client.create_equipamento().get_real_related(id_equip)
        lists['vips'] = [vips_reals.get('vips'), ] if type(
            vips_reals.get('vips')) is dict else vips_reals.get('vips')
        lists['equip_name'] = vips_reals.get('equip_name')

        # Returns HTML
        response = HttpResponse(loader.render_to_string(
            EQUIPMENT_VIEW_AJAX, lists, context_instance=RequestContext(request)))
        response.status_code = 200
        return response

    except NetworkAPIClientError, e:
        logger.error(e)
        messages.add_message(request, messages.ERROR, e)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:27,代码来源:views.py

示例13: healthcheck_expect_form

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def healthcheck_expect_form(request):

    lists = dict()

    try:

        auth = AuthSession(request.session)
        client = auth.get_clientFactory()
        ambientes = client.create_ambiente().list_all()

        if request.method == 'POST':

            form = HealthckeckExpectForm(ambientes, request.POST)
            lists['form'] = form

            if form.is_valid():

                match_list = form.cleaned_data['match_list']
                expect_string = form.cleaned_data['expect_string']
                environment_id = form.cleaned_data['environment']

                client.create_ambiente().add_healthcheck_expect(
                    environment_id, expect_string, match_list)
                messages.add_message(
                    request, messages.SUCCESS, healthcheck_messages.get('success_create'))

                lists['form'] = HealthckeckExpectForm(ambientes)

        # GET METHOD
        else:
            lists['form'] = HealthckeckExpectForm(ambientes)

    except NetworkAPIClientError, e:
        logger.error(e)
        messages.add_message(request, messages.ERROR, e)
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:37,代码来源:views.py

示例14: ajax_acl_name_suggest

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def ajax_acl_name_suggest(request):
    lists = dict()
    try:

        nome = request.GET['nome']
        id_ambiente = request.GET['id_ambiente']

        auth = AuthSession(request.session)
        client = auth.get_clientFactory()

        environment = client.create_ambiente().buscar_por_id(
            id_ambiente).get('ambiente')

        suggest_name = str(
            nome + environment['nome_ambiente_logico']).replace(" ", "")
        lists['suggest_name'] = suggest_name

        # Returns HTML
        response = HttpResponse(loader.render_to_string(
            AJAX_SUGGEST_NAME, lists, context_instance=RequestContext(request)))
        # Send response status with error
        response.status_code = 200
        return response

    except:

        lists['suggest_name'] = ''
        # Returns HTML
        response = HttpResponse(loader.render_to_string(
            AJAX_SUGGEST_NAME, lists, context_instance=RequestContext(request)))
        # Send response status with error
        response.status_code = 200
        return response
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:35,代码来源:views.py

示例15: show_form

# 需要导入模块: from CadVlan.Auth.AuthSession import AuthSession [as 别名]
# 或者: from CadVlan.Auth.AuthSession.AuthSession import get_clientFactory [as 别名]
def show_form(request):

    try:

        if request.method == "POST":

            # Get user
            auth = AuthSession(request.session)
            client = auth.get_clientFactory()

            # Um form com os dados de POST
            form = ScriptTypeForm(request.POST)

            if form.is_valid():
                tipo = form.cleaned_data['script_type']
                descricao = form.cleaned_data['description']
                try:
                    client.create_tipo_roteiro().inserir(
                        tipo, descricao)
                    messages.add_message(
                        request, messages.SUCCESS, script_type_messages.get("success_insert"))

                    return redirect('script.type.list')
                except NomeTipoRoteiroDuplicadoError, e:
                    messages.add_message(
                        request, messages.ERROR, script_type_messages.get("error_equal_name") % tipo)

        else:
开发者ID:globocom,项目名称:GloboNetworkAPI-WebUI,代码行数:30,代码来源:views.py


注:本文中的CadVlan.Auth.AuthSession.AuthSession.get_clientFactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。