本文整理汇总了Python中networkapi.infrastructure.script_utils.exec_script函数的典型用法代码示例。如果您正苦于以下问题:Python exec_script函数的具体用法?Python exec_script怎么用?Python exec_script使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exec_script函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: handle_delete
def handle_delete(self, request, user, *args, **kwargs):
"""Handles DELETE requests to remove VLAN by ID.
URLs: /vlan/<id_vlan>/remove/
"""
self.log.info('Remove VLAN by ID')
CODE_MESSAGE_VLAN_ERROR = 369
try:
# Commons Validations
# User permission
if not has_perm(user, AdminPermission.VLAN_MANAGEMENT, AdminPermission.WRITE_OPERATION):
self.log.error(
u'User does not have permission to perform the operation.')
return self.not_authorized()
# Business Validations
# Load URL param
vlan_id = kwargs.get('id_vlan')
# Valid VLAN ID
if not is_valid_int_greater_zero_param(vlan_id):
self.log.error(
u'Parameter id_vlan is invalid. Value: %s.', vlan_id)
raise InvalidValueError(None, 'id_vlan', vlan_id)
# Existing VLAN ID
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).distinct()
equips_from_ipv6 = Equipamento.objects.filter(
ipv6equipament__ip__networkipv6__vlan=vlan_id, equipamentoambiente__is_router=1).distinct()
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()
with distributedlock(LOCK_VLAN % vlan_id):
# Business Rules
if vlan.ativada:
network_errors = []
for net4 in vlan.networkipv4_set.all():
if net4.active:
try:
command = settings.NETWORKIPV4_REMOVE % int(net4.id)
code, stdout, stderr = exec_script(command)
if code == 0:
net4.deactivate(user, True)
else:
network_errors.append(str(net4.id))
except Exception, e:
network_errors.append(str(net4.id))
pass
for net6 in vlan.networkipv6_set.all():
if net6.active:
try:
command = settings.NETWORKIPV6_REMOVE % int(net6.id)
code, stdout, stderr = exec_script(command)
if code == 0:
net6.deactivate(user, True)
else:
network_errors.append(str(net6.id))
except Exception, e:
network_errors.append(str(net6.id))
pass
if network_errors:
raise VlanNetworkError(
None, message=', '.join(network_errors))
else:
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:93,代码来源:VlanRemoveResource.py
示例17: dict
success_map = dict()
success_map['codigo'] = '%04d' % 0
success_map['descricao'] = {
'stdout': 'Nothing to do. Vlan was already not active', 'stderr': ''}
map = dict()
map['sucesso'] = success_map
return self.response(dumps_networkapi(map))
# Execute script
vlan_id = vlan.id
environment_id = vlan.ambiente.id
# navlan -i <ID_REQUISICAO> --remove
command = settings.VLAN_REMOVE % vlan_id
code, stdout, stderr = exec_script(command)
# Return XML
if code == 0:
success_map = dict()
success_map['codigo'] = '%04d' % code
success_map['descricao'] = {
'stdout': stdout, 'stderr': stderr}
map = dict()
map['sucesso'] = success_map
#Set as deactivate
vlan.remove(user)
return self.response(dumps_networkapi(map))
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:31,代码来源:VlanRemoveResource.py
示例18: add_remove_check_list_vlan_trunk
def add_remove_check_list_vlan_trunk(self, user, networkapi_map, vlan_id, operation):
equipment_map = networkapi_map.get('equipamento')
if equipment_map is None:
return self.response_error(105)
try:
name = equipment_map.get('nome')
if name is None or name == '':
self.log.error(u'Parameter nome is invalid. Value: %s.', name)
raise InvalidValueError(None, 'nome', name)
interface_name = equipment_map.get('nome_interface')
if interface_name is None or interface_name == '':
self.log.error(
u'Parameter nome_interface is invalid. Value: %s.', interface_name)
raise InvalidValueError(None, 'nome_interface', interface_name)
if operation != 'list':
vlan = Vlan().get_by_pk(vlan_id)
# Check existence
equipment = Equipamento().get_by_name(name)
equip_permission = AdminPermission.EQUIP_UPDATE_CONFIG_OPERATION
admin_permission = AdminPermission.WRITE_OPERATION
if operation in ['check', 'list']:
equip_permission = AdminPermission.EQUIP_READ_OPERATION
admin_permission = AdminPermission.READ_OPERATION
if not has_perm(user,
AdminPermission.VLAN_ALTER_SCRIPT,
admin_permission,
None,
equipment.id,
equip_permission):
return self.not_authorized()
interface = Interface.get_by_interface_equipment(
interface_name, equipment.id)
if interface.ligacao_front is None:
return self.response_error(139)
protected = None
if operation not in ['check', 'list']:
protected = 0
try:
switch_interface = interface.get_switch_interface_from_host_interface(
protected)
except InterfaceNotFoundError:
return self.response_error(144)
if not has_perm(user,
AdminPermission.VLAN_ALTER_SCRIPT,
admin_permission,
None,
switch_interface.equipamento_id,
equip_permission):
return self.not_authorized()
# configurador -T snmp_vlans_trunk -i <nomequip> -A “'int=<interface> add=<numvlan>'”
# configurador -T snmp_vlans_trunk -i <nomequip> -A “'int=<interface> del=<numvlan>'”
# configurador -T snmp_vlans_trunk -i <nomequip> -A “'int=<interface> check=<numvlan>'"
# configurador -T snmp_vlans_trunk -i <nomequip> -A
# “'int=<interface> list'"
command = 'configurador -T snmp_vlans_trunk -i %s -A "\'int=%s %s' % (switch_interface.equipamento.nome,
switch_interface.interface,
operation)
if operation != 'list':
command = command + '=%d' % vlan.num_vlan
command = command + '\'"'
code, stdout, stderr = exec_script(command)
if code == 0:
map = dict()
success_map = dict()
success_map['codigo'] = '%04d' % code
success_map['descricao'] = {'stdout': stdout, 'stderr': stderr}
map['sucesso'] = success_map
return self.response(dumps_networkapi(map))
else:
return self.response_error(2, stdout + stderr)
except EquipamentoNotFoundError:
return self.response_error(117, name)
except InvalidValueError, e:
return self.response_error(269, e.param, e.value)
开发者ID:globocom,项目名称:GloboNetworkAPI,代码行数:91,代码来源:VlanResource.py
示例19: administrate_real
#.........这里部分代码省略.........
vip_id, real_name, end_ip)
ServerPoolMember().save_with_default_port(
vip_id, Ipv6Equip.ip, IP_VERSION.IPv6[1], user)
elif (operation == 'del'):
if IP_VERSION.IPv4[0] == network_version:
if new_call:
command = VIP_REALS_v4_REMOVE % (
vip_id, ip_id, port_real, port_vip)
pool_members = ServerPoolMember.objects.filter(
ip=ip_id, server_pool__vipporttopool__requisicao_vip__id=vip_id, server_pool__vipporttopool__port_vip=port_vip, port_real=port_real)
[pool_member.delete()
for pool_member in pool_members]
else:
command = VIP_REAL_v4_REMOVE % (
vip_id, real_name, end_ip)
pool_members = ServerPoolMember.objects.filter(
ip=ip_id, server_pool__vipporttopool__requisicao_vip__id=vip_id)
[pool_member.delete()
for pool_member in pool_members]
else:
if new_call:
command = VIP_REALS_v6_REMOVE % (
vip_id, ip_id, port_real, port_vip)
pool_members = ServerPoolMember.objects.filter(
ipv6=ip_id, server_pool__vipporttopool__requisicao_vip__id=vip_id, server_pool__vipporttopool__port_vip=port_vip, port_real=port_real)
[pool_member.delete()
for pool_member in pool_members]
else:
command = VIP_REAL_v6_REMOVE % (
vip_id, real_name, end_ip)
pool_members = ServerPoolMember.objects.filter(
ipv6=ip_id, server_pool__vipporttopool__requisicao_vip__id=vip_id)
[pool_member.delete()
for pool_member in pool_members]
elif (operation == 'ena'):
if IP_VERSION.IPv4[0] == network_version:
if new_call:
command = VIP_REALS_v4_ENABLE % (
vip_id, ip_id, port_real, port_vip)
else:
command = VIP_REAL_v4_ENABLE % (
vip_id, real_name, end_ip)
else:
if new_call:
command = VIP_REALS_v6_ENABLE % (
vip_id, ip_id, port_real, port_vip)
else:
command = VIP_REAL_v6_ENABLE % (
vip_id, real_name, end_ip)
elif (operation == 'dis'):
if IP_VERSION.IPv4[0] == network_version:
if new_call:
command = VIP_REALS_v4_DISABLE % (
vip_id, ip_id, port_real, port_vip)
else:
command = VIP_REAL_v4_DISABLE % (
vip_id, real_name, end_ip)
else:
if new_call:
command = VIP_REALS_v6_DISABLE % (
vip_id, ip_id, port_real, port_vip)
else:
command = VIP_REAL_v6_DISABLE % (
vip_id, real_name, end_ip)
self.log.info(command)
# Execute script
code, stdout, stderr = exec_script(command)
self.log.info(stdout)
map = dict()
success_map = dict()
# Return XML
if code == 0:
success_map['codigo'] = '%04d' % code
success_map['descricao'] = {'stdout': stdout, 'stderr': stderr}
map['sucesso'] = success_map
return self.response(dumps_networkapi(map))
elif code == 12:
success_map['codigo'] = '0'
success_map['descricao'] = {'stdout': '0', 'stderr': ''}
map['sucesso'] = success_map
self.rollback_changes(operation, new_call, network_version,
vip_id, ip_id, port_real, port_vip, real_name, end_ip, user)
return self.response(dumps_networkapi(map))
else:
self.rollback_changes(operation, new_call, network_version,
vip_id, ip_id, port_real, port_vip, real_name, end_ip, user)
return self.response_error(2, stdout + stderr)
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:101,代码来源:RequestVipsRealResource.py
示例20: handle_put
#.........这里部分代码省略.........
raise RequestVipsNotBeenCreatedError(None)
# Vip equipments permission
if vip.ip is not None:
for ip_equipment in vip.ip.ipequipamento_set.all():
if not has_perm(user, AdminPermission.VIP_ALTER_SCRIPT, AdminPermission.WRITE_OPERATION, None, ip_equipment.equipamento_id, AdminPermission.EQUIP_UPDATE_CONFIG_OPERATION):
self.log.error(
u'Groups of equipment registered with the IP of the VIP request is not allowed of acess.')
raise EquipmentGroupsNotAuthorizedError(None)
if vip.ipv6 is not None:
for ip_equipment in vip.ipv6.ipv6equipament_set.all():
if not has_perm(user, AdminPermission.VIP_ALTER_SCRIPT, AdminPermission.WRITE_OPERATION, None, ip_equipment.equipamento_id, AdminPermission.EQUIP_UPDATE_CONFIG_OPERATION):
self.log.error(
u'Groups of equipment registered with the IP of the VIP request is not allowed of acess.')
raise EquipmentGroupsNotAuthorizedError(None)
# Get variables
variables_map = vip.variables_to_map()
# Valid variables
vip.set_variables(variables_map)
# Valid real names and real ips of real server
if variables_map.get('reals') is not None:
evip = EnvironmentVip.get_by_values(variables_map.get(
'finalidade'), variables_map.get('cliente'), variables_map.get('ambiente'))
for real in variables_map.get('reals').get('real'):
ip_aux_error = real.get('real_ip')
equip_aux_error = real.get('real_name')
equip = Equipamento.get_by_name(equip_aux_error)
# Valid Real
RequisicaoVips.valid_real_server(
ip_aux_error, equip, evip)
# Valid reals_prioritys
variables_map, code = vip.valid_values_reals_priority(
variables_map)
if code is not None:
return self.response_error(329)
# Valid reals_weight
variables_map, code = vip.valid_values_reals_weight(
variables_map)
if code is not None:
return self.response_error(330)
# Valid ports
variables_map, code = vip.valid_values_ports(variables_map)
if code is not None:
return self.response_error(331)
variables_map['maxcon'] = maxcon
vip.set_variables(variables_map)
vip.save(user, commit=True)
#update server pool limits table
#Fix #27
server_pools = ServerPool.objects.filter(vipporttopool__requisicao_vip=vip)
for sp in server_pools:
#If exists pool member, change default maxconn of pool and members
if(len(sp.serverpoolmember_set.all()) > 0):
#if(old_maxconn != sp.default_limit and sp.pool_created):
sp.default_limit = maxcon
sp.save(user, commit=True)
for serverpoolmember in sp.serverpoolmember_set.all():
serverpoolmember.limit = maxcon
serverpoolmember.save(user, commit=True)
# gerador_vips -i <ID_REQUISICAO> --maxconn
command = 'gerador_vips -i %d --maxconn' % vip.id
code, stdout, stderr = exec_script(command)
if code == 0:
success_map = dict()
success_map['codigo'] = '%04d' % code
success_map['descricao'] = {
'stdout': stdout, 'stderr': stderr}
map = dict()
map['sucesso'] = success_map
return self.response(dumps_networkapi(map))
else:
#TODO Check if is needed to update pool members separately
vip_old.save(user, commit=True)
for sp in server_pools_old:
sp.save(user, commit=True)
for spm in server_pools_members_old:
spm.save(user, commit=True)
return self.response_error(2, stdout + stderr)
except XMLError, x:
self.log.error(u'Error reading the XML request.')
return self.response_error(3, x)
开发者ID:marcelometal,项目名称:GloboNetworkAPI,代码行数:101,代码来源:RequestMaxconResource.py
注:本文中的networkapi.infrastructure.script_utils.exec_script函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论