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


Python script_utils.exec_script函数代码示例

本文整理汇总了Python中networkapi.infrastructure.script_utils.exec_script函数的典型用法代码示例。如果您正苦于以下问题:Python exec_script函数的具体用法?Python exec_script怎么用?Python exec_script使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: update_pool_maxconn

def update_pool_maxconn(maxconn, old_maxconn, sp, user):
    sp.default_limit = maxconn
    sp.save()

    # If pool member  exists, checks if all of them have the same maxconn
    # before changing its default maxconn
    if(len(sp.serverpoolmember_set.all()) > 0):
        if(old_maxconn != sp.default_limit and sp.pool_created):

            for serverpoolmember in sp.serverpoolmember_set.all():
                if serverpoolmember.limit != old_maxconn:
                    raise exceptions.ScriptAlterLimitPoolDiffMembersException()
                else:
                    serverpoolmember.limit = maxconn
                    serverpoolmember.save()

            transaction.commit()
            command = settings.POOL_MANAGEMENT_LIMITS % (sp.id)
            code, _, _ = exec_script(command)
            if code != 0:
                sp.default_limit = old_maxconn
                for serverpoolmember in sp.serverpoolmember_set.all():
                    serverpoolmember.limit = old_maxconn
                    serverpoolmember.save()

                sp.save()
                transaction.commit()
                raise exceptions.ScriptAlterLimitPoolException()
开发者ID:jotagesales,项目名称:GloboNetworkAPI,代码行数:28,代码来源:facade.py

示例2: check_pool_member_status

    def check_pool_member_status(self, obj):

        command = POOL_REAL_CHECK % (obj.server_pool.id, obj.ip.id, obj.port_real)

        code, _, _ = exec_script(command)

        return code
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:7,代码来源:serializers.py

示例3: activate_network

    def activate_network(self, user, id):
        # id => ex: '55-v4' or '55-v6'
        value = id.split('-')

        if len(value) != 2:
            self.log.error(
                u'The id network parameter is invalid format: %s.', value)
            raise InvalidValueError(None, 'id_network', value)

        id_net = value[0]
        network_type = value[1]

        if not is_valid_int_greater_zero_param(id_net):
            self.log.error(
                u'The id network parameter is invalid. Value: %s.', id_net)
            raise InvalidValueError(None, 'id_network', id_net)

        if not is_valid_version_ip(network_type, IP_VERSION):
            self.log.error(
                u'The type network parameter is invalid value: %s.', network_type)
            raise InvalidValueError(None, 'network_type', network_type)

        if network_type == 'v4':
            # network_type = 'v4'

            # Make command
            command = NETWORKIPV4_CREATE % int(id_net)
            code, stdout, stderr = exec_script(command)
            if code == 0:
                # Change column 'active = 1'
                net = NetworkIPv4.get_by_pk(id_net)
                net.activate(user)
        else:
            # network_type = 'v6'

            # Make command
            command = NETWORKIPV6_CREATE % int(id_net)
            code, stdout, stderr = exec_script(command)
            if code == 0:
                # Change column 'active = 1'
                net = NetworkIPv6.get_by_pk(id_net)
                net.activate(user)

        return code, stdout, stderr
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:44,代码来源:NetworkEditResource.py

示例4: deploy_pool_member_config

def deploy_pool_member_config(id_ip, id_pool, port_ip, spm, user):
    transaction.commit()
    # def prepare_and_save(self, server_pool, ip, ip_type, priority, weight, port_real, user, commit=False):
    # spm.prepare_and_save(sp, ip_object, IP_VERSION.IPv4[1], dic['priority'], dic['weight'], dic['port_real'], user, True)
    command = settings.POOL_REAL_CREATE % (id_pool, id_ip, port_ip)
    code, _, _ = exec_script(command)
    if code != 0:
        spm.delete()
        transaction.commit()
        raise exceptions.ScriptCreatePoolException()
开发者ID:jotagesales,项目名称:GloboNetworkAPI,代码行数:10,代码来源:facade.py

示例5: apply_priorities

def apply_priorities(list_pool_member, old_priorities_list, sp, user):
    transaction.commit()
    command = settings.POOL_MEMBER_PRIORITIES % (sp.id)
    code, _, _ = exec_script(command)
    if code != 0:
        for i in range(0, len(old_priorities_list)):
            list_pool_member[i].priority = old_priorities_list[i]
            list_pool_member[i].save()
        transaction.commit()
        raise exceptions.ScriptAlterPriorityPoolMembersException()
开发者ID:jotagesales,项目名称:GloboNetworkAPI,代码行数:10,代码来源:facade.py

示例6: exec_script_check_poolmember_by_pool

def exec_script_check_poolmember_by_pool(pool_id):

    # execute script check status real
    command = settings.POOL_REAL_CHECK_BY_POOL % (pool_id)
    status_code, stdout, stderr = exec_script(command)

    if status_code != 0:
        raise exceptions.ScriptCheckStatusPoolMemberException()

    return stdout
开发者ID:jotagesales,项目名称:GloboNetworkAPI,代码行数:10,代码来源:facade.py

示例7: deactivate_network

    def deactivate_network(self, user, id):

        id_network, network_type = self.get_id_and_net_type(id)

        if not is_valid_int_greater_zero_param(id_network):
            self.log.error(
                u'The id network parameter is invalid. Value: %s.', id_network)
            raise InvalidValueError(None, 'id_network', id_network)

        if not is_valid_version_ip(network_type, IP_VERSION):
            self.log.error(
                u'The type network parameter is invalid value: %s.', network_type)
            raise InvalidValueError(None, 'network_type', network_type)

        if network_type == self.NETWORK_TYPE_V4:
            net = NetworkIPv4.get_by_pk(id_network)

            if not self.is_active_netwok(net):
                raise NetworkInactiveError(
                    message=error_messages.get(self.CODE_MESSAGE_INACTIVE_NETWORK))

            command = NETWORKIPV4_REMOVE % int(id_network)

            code, stdout, stderr = exec_script(command)
            if code == 0:
                net = NetworkIPv4.get_by_pk(id_network)
                net.deactivate(user)
        else:

            net = NetworkIPv6.get_by_pk(id_network)

            if not self.is_active_netwok(net):
                raise NetworkInactiveError(
                    message=error_messages.get(self.CODE_MESSAGE_INACTIVE_NETWORK))

            command = NETWORKIPV6_REMOVE % int(id_network)

            code, stdout, stderr = exec_script(command)
            if code == 0:
                net.deactivate(user)

        return code, stdout, stderr
开发者ID:itnihao,项目名称:GloboNetworkAPI,代码行数:42,代码来源:NetworkRemoveResource.py

示例8: check_pool_member_enabled

    def check_pool_member_enabled(self, obj):

        command = POOL_REAL_CHECK % (obj.server_pool.id, obj.ip.id, obj.port_real)


        code, _, _ = exec_script(command)

        if code == 0:
            return True

        return False
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:11,代码来源:serializers.py

示例9: create_vlan

    def create_vlan(self, user, vlan_id):

        if not has_perm(user, AdminPermission.VLAN_MANAGEMENT, AdminPermission.WRITE_OPERATION):
            return self.not_authorized()

        vlan = Vlan().get_by_pk(vlan_id)

        # Check permission group equipments
        equips_from_ipv4 = Equipamento.objects.filter(
            ipequipamento__ip__networkipv4__vlan=vlan_id, equipamentoambiente__is_router=1)
        equips_from_ipv6 = Equipamento.objects.filter(
            ipv6equipament__ip__networkipv6__vlan=vlan_id, equipamentoambiente__is_router=1)
        for equip in equips_from_ipv4:
            # User permission
            if not has_perm(user, AdminPermission.EQUIPMENT_MANAGEMENT, AdminPermission.WRITE_OPERATION, None, equip.id, AdminPermission.EQUIP_WRITE_OPERATION):
                self.log.error(
                    u'User does not have permission to perform the operation.')
                return self.not_authorized()
        for equip in equips_from_ipv6:
            # User permission
            if not has_perm(user, AdminPermission.EQUIPMENT_MANAGEMENT, AdminPermission.WRITE_OPERATION, None, equip.id, AdminPermission.EQUIP_WRITE_OPERATION):
                self.log.error(
                    u'User does not have permission to perform the operation.')
                return self.not_authorized()

        if vlan.ativada:
            return self.response_error(122)

        command = settings.VLAN_CREATE % (vlan.id)

        code, stdout, stderr = exec_script(command)
        if code == 0:
            vlan.activate(user)

            success_map = dict()
            success_map['codigo'] = '%04d' % code
            success_map['descricao'] = {'stdout': stdout, 'stderr': stderr}

            map = dict()
            map['sucesso'] = success_map

            # Send to Queue
            queue_manager = QueueManager()

            serializer = VlanSerializer(vlan)
            data_to_queue = serializer.data
            data_to_queue.update({'description': queue_keys.VLAN_CREATE})
            queue_manager.append({'action': queue_keys.VLAN_CREATE,'kind': queue_keys.VLAN_KEY,'data': data_to_queue})

            queue_manager.send()

            return self.response(dumps_networkapi(map))
        else:
            return self.response_error(2, stdout + stderr)
开发者ID:itnihao,项目名称:GloboNetworkAPI,代码行数:54,代码来源:VlanResource.py

示例10: update_load_balancing_method

def update_load_balancing_method(balancing, old_lb_method, sp, user):
    sp.lb_method = balancing
    sp.save()
    if (old_lb_method != sp.lb_method and sp.pool_created):
        transaction.commit()
        command = settings.POOL_MANAGEMENT_LB_METHOD % (sp.id)
        code, _, _ = exec_script(command)
        if code != 0:
            sp.lb_method = old_lb_method
            sp.save()
            transaction.commit()
            raise exceptions.ScriptCreatePoolException()
开发者ID:jotagesales,项目名称:GloboNetworkAPI,代码行数:12,代码来源:facade.py

示例11: apply_health_check

def apply_health_check(hc, old_healthcheck, sp, user):
    # Applies new healthcheck in pool
    sp.healthcheck = hc
    sp.save()
    if (old_healthcheck.id != hc.id and sp.pool_created):
        transaction.commit()
        command = settings.POOL_HEALTHCHECK % (sp.id)
        code, _, _ = exec_script(command)
        if code != 0:
            sp.healthcheck = old_healthcheck
            sp.save()
            transaction.commit()
            raise exceptions.ScriptCreatePoolException()
开发者ID:jotagesales,项目名称:GloboNetworkAPI,代码行数:13,代码来源:facade.py

示例12: apply_service_down_action

def apply_service_down_action(old_servicedownaction, servicedownaction, sp, user):
    # Applies new service-down-action in pool
    sp.servicedownaction = servicedownaction
    sp.save()
    if (old_servicedownaction != sp.servicedownaction and sp.pool_created):
        transaction.commit()
        command = settings.POOL_SERVICEDOWNACTION % (sp.id)
        code, _, _ = exec_script(command)
        if code != 0:
            sp.servicedownaction = old_servicedownaction
            sp.save()
            transaction.commit()
            raise exceptions.ScriptAlterServiceDownActionException()
开发者ID:jotagesales,项目名称:GloboNetworkAPI,代码行数:13,代码来源:facade.py

示例13: deactivate_network

    def deactivate_network(self, user, id):

        id_network, network_type = self.get_id_and_net_type(id)

        if not is_valid_int_greater_zero_param(id_network):
            self.log.error(
                u'The id network parameter is invalid. Value: %s.', id_network)
            raise InvalidValueError(None, 'id_network', id_network)

        if not is_valid_version_ip(network_type, IP_VERSION):
            self.log.error(
                u'The type network parameter is invalid value: %s.', network_type)
            raise InvalidValueError(None, 'network_type', network_type)

        if not self.is_active_netwok(net):
            code = 0
            stdout = 'Nothing to do. Network is not active.'
            stderr = ''
        else:
            if network_type == self.NETWORK_TYPE_V4:
                net = NetworkIPv4.get_by_pk(id_network)

                command = NETWORKIPV4_REMOVE % int(id_network)

                code, stdout, stderr = exec_script(command)
                if code == 0:
                    net = NetworkIPv4.get_by_pk(id_network)
                    net.deactivate(user)
            else:
                net = NetworkIPv6.get_by_pk(id_network)

                command = NETWORKIPV6_REMOVE % int(id_network)

                code, stdout, stderr = exec_script(command)
                if code == 0:
                    net.deactivate(user)

        return code, stdout, stderr
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:38,代码来源:NetworkRemoveResource.py

示例14: create_vip

 def create_vip(self, vips):
     try:
         if vips.get('layers'):
             for vip_id in vips.get('layers'):
                 for id_layer in vips.get('layers').get(vip_id):
                     vip_request = vips.get('layers').get(
                         vip_id).get(id_layer).get('vip_request')
                     command = 'gerador_vips -i %s --cria --aceonly' % vip_request[
                         'id']
                     log.info('calling script: %s' % command)
                     code, stdout, stderr = exec_script(command)
     except Exception, e:
         log.error(e)
         raise base_exceptions.CommandErrorException(e)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:14,代码来源:plugin.py

示例15: remove_pool_members

def remove_pool_members(id_pool_member_noempty, sp, user):
    # exclue server pool member
    del_smp = sp.serverpoolmember_set.exclude(id__in=id_pool_member_noempty)
    if del_smp:
        for obj in del_smp:

            obj.delete()

            # execute script remove real if pool already created
            # commit transaction after each successful script call
            if sp.pool_created:
                command = settings.POOL_REAL_REMOVE % (
                    obj.server_pool_id, obj.ip_id if obj.ip else obj.ipv6_id, obj.port_real)
                code, _, _ = exec_script(command)
                if code != 0:
                    raise exceptions.ScriptCreatePoolException()
                transaction.commit()
开发者ID:jotagesales,项目名称:GloboNetworkAPI,代码行数:17,代码来源:facade.py


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