How to use cmd method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

views.py

Source:views.py Github

copy

Full Screen

1import requests2from django.shortcuts import render, redirect, HttpResponse3from django.http import JsonResponse4from django.contrib.auth.decorators import login_required, user_passes_test5from django.contrib.auth import authenticate6from django.contrib.auth.models import User7from django.db.models import Count8from django.conf import settings9from auto_tl1.models import ServerTl1, GponDevice, LogTL1, UserActive, CmdTL1, Sto, LogApp10from auto_tl1.utils import render_to_pdf11from auto_tl1.serializers import GponSerializer12from socket import *13from datetime import datetime14from rest_framework.decorators import api_view15from rest_framework.response import Response16from rest_framework.views import APIView17import paramiko18import time19import xlwt20import platform21import os22import numpy as np23# Create your views here.+24def cek_level(request):25 if 'api_token' in request.session:26 if request.user.is_superuser == True:27 request.session['level'] = 'superadmin'28 elif request.user.is_staff == True:29 request.session['level'] = 'admin'30 else:31 request.session['level'] = 'user'32 if request.session.modified == False:33 del request.session['api_token']34 del request.session['toke_api']35 else:36 request.session['level'] = 'zero'37 return request.session['level']38def check_permissions(user):39 if user.is_staff is True or user.is_superuser is True:40 return True41 return False42def get_client_ip(request):43 X_FORWARDED_FOR = request.META.get('HTTP_X_FORWARDED_FOR')44 if X_FORWARDED_FOR:45 ip = X_FORWARDED_FOR.split(',')[0]46 else:47 ip = request.META.get('REMOTE_ADDR')48 return ip49def session_login(request):50 cek_level(request)51 sessionid = request.COOKIES[settings.SESSION_COOKIE_NAME]52 check_user_active = UserActive.objects.filter(sessionid=sessionid).count()53 if check_user_active > 0:54 user_active = UserActive.objects.get(sessionid=sessionid)55 user_active.ip_client = get_client_ip(request)56 user_active.level = request.session['level']57 user_active.save()58 else:59 UserActive.objects.create(sessionid=sessionid, username=request.user, ip_client=get_client_ip(request), level=request.session['level'], last_login=request.user.last_login)60 return cek_level(request)61@login_required(login_url=settings.URL_SEBELUM_LOGIN)62def index(request):63 if session_login(request) == 'zero':64 return redirect('login:formOtp')65 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))66 all_device = GponDevice.objects.all()67 fh_device = GponDevice.objects.select_related('ip_server').filter(ip_server__vendor="fh")68 zte_device = GponDevice.objects.select_related('ip_server').filter(ip_server__vendor="zte")69 hw_device = GponDevice.objects.select_related('ip_server').filter(ip_server__vendor="hw")70 dataLog = LogTL1.objects.all().order_by('-time')[:10]71 context = {72 'all_devices' : len(all_device),73 'fh_device' : len(fh_device),74 'zte_device' : len(zte_device),75 'hw_device': len(hw_device),76 'page_title' : 'Home',77 'vendors' : vendor,78 'last_event' : dataLog,79 'client_ip' : get_client_ip(request),80 }81 return render(request, 'home.html', context)82@login_required(login_url=settings.URL_SEBELUM_LOGIN)83def cekSN(request, cek_tipe, vendor_code):84 if session_login(request) == 'zero':85 return redirect('login:formOtp')86 if cek_tipe == 'unreg':87 page_title = 'Cek SN Unregister'88 elif cek_tipe == 'reg':89 page_title = 'Cek SN Register'90 elif cek_tipe == 'status':91 page_title = 'Cek Statu SN'92 elif cek_tipe == 'service':93 page_title = 'Cek Service ONT'94 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))95 server_tl1 = ServerTl1.objects.values('ip_server', 'name', 'id').filter(vendor=vendor_code).order_by('name')96 context = {97 'page_title' : page_title,98 'vendors' : vendor,99 'cek_tipe' : cek_tipe,100 'vendor_code' : vendor_code,101 'placeholder': 'contoh:\n172.x.x.x\n192.x.x.x\n10.x.x.x.x',102 'server_tl1': server_tl1,103 'client_ip': get_client_ip(request),104 }105 return render(request, 'formceksn.html', context)106@login_required(login_url=settings.URL_SEBELUM_LOGIN)107def cekUnregSN(request, vendor_code):108 if session_login(request) == 'zero':109 return redirect('login:formOtp')110 page_title = 'Cek SN Unregister'111 if request.is_ajax():112 tl1 = ServerTl1.objects.get(ip_server=request.POST['tl1_server'])113 ip_server = tl1.ip_server114 port_tl1 = tl1.port_tl1115 datas = []116 pesan_param = 'No Unregister ONU'117 ip_gpon = request.POST['ip_gpon'].splitlines()118 target = f'IP NMS: {ip_server}'119 logApp = logAppIn(request, page_title, target)120 if vendor_code == "fh" or vendor_code == "zte":121 # connect tl1 via socket122 s = socket(AF_INET, SOCK_STREAM)123 s.connect((ip_server, port_tl1))124 if vendor_code == "fh":125 # login tl1 fiberhome126 cmd_login = f'LOGIN:::CTAG::UN={tl1.user_tl1},PWD={tl1.pass_tl1};'127 s.send(cmd_login.encode())128 time.sleep(2)129 for ip in ip_gpon:130 log = LogTL1(target=ip, action=f"{page_title} FIBERHOME", command=ip, time=datetime.now(), status='In Progress', message='No Error', logapp=logApp)131 log.save()132 cmd = f'LST-UNREGONU::OLTID={ip}:CTAG::;'133 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param)134 if tl1_cmd['status'] == False:135 logAppFailed(logApp.id)136 return JsonResponse(137 {138 'status': tl1_cmd['status'],139 'data': tl1_cmd['data']140 }141 )142 s.send(b'LOGOUT:::CTAG::;')143 else:144 for ip in ip_gpon:145 log = LogTL1(target=ip, action=f"{page_title} ZTE", command=ip, time=datetime.now(), status='In Progress', message='No Error', logapp=logApp)146 log.save()147 cmd = f'LST-UNREGONU::OLTID={ip}:CTAG::;'148 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, pesan_param)149 if tl1_cmd['status'] == False:150 logAppFailed(logApp.id)151 152 return JsonResponse(153 {154 'status': tl1_cmd['status'],155 'data': tl1_cmd['data']156 }157 )158 s.close()159 request.session['hw'] = False160 else:161 user_name = tl1.user_tl1162 passwd = tl1.pass_tl1163 ip_server = tl1.ip_server164 ssh_client = paramiko.SSHClient()165 ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())166 ip_gpon = request.POST['ip_gpon'].splitlines()167 ssh_client.connect(hostname=ip_server, username=user_name, password=passwd, look_for_keys=False)168 cmd_gpon = f"""{user_name}169{passwd}170enable171scroll172config173display ont autofind all174quit175quit176y177"""178 for ip in ip_gpon:179 datas.append(f'HOST : {ip}')180 command = f"telnet {ip}"181 stdin, stdout, stderr = ssh_client.exec_command(command)182 time.sleep(1)183 log = LogTL1(target=ip, action=f"{page_title} HUAWEI", command=ip, time=datetime.now(), status='In Progress', message='No Error', logapp=logApp)184 log.save()185 stdin.write(cmd_gpon)186 hasil = stdout.read().decode()187 cmd_tl1 = CmdTL1(command_tl1='display ont autofind all', logtl1=log, result_tl1=hasil)188 cmd_tl1.save()189 datas.append(hasil)190 log = LogTL1.objects.get(pk=log.id)191 log.stoptime = datetime.now()192 if 'Failure: The automatically found ONTs do not exist' in hasil:193 status = 'Failed'194 pesan = 'No Unregister ONU'195 elif '%Error ' in hasil:196 status = 'Failed'197 pesan = 'IP GPON must vendor HUAWEI'198 log.status = status199 log.message = pesan200 log.save()201 logAppFailed(logApp.id)202 return JsonResponse(203 {204 'status': False,205 'data': pesan206 }207 )208 else:209 status = "Success"210 pesan = 'No Error'211 log.status = status212 log.message = pesan213 log.save()214 ssh_client.exec_command("logout")215 ssh_client.close()216 request.session['hw'] = True217 logAppSuccess(logApp.id)218 datas = '\n'.join(datas)219 request.session['hasil'] = datas220 return JsonResponse(221 {222 'status' : True,223 }224 )225@login_required(login_url=settings.URL_SEBELUM_LOGIN)226def cekRegSN(request, vendor_code):227 if session_login(request) == 'zero':228 return redirect('login:formOtp')229 page_title = 'Cek SN Register'230 if request.is_ajax():231 tl1 = ServerTl1.objects.get(ip_server=request.POST['tl1_server'])232 ip_server = tl1.ip_server233 port_tl1 = tl1.port_tl1234 datas = []235 pesan_param = 'No Register ONU'236 ip_gpon = request.POST['ip_gpon'].splitlines()237 target = f'IP NMS: {ip_server}'238 logApp = logAppIn(request, page_title, target)239 if vendor_code == "fh" or vendor_code == "zte":240 # connect tl1 via socket241 s = socket(AF_INET, SOCK_STREAM)242 s.connect((ip_server, port_tl1))243 if vendor_code == "fh":244 # login tl1 fiberhome245 cmd_login = f'LOGIN:::CTAG::UN={tl1.user_tl1},PWD={tl1.pass_tl1};'246 s.send(cmd_login.encode())247 time.sleep(2)248 for ips in ip_gpon:249 ip = ips.split(';')250 cmd = f'LST-ONU::OLTID={ip[0]}:CTAG::;'251 time_sleep = 7252 data_slot_port = ''253 if len(ip) > 1:254 cmd = f'LST-ONU::OLTID={ip[0]},PONID=1-1-{ip[1]}:CTAG::;'255 slot_port = ip[1].split('-')256 slot = slot_port[0]257 port = slot_port[1]258 data_slot_port = f', SLOT/PORT: {slot}/{port}'259 time_sleep = 1260 if len(ip) > 2:261 cmd = f'LST-ONU::OLTID={ip[0]},PONID=1-1-{ip[1]},ONUIDTYPE=MAC,ONUID={ip[2]}:CTAG::;'262 slot_port = ip[1].split('-')263 slot = slot_port[0]264 port = slot_port[1]265 data_slot_port = f', SLOT/PORT: {slot}/{port}, SN: {ip[2]}'266 time_sleep = 1267 log = LogTL1(target=f"IP GPON: {ip[0]}{data_slot_port}", action=f"{page_title} FIBERHOME", command=ips, time=datetime.now(), status='In Progress', message='No Error', logapp=logApp)268 log.save()269 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, time_sleep)270 if tl1_cmd['status'] == False:271 logAppFailed(logApp.id)272 return JsonResponse(273 {274 'status': tl1_cmd['status'],275 'data': tl1_cmd['data']276 }277 )278 s.send(b'LOGOUT:::CTAG::;')279 else:280 for ips in ip_gpon:281 ip = ips.split(';')282 cmd = f'LST-ONU::OLTID={ip[0]}:CTAG::;'283 data_slot_port = ''284 time_sleep = 7285 if len(ip) > 1:286 cmd = f'LST-ONU::OLTID={ip[0]},PONID=1-1-{ip[1]}:CTAG::;'287 slot_port = ip[1].split('-')288 slot = slot_port[0]289 port = slot_port[1]290 data_slot_port = f', SLOT/PORT: {slot}/{port}'291 time_sleep = 1292 if len(ip) > 2:293 cmd = f'LST-ONU::OLTID={ip[0]},PONID=1-1-{ip[1]},ONUIDTYPE=SN,ONUID={ip[2]}:CTAG::;'294 slot_port = ip[1].split('-')295 slot = slot_port[0]296 port = slot_port[1]297 data_slot_port = f', SLOT/PORT: {slot}/{port}, SN: {ip[2]}'298 time_sleep = 1299 log = LogTL1(target=f"IP GPON: {ip[0]}{data_slot_port}", action=f"{page_title} ZTE", command=ips, time=datetime.now(), status='In Progress', message='No Error', logapp=logApp)300 log.save()301 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, pesan_param, time_sleep)302 if tl1_cmd['status'] == False:303 logAppFailed(logApp.id)304 return JsonResponse(305 {306 'status': tl1_cmd['status'],307 'data': tl1_cmd['data']308 }309 )310 s.close()311 request.session['hw'] = False312 else:313 user_name = tl1.user_tl1314 passwd = tl1.pass_tl1315 ip_server = tl1.ip_server316 ssh_client = paramiko.SSHClient()317 ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())318 ip_gpon = request.POST['ip_gpon'].splitlines()319 ssh_client.connect(hostname=ip_server, username=user_name, password=passwd)320 for ips_gpon in ip_gpon:321 ip = ips_gpon.split(';')322 sn = ip[1]323 datas.append(f'HOST : {ip[0]}, SN : {sn}')324 command = f"telnet {ip[0]}"325 cmd_gpon = f"""{user_name}326{passwd}327enable328scroll329display ont info by-sn {sn}330quit331y332"""333 stdin, stdout, stderr = ssh_client.exec_command(command)334 time.sleep(1)335 log = LogTL1(target=f'IP GPON: {ip[0]}, SN: {sn}', action=f"{page_title} HUAWEI", command=ip, time=datetime.now(), status='In Progress', message='No Error', logapp=logApp)336 log.save()337 stdin.write(cmd_gpon)338 hasil = stdout.read().decode()339 cmd_tl1 = CmdTL1(command_tl1='display ont autofind all', logtl1=log, result_tl1=hasil)340 cmd_tl1.save()341 datas.append(hasil)342 log = LogTL1.objects.get(pk=log.id)343 log.stoptime = datetime.now()344 if 'The required ONT does not exist' in hasil:345 status = 'Failed'346 pesan = 'No Register ONU'347 elif 'Incomplete command, the error locates at' in hasil:348 status = 'Failed'349 pesan = 'Format is wrong'350 351 else:352 status = "Success"353 pesan = 'No Error'354 log.status = status355 log.message = pesan356 log.save()357 ssh_client.exec_command("logout")358 ssh_client.close()359 request.session['hw'] = True360 datas = '\n'.join(datas)361 request.session['hasil'] = datas362 logAppSuccess(logApp.id)363 return JsonResponse(364 {365 'status': True,366 }367 )368@login_required(login_url=settings.URL_SEBELUM_LOGIN)369def cekStatusSN(request, vendor_code):370 if session_login(request) == 'zero':371 return redirect('login:formOtp')372 page_title = 'Cek Status SN'373 if request.is_ajax():374 tl1 = ServerTl1.objects.get(ip_server=request.POST['tl1_server'])375 ip_server = tl1.ip_server376 port_tl1 = tl1.port_tl1377 datas = []378 pesan_param = 'Status ONU not found'379 ip_gpon = request.POST['ip_gpon'].splitlines()380 target = f'IP NMS: {ip_server}'381 logApp = logAppIn(request, page_title, target)382 if vendor_code == "fh" or vendor_code == "zte":383 # connect tl1 via socket384 s = socket(AF_INET, SOCK_STREAM)385 s.connect((ip_server, port_tl1))386 if vendor_code == "fh":387 # login tl1 fiberhome388 cmd_login = f'LOGIN:::CTAG::UN={tl1.user_tl1},PWD={tl1.pass_tl1};'389 s.send(cmd_login.encode())390 time.sleep(2)391 for ips in ip_gpon:392 ip = ips.split(';')393 cmd = f'LST-ONUSTATE::OLTID={ip[0]}:CTAG::;'394 data_slot_port = ''395 time_sleep = 7396 if len(ip) > 1:397 cmd = f'LST-ONUSTATE::OLTID={ip[0]},PONID=1-1-{ip[1]}:CTAG::;'398 slot_port = ip[1].split('-')399 slot = slot_port[0]400 port = slot_port[1]401 data_slot_port = f', SLOT/PORT: {slot}/{port}'402 time_sleep = 2403 if len(ip) > 2:404 cmd = f'LST-ONUSTATE::OLTID={ip[0]},PONID=1-1-{ip[1]},ONUIDTYPE=MAC,ONUID={ip[2]}:CTAG::;'405 slot_port = ip[1].split('-')406 slot = slot_port[0]407 port = slot_port[1]408 data_slot_port = f', SLOT/PORT: {slot}/{port}, SN: {ip[2]}'409 time_sleep = 2410 log = LogTL1(target=f"IP GPON: {ip[0]}{data_slot_port}", action=f"{page_title} FIBERHOME", command=ips, time=datetime.now(), status='In Progress', message='No Error', logapp=logApp)411 log.save()412 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, time_sleep)413 if tl1_cmd['status'] == False:414 logAppFailed(logApp.id)415 return JsonResponse(416 {417 'status': tl1_cmd['status'],418 'data': tl1_cmd['data']419 }420 )421 s.send(b'LOGOUT:::CTAG::;')422 else:423 for ips in ip_gpon:424 ip = ips.split(';')425 cmd = f'LST-ONUSTATE::OLTID={ip[0]}:CTAG::;'426 data_slot_port = ''427 time_sleep = 3428 if len(ip) > 1:429 cmd = f'LST-ONUSTATE::OLTID={ip[0]},PONID=1-1-{ip[1]}:CTAG::;'430 slot_port = ip[1].split('-')431 slot = slot_port[0]432 port = slot_port[1]433 data_slot_port = f', SLOT/PORT: {slot}/{port}'434 time_sleep = 2435 if len(ip) > 2:436 cmd = f'LST-ONUSTATE::OLTID={ip[0]},PONID=1-1-{ip[1]},ONUIDTYPE=SN,ONUID={ip[2]}:CTAG::;'437 slot_port = ip[1].split('-')438 slot = slot_port[0]439 port = slot_port[1]440 data_slot_port = f', SLOT/PORT: {slot}/{port}, SN: {ip[2]}'441 time_sleep = 3442 log = LogTL1(target=f"IP GPON: {ip[0]}{data_slot_port}", action=f"{page_title} ZTE", time=datetime.now(), command=ips, logapp=logApp)443 log.save()444 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, time_sleep)445 if tl1_cmd['status'] == False:446 logAppFailed(logApp.id)447 return JsonResponse(448 {449 'status': tl1_cmd['status'],450 'data': tl1_cmd['data']451 }452 )453 s.close()454 logAppSuccess(logApp.id)455 datas = '\n'.join(datas)456 request.session['hasil'] = datas457 request.session['hw'] = False458 return JsonResponse(459 {460 'status': True,461 }462 )463@login_required(login_url=settings.URL_SEBELUM_LOGIN)464def cekservice(request, vendor_code):465 if session_login(request) == 'zero':466 return redirect('login:formOtp')467 page_title = 'Cek Service'468 if request.is_ajax():469 tl1 = ServerTl1.objects.get(ip_server=request.POST['tl1_server'])470 ip_server = tl1.ip_server471 port_tl1 = tl1.port_tl1472 datas = []473 pesan_param = 'Service ONU does not exist'474 ip_gpon = request.POST['ip_gpon'].splitlines()475 target = f'IP NMS: {ip_server}'476 logApp = logAppIn(request, page_title, target)477 if vendor_code == "fh" or vendor_code == "zte":478 # connect tl1 via socket479 s = socket(AF_INET, SOCK_STREAM)480 s.connect((ip_server, port_tl1))481 if vendor_code == "fh":482 # login tl1 fiberhome483 cmd_login = f'LOGIN:::CTAG::UN={tl1.user_tl1},PWD={tl1.pass_tl1};'484 s.send(cmd_login.encode())485 time.sleep(2)486 for ips in ip_gpon:487 ip = ips.split(';')488 slot_port = ip[1].split('-')489 slot = slot_port[0]490 port = slot_port[1]491 datas.append(f"IP GPON: {ip[0]}, SLOT/PORT: {slot}/{port}, SN: {ip[2]}")492 log = LogTL1(target=f"IP GPON: {ip[0]}, SLOT/PORT: {slot}/{port}, SN: {ip[2]}", action=f"{page_title} FIBERHOME", time=datetime.now(), command=ips, status='In Progress', message='No Error', logapp=logApp)493 log.save()494 datas.append('Register ONT')495 cmd = f'LST-ONU::OLTID={ip[0]},PONID=1-1-{ip[1]},ONUIDTYPE=MAC,ONUID={ip[2]}:CTAG::;'496 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, 2)497 if tl1_cmd['status'] == False:498 logAppFailed(logApp.id)499 return JsonResponse(500 {501 'status': tl1_cmd['status'],502 'data': tl1_cmd['data']503 }504 )505 datas.append('Status ONT')506 cmd = f'LST-ONUSTATE::OLTID={ip[0]},PONID=1-1-{ip[1]},ONUIDTYPE=MAC,ONUID={ip[2]}:CTAG::;'507 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, 2)508 if tl1_cmd['status'] == False:509 logAppFailed(logApp.id)510 return JsonResponse(511 {512 'status': tl1_cmd['status'],513 'data': tl1_cmd['data']514 }515 )516 datas.append('Service Internet')517 cmd = f'LST-ONUWANSERVICECFG::OLTID={ip[0]},PONID=1-1-{ip[1]},ONUIDTYPE=MAC,ONUID={ip[2]}:CTAG::;'518 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, 2)519 if tl1_cmd['status'] == False:520 logAppFailed(logApp.id)521 return JsonResponse(522 {523 'status': tl1_cmd['status'],524 'data': tl1_cmd['data']525 }526 )527 datas.append('Service Voice')528 cmd = f'LST-POTS::OLTID={ip[0]},PONID=1-1-{ip[1]},ONUIDTYPE=MAC,ONUID={ip[2]}:CTAG::;'529 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, 2)530 if tl1_cmd['status'] == False:531 logAppFailed(logApp.id)532 533 return JsonResponse(534 {535 'status': tl1_cmd['status'],536 'data': tl1_cmd['data']537 }538 )539 cmd = f'LST-POTSINFO::OLTID={ip[0]},PONID=1-1-{ip[1]},ONUIDTYPE=MAC,ONUID={ip[2]}:CTAG::;'540 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, 2)541 if tl1_cmd['status'] == False:542 logAppFailed(logApp.id)543 544 return JsonResponse(545 {546 'status': tl1_cmd['status'],547 'data': tl1_cmd['data']548 }549 )550 datas.append('Service IPTV / WIFI / ASTINET / VPN')551 cmd = f'LST-PORTVLAN::OLTID={ip[0]},PONID=1-1-{ip[1]},ONUIDTYPE=MAC,ONUID={ip[2]}:CTAG::;'552 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, 2)553 if tl1_cmd['status'] == False:554 logAppFailed(logApp.id)555 556 return JsonResponse(557 {558 'status': tl1_cmd['status'],559 'data': tl1_cmd['data']560 }561 )562 s.send(b'LOGOUT:::CTAG::;')563 else:564 for ips in ip_gpon:565 ip = ips.split(';')566 slot_port = ip[1].split('-')567 slot = slot_port[0]568 port = slot_port[1]569 datas.append(f'IP GPON : {ip[0]}, SLOT/PORT : {slot}/{port}, SN ; {ip[2]}')570 log = LogTL1(target=f"IP GPON: {ip[0]}, SLOT/PORT: {slot}/{port}, SN: {ip[2]}", action=f"{page_title} ZTE", time=datetime.now(), command=ips, status='In Progress', message='No Error', logapp=logApp)571 log.save()572 datas.append('Register ONT')573 cmd = f'LST-ONU::OLTID={ip[0]},PONID=1-1-{ip[1]},ONUIDTYPE=SN,ONUID={ip[2]}:CTAG::;'574 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, 2)575 if tl1_cmd['status'] == False:576 logAppFailed(logApp.id)577 578 return JsonResponse(579 {580 'status': tl1_cmd['status'],581 'data': tl1_cmd['data']582 }583 )584 datas.append('Status ONT')585 cmd = f'LST-ONUSTATE::OLTID={ip[0]},PONID=1-1-{ip[1]},ONUIDTYPE=SN,ONUID={ip[2]}:CTAG::;'586 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, 2)587 if tl1_cmd['status'] == False:588 logAppFailed(logApp.id)589 590 return JsonResponse(591 {592 'status': tl1_cmd['status'],593 'data': tl1_cmd['data']594 }595 )596 datas.append('Service PORT')597 cmd = f'LST-SERVICEPORT::DID={ip[0]},OID={ip[2]}:CTAG::;'598 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, 2)599 if tl1_cmd['status'] == False:600 logAppFailed(logApp.id)601 602 return JsonResponse(603 {604 'status': tl1_cmd['status'],605 'data': tl1_cmd['data']606 }607 )608 datas.append('Service Internet')609 cmd = f'LST-ONUWANIP::DID={ip[0]},OID={ip[2]}:CTAG::;'610 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, 2)611 if tl1_cmd['status'] == False:612 logAppFailed(logApp.id)613 614 return JsonResponse(615 {616 'status': tl1_cmd['status'],617 'data': tl1_cmd['data']618 }619 )620 datas.append('Service Voice')621 cmd = f'LST-POTSINFO::OLTID={ip[0]},PONID=1-1-{ip[1]},ONUIDTYPE=MAC,ONUID={ip[2]},ONUPORT=1-1-1-1:CTAG::;'622 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, 2)623 if tl1_cmd['status'] == False:624 logAppFailed(logApp.id)625 return JsonResponse(626 {627 'status': tl1_cmd['status'],628 'data': tl1_cmd['data']629 }630 )631 datas.append('Service Port Vlan')632 cmd = f'LST-PORTVLAN::OLTID={ip[0]},PONID=1-1-{ip[1]},ONUIDTYPE=MAC,ONUID={ip[2]}:CTAG::;'633 tl1_cmd = tl1_command(s, cmd, datas, log, log.id, False, pesan_param, 2)634 if tl1_cmd['status'] == False:635 logAppFailed(logApp.id)636 637 return JsonResponse(638 {639 'status': tl1_cmd['status'],640 'data': tl1_cmd['data']641 }642 )643 s.close()644 request.session['hw'] = False645 else:646 user_name = tl1.user_tl1647 passwd = tl1.pass_tl1648 ip_server = tl1.ip_server649 ssh_client = paramiko.SSHClient()650 ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())651 ssh_client.connect(hostname=ip_server, username=user_name, password=passwd)652 for ips_gpon in ip_gpon:653 ip = ips_gpon.split(';')654 sp = ip[1].split('-')655 slot = sp[0]656 port = sp[1]657 onu_id = ip[2]658 datas.append(f'HOST: {ip[0]}, SLOT/PORT: {slot}/{port}, ONU ID: {onu_id}')659 command = f"telnet {ip[0]}"660 cmd_gpon = f"""{tl1.user_tl1}661{tl1.pass_tl1}662enable663scroll664config665display service-port port 0/{slot}/{port} ont {onu_id}666display ont wan-info 0/{slot} {port} {onu_id}667interface gpon 0/{slot}668display ont port state {port} {onu_id} pots-port all669quit670quit671quit672y673"""674 stdin, stdout, stderr = ssh_client.exec_command(command)675 time.sleep(1)676 log = LogTL1(target=f'IP GPON: {ip[0]}, SLOT/PORT: {slot}/{port}, ONU ID: {onu_id}', action=f"{page_title} HUAWEI", command=ip, time=datetime.now(), status='In Progress', message='No Error', logapp=logApp)677 log.save()678 stdin.write(cmd_gpon)679 hasil = stdout.read().decode()680 if 'The required ONT does not exist' in hasil:681 status = 'Failed'682 pesan = 'No Unregister ONU'683 elif 'Incomplete command, the error locates at' in hasil:684 status = 'Failed'685 pesan = 'Format is wrong'686 else:687 status = "Success"688 pesan = 'No Error'689 cmd_tl1 = CmdTL1(command_tl1='display ont autofind all', logtl1=log, result_tl1=hasil)690 cmd_tl1.save()691 datas.append(hasil)692 log = LogTL1.objects.get(pk=log.id)693 log.stoptime = datetime.now()694 log.status = status695 log.message = pesan696 log.save()697 ssh_client.exec_command("logout")698 ssh_client.close()699 request.session['hw'] = True700 logAppSuccess(logApp.id)701 datas = '\n'.join(datas)702 request.session['hasil'] = datas703 return JsonResponse(704 {705 'status': True,706 }707 )708@login_required(login_url=settings.URL_SEBELUM_LOGIN)709@user_passes_test(check_permissions)710def wifiService(request, vendor_code):711 if session_login(request) == 'zero':712 return redirect('login:formOtp')713 page_title = 'Wifi Service'714 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))715 if request.is_ajax():716 s = socket(AF_INET, SOCK_STREAM)717 tl1 = ServerTl1.objects.get(vendor=vendor_code, server_gpon__ip_gpon=request.POST['ip_gpon'])718 ip_server = tl1.ip_server719 port_tl1 = tl1.port_tl1720 s.connect((ip_server, port_tl1))721 datas = []722 cmd_login = f'LOGIN:::CTAG::UN={tl1.user_tl1},PWD={tl1.pass_tl1};'723 s.send(cmd_login.encode())724 time.sleep(2)725 s.recv(80000).decode()726 ip_gpon = request.POST['ip_gpon']727 slot = request.POST['slot']728 port = request.POST['port']729 sn = request.POST['sn']730 status_code = False731 target = f'IP NMS: {ip_server}, IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}'732 logApp = logAppIn(request, page_title, target)733 if 'cek_WIFI' in request.POST:734 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"{page_title} FIBERHOME", time=datetime.now(), command='No Command', status='In Progress', message='No Error', logapp=logApp)735 log.save()736 cmd = f'LST-WIFISERVICE::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn}:CTAG::;'737 s.send(cmd.encode())738 time.sleep(2)739 data_recv = s.recv(80000).decode()740 begin_word = data_recv.find('ENDESC=No error ;') + 1741 cmd_tl1 = CmdTL1(command_tl1=cmd, logtl1=log, result_tl1=data_recv[begin_word:])742 cmd_tl1.save()743 if 'block_records=1' in data_recv:744 status = "Success"745 pesan = 'No Error'746 status_code = True747 begin_word = data_recv.find('List of Onu')748 datas.append(data_recv[begin_word:])749 elif 'EADD=object not exist, please check' in data_recv:750 status = 'Failed'751 status_code = False752 pesan = 'ONU does not exist'753 datas = pesan754 logAppFailed(logApp.id)755 elif 'ENDESC=invalid parameter format' in data_recv:756 status = 'Failed'757 status_code = False758 pesan = 'IP GPON does not exist'759 datas = pesan760 logAppFailed(logApp.id)761 else:762 status = 'Failed'763 status_code = False764 pesan = 'There is error'765 datas = pesan766 log = LogTL1.objects.get(pk=log.id)767 log.stoptime = datetime.now()768 log.status = status769 log.message = pesan770 log.save()771 if 'ubah_WIFI' in request.POST:772 SSID = request.POST['SSID']773 nama_SSID = request.POST['nama_SSID']774 ssid_AUTH = request.POST['ssid_AUTH']775 ssid_Encryptype = request.POST['ssid_Encryptype']776 wifi_ENABLE = request.POST['wifi_ENABLE']777 ssid_ENABLE = request.POST['ssid_ENABLE']778 hidden_ENABLE = request.POST['hidden_ENABLE']779 pass_SSID = request.POST['pass_SSID']780 config_SSID = request.POST['config_SSID']781 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"{page_title} FIBERHOME", time=datetime.now(), command='No Command', status='In Progress', message='No Error', logapp=logApp)782 log.save()783 if config_SSID == 'Modify':784 cmd = f'MODIFY-WIFISERVICE::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn}:CTAG::ENABLE={wifi_ENABLE},WILESS-STANDARD=802.11bgn,WORKING-FREQUENCY=2.4GHZ,FREQUENCY-BANDWIDTH=20/40MHZ,WILESS-AREA=0,WILESS-CHANNEL=0,T-POWER=100,SSID={SSID},SSID-ENABLE={ssid_ENABLE},SSID-NAME={nama_SSID},SSID-VISIBALE={hidden_ENABLE},AUTH-MODE={ssid_AUTH},ENCRYP-TYPE={ssid_Encryptype},PRESHARED-KEY={pass_SSID},UPDATEKEY-INTERVAL=0;'785 else:786 cmd = f'CFG-WIFISERVICE::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn}:CTAG::ENABLE={wifi_ENABLE},WILESS-STANDARD=802.11bgn,WORKING-FREQUENCY=2.4GHZ,FREQUENCY-BANDWIDTH=20/40MHZ,WILESS-AREA=0,WILESS-CHANNEL=0,T-POWER=100,SSID={SSID},SSID-ENABLE={ssid_ENABLE},SSID-NAME={nama_SSID},SSID-VISIBALE={hidden_ENABLE},AUTH-MODE={ssid_AUTH},ENCRYP-TYPE={ssid_Encryptype},PRESHARED-KEY={pass_SSID};'787 s.send(cmd.encode())788 time.sleep(2)789 data_recv = s.recv(80000).decode()790 begin_word = data_recv.find('ENDESC=No error ;') + 1791 cmd_tl1 = CmdTL1(command_tl1=cmd, logtl1=log, result_tl1=data_recv[begin_word:])792 cmd_tl1.save()793 if 'ENDESC=No error' in data_recv:794 status = "Success"795 status_code = True796 pesan = 'Success Configure Wifi'797 datas = pesan798 elif 'EADD=object not exist, please check' in data_recv:799 status = 'Failed'800 status_code = False801 pesan = 'ONU does not exist'802 datas = pesan803 logAppFailed(logApp.id)804 elif 'ENDESC=invalid parameter format' in data_recv:805 status = 'Failed'806 status_code = False807 pesan = 'IP GPON does not exist'808 datas = pesan809 logAppFailed(logApp.id)810 else:811 status = 'Failed'812 status_code = False813 pesan = 'There is error'814 datas = pesan815 logAppFailed(logApp.id)816 log = LogTL1.objects.get(pk=log.id)817 log.stoptime = datetime.now()818 log.status = status819 log.message = pesan820 log.save()821 s.close()822 logAppSuccess(logApp.id)823 return JsonResponse(824 {825 'status': status_code,826 'data' : datas827 }828 )829 else:830 sto = Sto.objects.order_by('sto_code').annotate(scount=Count('sto_code')).filter(sto_gpon__ip_server__vendor=vendor_code)831 vendor_name = vendor_code832 context = {833 'page_title': page_title,834 'vendors': vendor,835 'vendor_name': vendor_name,836 'stos' : sto,837 'client_ip': get_client_ip(request),838 }839 return render(request, 'wifiservice.html', context)840@login_required(login_url=settings.URL_SEBELUM_LOGIN)841@user_passes_test(check_permissions)842def cekSto(request):843 if request.is_ajax():844 gpon = GponDevice.objects.filter(sto__sto_code=request.POST['sto'], ip_server__vendor=request.POST['vendor'])845 if gpon.count() > 0:846 status = True847 gpon_serial = GponSerializer(gpon, many=True)848 else:849 status = False850 gpon_serial = None851 data = {852 'status_code': status,853 'data': gpon_serial.data854 }855 return JsonResponse(data, safe=False)856@login_required(login_url=settings.URL_SEBELUM_LOGIN)857def sop(request, sop_tipe):858 if session_login(request) == 'zero':859 return redirect('login:formOtp')860 if sop_tipe == "configbatch":861 placeholder = "Contoh Fiberhome :\n"862 placeholder += "=====CREATE ONT==========\n"863 placeholder += "ont|fh|172.29.215.6|6-6|FHTT06138248\n"864 placeholder += "ont|fh|172.29.215.6|6-6|FHTT06138248|HG6243C\n"865 placeholder += "ont|fh|172.29.215.6|6-6|FHTT06138248|HG6243C|{NAMA_PELANGGAN}\n"866 placeholder += "=====CREATE INTERNET==========\n"867 placeholder += "other|fh|172.29.215.6|6-6|FHTT06138248;INET|1904|131626153157@telkom.net|707341163\n"868 placeholder += "other|fh|172.29.215.6|6-6|FHTT06138248;INET|1904|131626153157@telkom.net|707341163|1536K|15360K\n"869 placeholder += "=====CREATE VOICE==========\n"870 placeholder += "other|fh|172.29.215.6|6-6|FHTT06138248;VOICE|532|+622666221191|190718488\n"871 placeholder += "=====CREATE IPTV==========\n"872 placeholder += "other|fh|172.29.215.6|6-6|FHTT06138248;IPTV\n"873 placeholder += "=====CREATE 3P/2P/1P + ONT==========\n"874 placeholder += "ont|fh|172.29.215.6|6-6|FHTT06138248|HG6243C|NAMA_PELANGGAN;INET|1904|131626153157@telkom.net|707341163|1536K|15360K;VOICE|532|+622666221191|190718488;IPTV\n"875 placeholder += "\n"876 placeholder += "\n"877 placeholder += "Contoh ZTE :\n"878 placeholder += "=====CREATE ONT==========\n"879 placeholder += "ont|zte|172.21.202.4|12-2|ZTEGC6753017\n"880 placeholder += "ont|zte|172.21.202.4|12-2|ZTEGC6753017|ZTEG-F609\n"881 placeholder += "ont|zte|172.21.202.4|12-2|ZTEGC6753017|ZTEG-F609|NAMA_PELANGGAN\n"882 placeholder += "=====CREATE INTERNET==========\n"883 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;INET|770|131626153157@telkom.net|707341163|\n"884 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;INET|770|131626153157@telkom.net|707341163|{vport}\n"885 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;INET|770|131626153157@telkom.net|707341163|{vport}|1536K|15360K\n"886 placeholder += "=====CREATE VOICE==========\n"887 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;VOICE|571|+622667121278|9866556\n"888 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;VOICE|571|+622667121278|9866556|{vport}\n"889 placeholder += "=====CREATE IPTV==========\n"890 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;IPTV\n"891 placeholder += "=====CREATE 3P/2P/1P + ONT==========\n"892 placeholder += "ont|zte|172.21.202.4|12-2|ZTEGC6753017|ZTEG-F609|NAMA_PELANGGAN;INET|770|131626153157@telkom.net|707341163|1|1536K|15360K;VOICE|571|+622667121278|9866556|2;IPTV\n"893 else:894 placeholder = "Contoh Fiberhome :\n"895 placeholder += "=====DELETE ONT==========\n"896 placeholder += "ont|fh|172.29.215.6|6-6|FHTT06138248\n"897 placeholder += "=====DELETE INTERNET==========\n"898 placeholder += "other|fh|172.29.215.6|6-6|FHTT06138248;INET|1904\n"899 placeholder += "=====DELETE VOICE==========\n"900 placeholder += "other|fh|172.29.215.6|6-6|FHTT06138248;VOICE\n"901 placeholder += "=====DELETE IPTV==========\n"902 placeholder += "other|fh|172.29.215.6|6-6|FHTT06138248;IPTV\n"903 placeholder += "\n"904 placeholder += "\n"905 placeholder += "Contoh ZTE :\n"906 placeholder += "=====DELETE ONT==========\n"907 placeholder += "ont|zte|172.21.202.4|12-2|ZTEGC6753017\n"908 placeholder += "=====CREATE INTERNET==========\n"909 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;INET|770\n"910 placeholder += "=====CREATE VOICE==========\n"911 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;VOICE|571\n"912 placeholder += "=====CREATE IPTV==========\n"913 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;IPTV\n"914 datas = placeholder.splitlines()915 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))916 context = {917 'page_title' : 'SOP',918 'datas' : datas,919 'vendors' : vendor,920 'client_ip': get_client_ip(request),921 }922 return render(request, 'sop.html', context)923@login_required(login_url=settings.URL_SEBELUM_LOGIN)924@user_passes_test(check_permissions)925def config_gui(request, vendor_code):926 if session_login(request) == 'zero':927 return redirect('login:formOtp')928 page_title = "CEK ONT"929 if request.method == 'POST':930 if request.is_ajax():931 s = socket(AF_INET, SOCK_STREAM)932 tl1 = ServerTl1.objects.get(vendor=vendor_code, server_gpon__ip_gpon=request.POST['ip_gpon'])933 ip_server = tl1.ip_server934 port_tl1 = tl1.port_tl1935 s.connect((ip_server, port_tl1))936 cmd_login = f'LOGIN:::CTAG::UN={tl1.user_tl1},PWD={tl1.pass_tl1};'937 s.send(cmd_login.encode())938 time.sleep(2)939 s.recv(80000).decode()940 ip_gpon = request.POST['ip_gpon']941 slot = request.POST['slot']942 port = request.POST['port']943 sn = request.POST['sn']944 target = f'IP NMS: {ip_server}, IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}'945 logApp = logAppIn(request, page_title, target)946 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Cek SN FIBERHOME", time=datetime.now(), command='No Command', username=request.user, status='In Progress', message='No Error', logapp=logApp)947 log.save()948 cmd = f'LST-ONU::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn}:CTAG::;'949 s.send(cmd.encode())950 time.sleep(2)951 data_recv = s.recv(80000).decode()952 cmd_tl1 = CmdTL1(command_tl1=cmd, logtl1=log, result_tl1=data_recv)953 cmd_tl1.save()954 if 'block_records=1' in data_recv or 'totalrecord=1' in data_recv:955 status = "Success"956 pesan = 'ONU already exist'957 status_code = True958 datas = pesan959 logAppFailed(logApp.id)960 elif 'EADD=object not exist, please check' in data_recv or 'ENDESC=device does not exist (the onu does not exist)' in data_recv:961 status = 'Failed'962 status_code = False963 pesan = 'ONU does not exist'964 datas = pesan965 logAppFailed(logApp.id)966 elif 'ENDESC=invalid parameter format' in data_recv:967 status = 'Failed'968 status_code = False969 pesan = 'IP GPON does not exist'970 datas = pesan971 logAppFailed(logApp.id)972 else:973 status = 'Failed'974 status_code = False975 pesan = 'There is error'976 datas = pesan977 logAppFailed(logApp.id)978 log = LogTL1.objects.get(pk=log.id)979 log.stoptime = datetime.now()980 log.status = status981 log.message = pesan982 log.save()983 s.close()984 logAppSuccess(logApp.id)985 return JsonResponse(986 {987 'status': status_code,988 'data': datas989 }990 )991 else:992 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))993 sto = Sto.objects.order_by('sto_code').annotate(scount=Count('sto_code')).filter(sto_gpon__ip_server__vendor=vendor_code)994 if vendor_code == 'zte':995 tipe_ont = {996 'ZTEG-F660' : 'ZXHN_F660',997 'ZTEG-F609' : 'ZXHN_F609',998 'ZTEG-F670': 'ZXHN_F670',999 }1000 else:1001 tipe_ont = {1002 'AN5506-04-F1' : 'AN5506-04-F1',1003 'HG6243C' : 'HG6243C',1004 }1005 context = {1006 'page_title': 'CONFIG GUI',1007 'vendor_name' : vendor_code,1008 'vendors': vendor,1009 'stos' : sto,1010 'tipe_ont' : tipe_ont,1011 'client_ip': get_client_ip(request),1012 }1013 return render(request, 'config_vendor.html', context)1014def logAppIn(request, action, target):1015 logApp = LogApp(status='In Progress', time=datetime.now(), ip_client=get_client_ip(request), username=request.user, action=action, target=target)1016 logApp.save();1017 return logApp1018def logAppFailed(logAppId):1019 logAppFailed = LogApp.objects.get(pk=logAppId)1020 logAppFailed.status = "Failed"1021 logAppFailed.stoptime = datetime.now()1022 logAppFailed.save()1023def logAppSuccess(logAppId):1024 logAppSuccess = LogApp.objects.get(pk=logAppId)1025 logAppSuccess.status = "Success"1026 logAppSuccess.stoptime = datetime.now()1027 logAppSuccess.save()1028def save_log(log_id, status, pesan):1029 log = LogTL1.objects.get(pk=log_id)1030 log.stoptime = datetime.now()1031 log.status = status1032 log.message = pesan1033 log.save()1034def list_error_cek(log_id, data_recv, param_pesan):1035 if 'block_records=0' in data_recv or 'totalrecord=0' in data_recv or 'ENDESC=device does not exist (the onu does not exist)' in data_recv:1036 status = 'Failed'1037 status_array = True1038 pesan = param_pesan1039 else:1040 status_array = False1041 if 'EADD=object not exist, please check' in data_recv:1042 status = 'Failed'1043 pesan = 'ONU does not exist'1044 elif 'ENDESC=resource does not exist (NE topo node)' in data_recv:1045 status = 'Failed'1046 pesan = 'IP GPON does not exist'1047 elif 'ENDESC=invalid parameter format' in data_recv or 'INVALID SYNTAX OR PUNCTUATION' in data_recv or 'ILLEGAL COMMAND CODE' in data_recv or 'ENDESC=exception happensjava.lang.NullPointerException' in data_recv:1048 status = 'Failed'1049 pesan = 'There is something went wrong'1050 else:1051 status = 'Success'1052 status_array = True1053 pesan = 'No Error'1054 save_log(log_id, status, pesan)1055 return {1056 'status': status_array,1057 'data': pesan1058 }1059def list_error(log_id, data_recv):1060 status = 'Failed'1061 status_array = False1062 if 'ENDESC=No error' in data_recv or 'ENDESC=No Error' in data_recv:1063 status = "Success"1064 status_array = True1065 pesan = 'No Error'1066 elif 'EADD=object not exist, please check' in data_recv or 'ENDESC=resource does not exist (ONU)' in data_recv:1067 pesan = 'ONU does not exist'1068 elif 'ENDESC=invalid parameter format' in data_recv or 'ENDESC=device does not exist' in data_recv:1069 pesan = 'IP GPON does not exist'1070 elif 'INVALID SYNTAX OR PUNCTUATION' in data_recv or 'ILLEGAL COMMAND CODE' in data_recv or 'ENDESC=exception happensjava.lang.NullPointerException' in data_recv:1071 pesan = 'Format is Wrong'1072 elif 'EADD=onu already exist' in data_recv or 'ENDESC=device operation failed (GPON ONU sn already exists.)' in data_recv:1073 pesan = 'ONU already exist'1074 elif 'EADD=service not exist' in data_recv:1075 pesan = 'Service not exist'1076 elif 'ENDESC=resource conflicts (NAME)' in data_recv:1077 pesan = 'ONU name already exist'1078 elif 'EADD=server check input parameter error' in data_recv:1079 pesan = 'Bandwith profile does not exist'1080 elif 'EADD=service already exist' in data_recv:1081 pesan = 'Service already exist'1082 elif 'ENDESC=device operation failed (T-CONT name already exists.)' in data_recv:1083 pesan = 'Service Port already exist'1084 elif 'ENDESC=resource does not exist (traffic profile)' in data_recv:1085 pesan = 'Upload profile does not exist'1086 elif 'ENDESC=resource does not exist (bandwidth profile)' in data_recv:1087 pesan = 'Download profile does not exist'1088 elif 'EADD=NGN User Data UserIndex Repeat' in data_recv:1089 pesan = 'Voice already exist'1090 elif 'EADD=ngnvlan is not defined, please check' in data_recv:1091 pesan = 'Vlan voice does not exist'1092 elif 'EADD=Can`t config the same VID when the connect type is the same' in data_recv or 'EADD=only one INTERNET mode wanservice could be set on one port' in data_recv:1093 pesan = 'Wan COS must be set same with NMS'1094 else:1095 pesan = 'There is something wrong'1096 save_log(log_id, status, pesan)1097 return {1098 'status': status_array,1099 'data': pesan1100 }1101def tl1_command(sockets, cmd, datas, log, log_id, cek = True, param_pesan='', time_sleep=2):1102 save_log(log_id, 'Progress', 'No Error')1103 sockets.send(cmd.encode())1104 time.sleep(time_sleep)1105 data_recv = sockets.recv(128000000).decode()1106 cmd_tl1 = CmdTL1(command_tl1=cmd, logtl1=log, result_tl1=data_recv)1107 cmd_tl1.save()1108 datas.append(cmd)1109 datas.append(data_recv)1110 if cek == True:1111 ls_err = list_error(log_id, data_recv)1112 else:1113 ls_err = list_error_cek(log_id, data_recv, param_pesan)1114 return ls_err1115@login_required(login_url=settings.URL_SEBELUM_LOGIN)1116@user_passes_test(check_permissions)1117def config(request, vendor_code):1118 if request.is_ajax():1119 if session_login(request) == 'zero':1120 return redirect('login:formOtp')1121 if 'ip_gpon' not in request.POST:1122 return JsonResponse(1123 {1124 'status' : False,1125 'data' : 'IP GPON does not exist!!!'1126 }1127 )1128 page_title = "CONFIG GUI"1129 tl1 = ServerTl1.objects.get(vendor=vendor_code, server_gpon__ip_gpon=request.POST['ip_gpon'])1130 ip_server = tl1.ip_server1131 port_tl1 = tl1.port_tl11132 s = socket(AF_INET, SOCK_STREAM)1133 datas = []1134 ip_gpon = request.POST['ip_gpon']1135 slot = request.POST['slot']1136 port = request.POST['port']1137 tipe_ont = request.POST['tipe_ont']1138 sn = request.POST['sn']1139 nama_pel = request.POST['nama_pel']1140 create_ont = request.POST['create_ont']1141 action = request.POST['action']1142 services = request.POST.getlist('service_name')1143 target = f'IP NMS: {ip_server}, IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}'1144 logApp = logAppIn(request, page_title, target)1145 if vendor_code == 'fh':1146 vendor_name = "FIBERHOME"1147 s.connect((ip_server, port_tl1))1148 cmd_login = f'LOGIN:::CTAG::UN={tl1.user_tl1},PWD={tl1.pass_tl1};'1149 s.send(cmd_login.encode())1150 time.sleep(2)1151 data = s.recv(80000)1152 datas.append(data.decode())1153 if nama_pel == "":1154 cmd_create_ont = f'ADD-ONU::OLTID={ip_gpon},PONID=1-1-{slot}-{port}:5::AUTHTYPE=MAC,ONUID={sn},ONUTYPE={tipe_ont};'1155 else:1156 cmd_create_ont = f'ADD-ONU::OLTID={ip_gpon},PONID=1-1-{slot}-{port}:5::AUTHTYPE=MAC,ONUID={sn},ONUTYPE={tipe_ont},NAME={nama_pel} | {sn};'1157 cmd_delete_ont = f'DEL-ONU::OLTID={ip_gpon},PONID=1-1-{slot}-{port}:5::ONUIDTYPE=MAC,ONUID={sn};'1158 else:1159 vendor_name = "ZTE"1160 s.connect((ip_server, port_tl1))1161 if nama_pel == "":1162 cmd_create_ont = f'ADD-ONU::OLTID={ip_gpon},PONID=1-1-{slot}-{port}:5::AUTHTYPE=SN,ONUID={sn},ONUTYPE={tipe_ont};'1163 else:1164 cmd_create_ont = f'ADD-ONU::OLTID={ip_gpon},PONID=1-1-{slot}-{port}:5::AUTHTYPE=SN,ONUID={sn},ONUTYPE={tipe_ont},NAME={nama_pel}|{sn};'1165 cmd_delete_ont = f'DEL-ONU::OLTID={ip_gpon},PONID=1-1-{slot}-{port}:5::ONUIDTYPE=SN,ONUID={sn};'1166 command = f'ont|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn}|{tipe_ont}'1167 if create_ont == "Create ONT" and action == "Config" :1168 datas.append('###################CREATE ONT###################')1169 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Register ONT {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1170 log.save()1171 tl1_cmd = tl1_command(s, cmd_create_ont, datas, log, log.id)1172 if tl1_cmd['status'] == False:1173 logAppFailed(logApp.id)1174 1175 return JsonResponse(1176 {1177 'status' : tl1_cmd['status'],1178 'data' : tl1_cmd['data']1179 }1180 )1181 elif create_ont == "Create ONT" and action == "Delete" :1182 datas.append('###################DELETE ONT###################')1183 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Delete ONT {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1184 log.save()1185 tl1_cmd = tl1_command(s, cmd_delete_ont, datas, log, log.id)1186 if tl1_cmd['status'] == False:1187 logAppFailed(logApp.id)1188 1189 return JsonResponse(1190 {1191 'status' : tl1_cmd['status'],1192 'data' : tl1_cmd['data']1193 }1194 )1195 if action == "Config" :1196 for service in services:1197 if service == "IPTV":1198 lan_IPTV = request.POST.getlist('lan_IPTV')1199 lan_CMD = ''1200 datas.append(f'###################Configure {service}###################')1201 for lan in lan_IPTV:1202 lan_CMD += f'-{lan}'1203 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};iptv|{lan_CMD[1:]}'1204 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Configure IPTV {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1205 log.save()1206 if vendor_code == "fh":1207 for lan in lan_IPTV:1208 cmd = f'ADD-LANIPTVPORT::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn},ONUPORT=1-1-1-{lan}:5::MVLAN=110,MCOS=4;'1209 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1210 if tl1_cmd['status'] == False:1211 logAppFailed(logApp.id)1212 1213 return JsonResponse(1214 {1215 'status' : tl1_cmd['status'],1216 'data' : tl1_cmd['data']1217 }1218 )1219 cmd = f'CFG-LANPORTVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn},ONUPORT=1-1-1-{lan}:5::CVLAN=111,CCOS=4;'1220 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1221 if tl1_cmd['status'] == False:1222 logAppFailed(logApp.id)1223 1224 return JsonResponse(1225 {1226 'status' : tl1_cmd['status'],1227 'data' : tl1_cmd['data']1228 }1229 )1230 cmd = f'CFG-LANPORT::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn},ONUPORT=1-1-1-{lan}:5::BW=DOWN8MKA4_UP2253KA4;'1231 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1232 if tl1_cmd['status'] == False:1233 logAppFailed(logApp.id)1234 1235 return JsonResponse(1236 {1237 'status' : tl1_cmd['status'],1238 'data' : tl1_cmd['data']1239 }1240 )1241 else:1242 cmd = f'ADD-PONVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::CVLAN=111,UV=111,SERVICENAME=USEETV;'1243 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1244 if tl1_cmd['status'] == False:1245 logAppFailed(logApp.id)1246 1247 return JsonResponse(1248 {1249 'status' : tl1_cmd['status'],1250 'data' : tl1_cmd['data']1251 }1252 )1253 cmd = f'CFG-ONUBW::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::UPBW=UP-2253KA4,DOWNBW=DOWN-9012KA4,SERVICENAME=USEETV;'1254 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1255 if tl1_cmd['status'] == False:1256 logAppFailed(logApp.id)1257 1258 return JsonResponse(1259 {1260 'status' : tl1_cmd['status'],1261 'data' : tl1_cmd['data']1262 }1263 )1264 for lan in lan_IPTV:1265 cmd = f'ADD-LANIPTVPORT::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn},ONUPORT=1-1-1-{lan}:5::MVLAN=110,SERVICENAME=USEETV;'1266 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1267 if tl1_cmd['status'] == False:1268 logAppFailed(logApp.id)1269 1270 return JsonResponse(1271 {1272 'status' : tl1_cmd['status'],1273 'data' : tl1_cmd['data']1274 }1275 )1276 cmd = f'CFG-LANPORT::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn},ONUPORT=1-1-1-{lan}:5::VLANMOD=Hybrid,PVID=111;'1277 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1278 if tl1_cmd['status'] == False:1279 logAppFailed(logApp.id)1280 1281 return JsonResponse(1282 {1283 'status' : tl1_cmd['status'],1284 'data' : tl1_cmd['data']1285 }1286 )1287 cmd = f'CHG-ONUUNI-PON::DID={ip_gpon},OID={sn},ONUPORT={lan}:5::IPRETRIEVEMODE=FromNetwork;'1288 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1289 if tl1_cmd['status'] == False:1290 logAppFailed(logApp.id)1291 1292 return JsonResponse(1293 {1294 'status' : tl1_cmd['status'],1295 'data' : tl1_cmd['data']1296 }1297 )1298 if service == "VOICE":1299 vlan_VOICE = request.POST['vlan_VOICE']1300 pots = request.POST['lan_VOICE']1301 vport_VOICE = request.POST['vport_VOICE'] if 'vport_VOICE' in request.POST else ''1302 bw_up_VOICE = request.POST['bw_up_VOICE']1303 bw_down_VOICE = request.POST['bw_down_VOICE']1304 user_VOICE_split = request.POST['user_accout_VOICE'].split('@')1305 user_VOICE = user_VOICE_split[0]1306 domain_VOICE = user_VOICE_split[1]1307 pass_VOICE = request.POST['pass_accout_VOICE']1308 datas.append(f'###################Configure {service}###################')1309 if vendor_code == "fh":1310 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};voice|{vlan_VOICE}|{user_VOICE}@{domain_VOICE}|{pass_VOICE}'1311 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Configure {service} {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1312 log.save()1313 cmd = f'CFG-VOIPSERVICE::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn},ONUPORT=1-1-1-{pots}:5::PHONENUMBER={user_VOICE},PT=SIP,VOIPVLAN={vlan_VOICE},SCOS=7,EID=@{domain_VOICE},SIPUSERNAME={user_VOICE},SIPUSERPWD={pass_VOICE},IPMODE=DHCP;'1314 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1315 if tl1_cmd['status'] == False:1316 logAppFailed(logApp.id)1317 1318 return JsonResponse(1319 {1320 'status': tl1_cmd['status'],1321 'data': tl1_cmd['data']1322 }1323 )1324 else:1325 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};voice|{vlan_VOICE}|{user_VOICE}@{domain_VOICE}|{pass_VOICE}|{vport_VOICE}'1326 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Configure {service} {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1327 log.save()1328 cmd = f'ADD-PONVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::CVLAN={vlan_VOICE},UV={vlan_VOICE},SERVICENAME=VOIP;'1329 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1330 if tl1_cmd['status'] == False:1331 logAppFailed(logApp.id)1332 1333 return JsonResponse(1334 {1335 'status': tl1_cmd['status'],1336 'data': tl1_cmd['data']1337 }1338 )1339 cmd = f'CFG-ONUBW::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::UPBW=UP-{bw_up_VOICE},DOWNBW=DOWN-{bw_down_VOICE},SERVICENAME=VOIP;'1340 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1341 if tl1_cmd['status'] == False:1342 logAppFailed(logApp.id)1343 1344 return JsonResponse(1345 {1346 'status' : tl1_cmd['status'],1347 'data' : tl1_cmd['data']1348 }1349 )1350 cmd = f'CHG-PORT-DHCP::DID={ip_gpon},OID={sn}:5::VIFID={vport_VOICE},OPTION82STAT=Enable;'1351 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1352 if tl1_cmd['status'] == False:1353 logAppFailed(logApp.id)1354 1355 return JsonResponse(1356 {1357 'status' : tl1_cmd['status'],1358 'data' : tl1_cmd['data']1359 }1360 )1361 cmd = f'CFG-VOIPSERVICE::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn},ONUPORT=1-1-1-{pots}:5::PT=SIP,PHONENUMBER={user_VOICE},SIPREGDM="10.0.0.10::10.0.0.40",SIPUSERNAME={user_VOICE}@{domain_VOICE},SIPUSERPWD={pass_VOICE},VOIPVLAN={vlan_VOICE},CCOS=0,IPMODE=DHCP,IPHOSTID=2;'1362 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1363 if tl1_cmd['status'] == False:1364 logAppFailed(logApp.id)1365 1366 return JsonResponse(1367 {1368 'status' : tl1_cmd['status'],1369 'data' : tl1_cmd['data']1370 }1371 )1372 if service == "INET":1373 vlan_INET = request.POST['vlan_INET']1374 cos_INET = request.POST['cos_INET'] if 'cos_INET' in request.POST else ''1375 lan_INET = request.POST.getlist('lan_INET') if 'lan_INET' in request.POST else ''1376 lan_CMD = ''1377 ssid_INET = request.POST.getlist('ssid_INET') if 'ssid_INET' in request.POST else ''1378 user_INET_split = request.POST['user_accout_INET'].split('@')1379 user_INET = user_INET_split[0]1380 domain_INET = user_INET_split[1]1381 pass_INET = request.POST['pass_accout_INET']1382 bw_up_INET = request.POST['bw_up_INET']1383 bw_down_INET = request.POST['bw_down_INET']1384 vport_INET = request.POST['vport_INET'] if 'vport_INET' in request.POST else ''1385 datas.append('###################Configure INTERNET###################')1386 if vendor_code == "fh":1387 for lan in lan_INET:1388 lan_CMD += f'-{lan}'1389 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};inet|{vlan_INET}|{user_INET}@{domain_INET}|{pass_INET}|{lan_CMD[1:]}|{bw_up_INET}|{bw_down_INET}'1390 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Configure Internet {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1391 log.save()1392 if bw_up_INET.upper() == 'BYPASSED' and bw_down_INET.upper() == 'BYPASSED':1393 for lan in lan_INET:1394 cmd = f'SET-WANSERVICE::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn}:5::STATUS=1,MODE=2,CONNTYPE=2,VLAN={vlan_INET},COS={cos_INET},NAT=1,IPMODE=3,PPPOEPROXY=1,PPPOEUSER={user_INET}@{domain_INET},PPPOEPASSWD={pass_INET},PPPOENAME={user_INET},PPPOEMODE=1,UPORT={lan};'1395 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1396 if tl1_cmd['status'] == False:1397 logAppFailed(logApp.id)1398 return JsonResponse(1399 {1400 'status': tl1_cmd['status'],1401 'data': tl1_cmd['data']1402 }1403 )1404 for ssid in ssid_INET:1405 cmd = f'SET-WANSERVICE::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn}:5::STATUS=1,MODE=2,CONNTYPE=2,VLAN={vlan_INET},COS={cos_INET},NAT=1,IPMODE=3,PPPOEPROXY=1,PPPOEUSER={user_INET}@{domain_INET},PPPOEPASSWD={pass_INET},PPPOENAME={user_INET},PPPOEMODE=1,SSID={ssid};'1406 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1407 if tl1_cmd['status'] == False:1408 logAppFailed(logApp.id)1409 return JsonResponse(1410 {1411 'status': tl1_cmd['status'],1412 'data': tl1_cmd['data']1413 }1414 )1415 else:1416 for lan in lan_INET:1417 cmd = f'SET-WANSERVICE::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn}:5::STATUS=1,MODE=2,CONNTYPE=2,VLAN={vlan_INET},COS={cos_INET},NAT=1,IPMODE=3,PPPOEPROXY=1,PPPOEUSER={user_INET}@{domain_INET},PPPOEPASSWD={pass_INET},PPPOENAME={user_INET},PPPOEMODE=1,UPORT={lan},UPPROFILENAME=UP-{bw_up_INET},DOWNPROFILENAME=DOWN-{bw_down_INET};'1418 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1419 if tl1_cmd['status'] == False:1420 logAppFailed(logApp.id)1421 return JsonResponse(1422 {1423 'status': tl1_cmd['status'],1424 'data': tl1_cmd['data']1425 }1426 )1427 for ssid in ssid_INET:1428 cmd = f'SET-WANSERVICE::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn}:5::STATUS=1,MODE=2,CONNTYPE=2,VLAN={vlan_INET},COS={cos_INET},NAT=1,IPMODE=3,PPPOEPROXY=1,PPPOEUSER={user_INET}@{domain_INET},PPPOEPASSWD={pass_INET},PPPOENAME={user_INET},PPPOEMODE=1,SSID={ssid},UPPROFILENAME=UP-{bw_up_INET},DOWNPROFILENAME=DOWN-{bw_down_INET};'1429 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1430 if tl1_cmd['status'] == False:1431 logAppFailed(logApp.id)1432 return JsonResponse(1433 {1434 'status': tl1_cmd['status'],1435 'data': tl1_cmd['data']1436 }1437 )1438 else:1439 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};inet|{vlan_INET}|{user_INET}@{domain_INET}|{pass_INET}|{vport_INET}|{bw_up_INET}|{bw_down_INET}'1440 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action="Configure Internet", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1441 log.save()1442 cmd = f'ADD-PONVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::CVLAN={vlan_INET},UV={vlan_INET},SERVICENAME=SPEEDY;'1443 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1444 if tl1_cmd['status'] == False:1445 logAppFailed(logApp.id)1446 1447 return JsonResponse(1448 {1449 'status': tl1_cmd['status'],1450 'data': tl1_cmd['data']1451 }1452 )1453 cmd = f'CFG-ONUBW::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::UPBW=UP-{bw_up_INET},DOWNBW=DOWN-{bw_down_INET},SERVICENAME=SPEEDY;'1454 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1455 if tl1_cmd['status'] == False:1456 logAppFailed(logApp.id)1457 1458 return JsonResponse(1459 {1460 'status': tl1_cmd['status'],1461 'data': tl1_cmd['data']1462 }1463 )1464 cmd = f'CHG-PORTLOCATING::DID={ip_gpon},OID={sn}:5::VIFID={vport_INET},FORMAT=dsl-forum;'1465 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1466 if tl1_cmd['status'] == False:1467 logAppFailed(logApp.id)1468 1469 return JsonResponse(1470 {1471 'status': tl1_cmd['status'],1472 'data': tl1_cmd['data']1473 }1474 )1475 cmd = f'CHG-PORT-PPPOEPLUS::DID={ip_gpon},OID={sn}:5::VIFID={vport_INET},STATUS=enable;'1476 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1477 if tl1_cmd['status'] == False:1478 logAppFailed(logApp.id)1479 1480 return JsonResponse(1481 {1482 'status': tl1_cmd['status'],1483 'data': tl1_cmd['data']1484 }1485 )1486 cmd = f'CHG-ONUWANIP::DID={ip_gpon},OID={sn}:5::IPHOSTID=1,PPPOEUSER={user_INET}@{domain_INET},PPPOEPWD={pass_INET},VID={vlan_INET};'1487 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1488 if tl1_cmd['status'] == False:1489 logAppFailed(logApp.id)1490 1491 return JsonResponse(1492 {1493 'status': tl1_cmd['status'],1494 'data': tl1_cmd['data']1495 }1496 )1497 1498 cmd = f'CHG-ONUWAN::DID={ip_gpon},OID={sn}:5::WANID=1,IPHOSTID=1,SERVICETYPE=Internet;'1499 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1500 if tl1_cmd['status'] == False:1501 logAppFailed(logApp.id)1502 1503 return JsonResponse(1504 {1505 'status': tl1_cmd['status'],1506 'data': tl1_cmd['data']1507 }1508 )1509 if service == "WIFIID":1510 vlan_WIFIID = request.POST['vlan_WIFIID']1511 lan_WIFIID = request.POST.getlist('lan_WIFIID')1512 lan_CMD = ''1513 bw_up_WIFIID = request.POST['bw_up_WIFIID']1514 bw_down_WIFIID = request.POST['bw_down_WIFIID']1515 datas.append(f'###################Configure {service}###################')1516 for lan in lan_WIFIID:1517 lan_CMD += f'-{lan}'1518 1519 if vendor_code == "fh":1520 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};wifiid|{lan_CMD[1:]}|{vlan_WIFIID}'1521 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Configure {service} {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1522 log.save()1523 for lan in lan_WIFIID:1524 cmd = f'CFG-LANPORTVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn},ONUPORT=1-1-1-{lan}:5::CVLAN={vlan_WIFIID},CCOS=1;'1525 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1526 if tl1_cmd['status'] == False:1527 logAppFailed(logApp.id)1528 1529 return JsonResponse(1530 {1531 'status': tl1_cmd['status'],1532 'data': tl1_cmd['data']1533 }1534 )1535 else:1536 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};wifiid|{lan_CMD[1:]}|{vlan_WIFIID}|{bw_up_WIFIID}|{bw_down_WIFIID}'1537 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Configure {service} {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1538 log.save()1539 cmd = f'ADD-PONVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::CVLAN={vlan_WIFIID},UV={vlan_WIFIID},SERVICENAME={service};'1540 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1541 if tl1_cmd['status'] == False:1542 logAppFailed(logApp.id)1543 1544 return JsonResponse(1545 {1546 'status': tl1_cmd['status'],1547 'data': tl1_cmd['data']1548 }1549 )1550 cmd = f'CFG-ONUBW::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::UPBW=UP-{bw_up_WIFIID},DOWNBW=DOWN-{bw_down_WIFIID},SERVICENAME={service};'1551 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1552 if tl1_cmd['status'] == False:1553 logAppFailed(logApp.id)1554 1555 return JsonResponse(1556 {1557 'status': tl1_cmd['status'],1558 'data': tl1_cmd['data']1559 }1560 )1561 for lan in lan_WIFIID:1562 cmd = f'CFG-LANPORT::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn},ONUPORT=1-1-1-{lan}:5::VLANMOD=Hybrid,PVID={vlan_WIFIID};'1563 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1564 if tl1_cmd['status'] == False:1565 logAppFailed(logApp.id)1566 1567 return JsonResponse(1568 {1569 'status': tl1_cmd['status'],1570 'data': tl1_cmd['data']1571 }1572 )1573 cmd = f'CHG-ONUUNI-PON::DID={ip_gpon},OID={sn},ONUPORT={lan}:5::IPRETRIEVEMODE=FromNetwork;'1574 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1575 if tl1_cmd['status'] == False:1576 logAppFailed(logApp.id)1577 1578 return JsonResponse(1579 {1580 'status': tl1_cmd['status'],1581 'data': tl1_cmd['data']1582 }1583 )1584 if service == "ASTINET":1585 vlan_ASTINET = request.POST['vlan_ASTINET']1586 lan_ASTINET = request.POST.getlist('lan_ASTINET')1587 lan_CMD = ''1588 bw_up_ASTINET = request.POST['bw_up_ASTINET']1589 bw_down_ASTINET = request.POST['bw_down_ASTINET']1590 datas.append(f'###################Configure {service}###################')1591 for lan in lan_ASTINET:1592 lan_CMD += f'-{lan}'1593 if vendor_code == "fh":1594 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};astinet|{lan_CMD[1:]}|{vlan_ASTINET}'1595 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Configure {service} {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1596 log.save()1597 for lan in lan_ASTINET:1598 cmd = f'CFG-LANPORTVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn},ONUPORT=1-1-1-{lan}:5::CVLAN={vlan_ASTINET},CCOS=1;'1599 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1600 if tl1_cmd['status'] == False:1601 logAppFailed(logApp.id)1602 1603 return JsonResponse(1604 {1605 'status': tl1_cmd['status'],1606 'data': tl1_cmd['data']1607 }1608 )1609 1610 else:1611 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};astinet|{lan_CMD[1:]}|{vlan_ASTINET}|{bw_up_ASTINET}|{bw_down_ASTINET}'1612 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Configure {service} {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1613 log.save()1614 cmd = f'ADD-PONVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::CVLAN={vlan_ASTINET},UV={vlan_ASTINET},SERVICENAME={service};'1615 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1616 if tl1_cmd['status'] == False:1617 logAppFailed(logApp.id)1618 1619 return JsonResponse(1620 {1621 'status': tl1_cmd['status'],1622 'data': tl1_cmd['data']1623 }1624 )1625 cmd = f'CFG-ONUBW::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::UPBW=UP-{bw_up_ASTINET},DOWNBW=DOWN-{bw_down_ASTINET},SERVICENAME={service};'1626 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1627 if tl1_cmd['status'] == False:1628 logAppFailed(logApp.id)1629 1630 return JsonResponse(1631 {1632 'status': tl1_cmd['status'],1633 'data': tl1_cmd['data']1634 }1635 )1636 for lan in lan_ASTINET:1637 cmd = f'CFG-LANPORT::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn},ONUPORT=1-1-1-{lan}:5::VLANMOD=Hybrid,PVID={vlan_ASTINET};'1638 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1639 if tl1_cmd['status'] == False:1640 logAppFailed(logApp.id)1641 1642 return JsonResponse(1643 {1644 'status': tl1_cmd['status'],1645 'data': tl1_cmd['data']1646 }1647 )1648 if service == "VPNIP":1649 vlan_VPNIP = request.POST['vlan_VPNIP']1650 lan_VPNIP = request.POST.getlist('lan_VPNIP')1651 lan_CMD = ''1652 bw_up_VPNIP = request.POST['bw_up_VPNIP']1653 bw_down_VPNIP = request.POST['bw_down_VPNIP']1654 datas.append(f'###################Configure {service}###################')1655 for lan in lan_VPNIP:1656 lan_CMD += f'-{lan}'1657 if vendor_code == "fh":1658 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};vpnip|{lan_CMD[1:]}|{vlan_VPNIP}'1659 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Configure {service} {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1660 log.save()1661 for lan in lan_VPNIP:1662 cmd = f'CFG-LANPORTVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn},ONUPORT=1-1-1-{lan}:5::CVLAN={vlan_VPNIP},CCOS=1;'1663 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1664 if tl1_cmd['status'] == False:1665 logAppFailed(logApp.id)1666 1667 return JsonResponse(1668 {1669 'status': tl1_cmd['status'],1670 'data': tl1_cmd['data']1671 }1672 )1673 else:1674 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};vpnip|{lan_CMD[1:]}|{vlan_VPNIP}|{bw_up_VPNIP}|{bw_down_VPNIP}'1675 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Configure {service} {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1676 log.save()1677 cmd = f'ADD-PONVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::CVLAN={vlan_VPNIP},UV={vlan_VPNIP},SERVICENAME={service};'1678 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1679 if tl1_cmd['status'] == False:1680 logAppFailed(logApp.id)1681 1682 return JsonResponse(1683 {1684 'status': tl1_cmd['status'],1685 'data': tl1_cmd['data']1686 }1687 )1688 1689 cmd = f'CFG-ONUBW::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::UPBW=UP-{bw_up_VPNIP},DOWNBW=DOWN-{bw_down_VPNIP},SERVICENAME={service};'1690 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1691 if tl1_cmd['status'] == False:1692 logAppFailed(logApp.id)1693 1694 return JsonResponse(1695 {1696 'status': tl1_cmd['status'],1697 'data': tl1_cmd['data']1698 }1699 )1700 for lan in lan_VPNIP:1701 cmd = f'CFG-LANPORT::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn},ONUPORT=1-1-1-{lan}:5::VLANMOD=Hybrid,PVID={vlan_VPNIP};'1702 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1703 if tl1_cmd['status'] == False:1704 logAppFailed(logApp.id)1705 1706 return JsonResponse(1707 {1708 'status': tl1_cmd['status'],1709 'data': tl1_cmd['data']1710 }1711 )1712 if create_ont == "Modify ONT" and action == "Delete" :1713 for service in services:1714 if service == "IPTV":1715 lan_IPTV = request.POST.getlist('lan_IPTV')1716 lan_CMD = ''1717 datas.append(f'###################Delete {service}###################')1718 1719 for lan in lan_IPTV:1720 lan_CMD += f'-{lan}'1721 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};iptv|{lan_CMD[1:]}'1722 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Delete Service {service} {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1723 log.save()1724 if vendor_code == "fh":1725 for lan in lan_IPTV:1726 cmd = f'DEL-LANIPTVPORT::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn},ONUPORT=1-1-1-{lan}:5::MVLAN=110;'1727 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1728 if tl1_cmd['status'] == False:1729 logAppFailed(logApp.id)1730 1731 return JsonResponse(1732 {1733 'status': tl1_cmd['status'],1734 'data': tl1_cmd['data']1735 }1736 )1737 cmd = f'DEL-LANPORTVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn},ONUPORT=1-1-1-{lan}:5::UV=111;'1738 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1739 if tl1_cmd['status'] == False:1740 logAppFailed(logApp.id)1741 1742 return JsonResponse(1743 {1744 'status': tl1_cmd['status'],1745 'data': tl1_cmd['data']1746 }1747 )1748 else:1749 for lan in lan_IPTV:1750 cmd = f'CHG-ONUUNI-PON::DID={ip_gpon},OID={sn},ONUPORT={lan}:5::IPRETRIEVEMODE=NoControl;'1751 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1752 if tl1_cmd['status'] == False:1753 logAppFailed(logApp.id)1754 1755 return JsonResponse(1756 {1757 'status': tl1_cmd['status'],1758 'data': tl1_cmd['data']1759 }1760 )1761 cmd = f'CFG-LANPORT::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn},ONUPORT=1-1-1-{lan}:5::VLANMOD=None;'1762 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1763 if tl1_cmd['status'] == False:1764 logAppFailed(logApp.id)1765 1766 return JsonResponse(1767 {1768 'status': tl1_cmd['status'],1769 'data': tl1_cmd['data']1770 }1771 )1772 cmd = f'DEL-LANIPTVPORT::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn},ONUPORT=1-1-1-{lan}:5::MVLAN=110;'1773 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1774 if tl1_cmd['status'] == False:1775 logAppFailed(logApp.id)1776 1777 return JsonResponse(1778 {1779 'status': tl1_cmd['status'],1780 'data': tl1_cmd['data']1781 }1782 )1783 cmd = f'DEL-PONVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::CVLAN=111,UV=111,SERVICENAME=USEETV;'1784 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1785 if tl1_cmd['status'] == False:1786 logAppFailed(logApp.id)1787 1788 return JsonResponse(1789 {1790 'status': tl1_cmd['status'],1791 'data': tl1_cmd['data']1792 }1793 )1794 if service == "VOICE":1795 vlan_VOICE = request.POST['vlan_VOICE']1796 pots = request.POST['lan_VOICE']1797 vport_VOICE = request.POST['vport_VOICE'] if 'vport_VOICE' in request.POST else ''1798 datas.append(f'###################Delete {service}###################')1799 1800 if vendor_code == "fh":1801 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};voice'1802 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Configure {service} {vendor_name}", time=datetime.now(), command=command, logapp=logApp)1803 log.save()1804 cmd = f'DEL-VOIPSERVICE::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn},ONUPORT=1-1-1-{pots}:5::;'1805 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1806 if tl1_cmd['status'] == False:1807 logAppFailed(logApp.id)1808 1809 return JsonResponse(1810 {1811 'status': tl1_cmd['status'],1812 'data': tl1_cmd['data']1813 }1814 )1815 else:1816 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};voice|{vlan_VOICE}'1817 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Configure {service} {vendor_name}", time=datetime.now(), command=command, logapp=logApp)1818 log.save()1819 cmd = f'DEL-VOIPSERVICE::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn},ONUPORT=1-1-1-{pots}:::;'1820 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1821 if tl1_cmd['status'] == False:1822 logAppFailed(logApp.id)1823 1824 return JsonResponse(1825 {1826 'status': tl1_cmd['status'],1827 'data': tl1_cmd['data']1828 }1829 )1830 cmd = f'CHG-PORT-DHCP::DID={ip_gpon},OID={sn}:5::VIFID={vport_VOICE},OPTION82STAT=Disable;'1831 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1832 if tl1_cmd['status'] == False:1833 logAppFailed(logApp.id)1834 1835 return JsonResponse(1836 {1837 'status': tl1_cmd['status'],1838 'data': tl1_cmd['data']1839 }1840 )1841 cmd = f'DEL-PONVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::CVLAN={vlan_VOICE},UV={vlan_VOICE},SERVICENAME=VOIP;'1842 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1843 if tl1_cmd['status'] == False:1844 logAppFailed(logApp.id)1845 1846 return JsonResponse(1847 {1848 'status': tl1_cmd['status'],1849 'data': tl1_cmd['data']1850 }1851 )1852 if service == "INET":1853 vlan_INET = request.POST['vlan_INET']1854 cos_INET = request.POST['cos_INET'] if 'cos_INET' in request.POST else ''1855 lan_INET = request.POST.getlist('lan_INET') if 'lan_INET' in request.POST else ''1856 lan_CMD = ''1857 ssid_INET = request.POST.getlist('ssid_INET') if 'ssid_INET' in request.POST else ''1858 vport_INET = request.POST['vport_INET'] if 'vport_INET' in request.POST else ''1859 user_INET_split = request.POST['user_accout_INET'].split('@')1860 user_INET = user_INET_split[0]1861 domain_INET = user_INET_split[1]1862 pass_INET = request.POST['pass_accout_INET']1863 datas.append('###################Delete INTERNET###################')1864 if vendor_code == "fh":1865 for lan in lan_INET:1866 lan_CMD += f'-{lan}'1867 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};inet|{vlan_INET}|{lan_CMD[1:]}'1868 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Delete Service Internet {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1869 log.save()1870 for lan in lan_INET:1871 cmd = f'SET-WANSERVICE::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn}:5::STATUS=2,MODE=2,CONNTYPE=2,VLAN={vlan_INET},COS={cos_INET},NAT=1,IPMODE=3,PPPOEPROXY=1,PPPOEUSER={user_INET}@{domain_INET},PPPOEPASSWD={pass_INET},PPPOENAME={user_INET},PPPOEMODE=1,UPORT={lan};'1872 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1873 if tl1_cmd['status'] == False:1874 logAppFailed(logApp.id)1875 1876 return JsonResponse(1877 {1878 'status': tl1_cmd['status'],1879 'data': tl1_cmd['data']1880 }1881 )1882 for ssid in ssid_INET:1883 cmd = f'SET-WANSERVICE::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn}:5::STATUS=2,MODE=2,CONNTYPE=2,VLAN={vlan_INET},COS={cos_INET},NAT=1,IPMODE=3,PPPOEPROXY=1,PPPOEUSER={user_INET}@{domain_INET},PPPOEPASSWD={pass_INET},PPPOENAME={user_INET},PPPOEMODE=1,SSID={ssid};'1884 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1885 if tl1_cmd['status'] == False:1886 logAppFailed(logApp.id)1887 1888 return JsonResponse(1889 {1890 'status': tl1_cmd['status'],1891 'data': tl1_cmd['data']1892 }1893 )1894 else:1895 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};inet|{vlan_INET}'1896 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Delete Service Internet {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)1897 log.save()1898 cmd = f'DLT-ONUWAN::DID={ip_gpon},OID={sn}:5::WANID=1,IPHOSTID=1;'1899 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1900 if tl1_cmd['status'] == False:1901 logAppFailed(logApp.id)1902 1903 return JsonResponse(1904 {1905 'status': tl1_cmd['status'],1906 'data': tl1_cmd['data']1907 }1908 )1909 cmd = f'DLT-ONUWANIP::DID={ip_gpon},OID={sn}:5::IPHOSTID=1;'1910 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1911 if tl1_cmd['status'] == False:1912 logAppFailed(logApp.id)1913 1914 return JsonResponse(1915 {1916 'status': tl1_cmd['status'],1917 'data': tl1_cmd['data']1918 }1919 )1920 cmd = f'CHG-PORT-PPPOEPLUS::DID={ip_gpon},OID={sn}:5::VIFID={vport_INET},STATUS=disable;'1921 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1922 if tl1_cmd['status'] == False:1923 logAppFailed(logApp.id)1924 1925 return JsonResponse(1926 {1927 'status': tl1_cmd['status'],1928 'data': tl1_cmd['data']1929 }1930 )1931 cmd = f'DEL-PONVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::CVLAN={vlan_INET},UV={vlan_INET},SERVICENAME=SPEEDY;'1932 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1933 if tl1_cmd['status'] == False:1934 logAppFailed(logApp.id)1935 1936 return JsonResponse(1937 {1938 'status': tl1_cmd['status'],1939 'data': tl1_cmd['data']1940 }1941 )1942 if service == "WIFIID":1943 vlan_WIFIID = request.POST['vlan_WIFIID']1944 lan_WIFIID = request.POST.getlist('lan_WIFIID')1945 lan_CMD = ''1946 datas.append(f'###################Delete {service}###################')1947 for lan in lan_WIFIID:1948 lan_CMD += f'-{lan}'1949 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};wifiid|{lan_CMD[1:]}|{vlan_WIFIID}'1950 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Delete Service {service} {vendor_name}", time=datetime.now(), command=command, logapp=logApp)1951 log.save()1952 1953 if vendor_code == "fh":1954 for lan in lan_WIFIID:1955 cmd = f'DEL-LANPORTVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn},ONUPORT=1-1-1-{lan}:5::UV={vlan_WIFIID};'1956 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1957 if tl1_cmd['status'] == False:1958 logAppFailed(logApp.id)1959 1960 return JsonResponse(1961 {1962 'status': tl1_cmd['status'],1963 'data': tl1_cmd['data']1964 }1965 )1966 else:1967 for lan in lan_WIFIID:1968 cmd = f'CHG-ONUUNI-PON::DID={ip_gpon},OID={sn},ONUPORT={lan}:5::IPRETRIEVEMODE=NoControl;'1969 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1970 if tl1_cmd['status'] == False:1971 logAppFailed(logApp.id)1972 1973 return JsonResponse(1974 {1975 'status': tl1_cmd['status'],1976 'data': tl1_cmd['data']1977 }1978 )1979 cmd = f'CFG-LANPORT::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn},ONUPORT=1-1-1-{lan}:5::VLANMOD=None;'1980 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1981 if tl1_cmd['status'] == False:1982 logAppFailed(logApp.id)1983 1984 return JsonResponse(1985 {1986 'status': tl1_cmd['status'],1987 'data': tl1_cmd['data']1988 }1989 )1990 cmd = f'DEL-PONVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::CVLAN={vlan_WIFIID},UV={vlan_WIFIID},SERVICENAME={service};'1991 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)1992 if tl1_cmd['status'] == False:1993 logAppFailed(logApp.id)1994 1995 return JsonResponse(1996 {1997 'status': tl1_cmd['status'],1998 'data': tl1_cmd['data']1999 }2000 )2001 if service == "ASTINET":2002 vlan_ASTINET = request.POST['vlan_ASTINET']2003 lan_ASTINET = request.POST.getlist('lan_ASTINET')2004 lan_CMD = ''2005 datas.append(f'###################Delete {service}###################')2006 for lan in lan_ASTINET:2007 lan_CMD += f'-{lan}'2008 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};astinet|{lan_CMD[1:]}|{vlan_ASTINET}'2009 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Delete Service {service} {vendor_name}", time=datetime.now(), command=command, logapp=logApp)2010 log.save()2011 if vendor_code == "fh":2012 for lan in lan_ASTINET:2013 cmd = f'DEL-LANPORTVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn},ONUPORT=1-1-1-{lan}:5::UV={vlan_ASTINET};'2014 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2015 if tl1_cmd['status'] == False:2016 logAppFailed(logApp.id)2017 2018 return JsonResponse(2019 {2020 'status': tl1_cmd['status'],2021 'data': tl1_cmd['data']2022 }2023 )2024 else:2025 for lan in lan_ASTINET:2026 cmd = f'CFG-LANPORT::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn},ONUPORT=1-1-1-{lan}:5::VLANMOD=None;'2027 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2028 if tl1_cmd['status'] == False:2029 logAppFailed(logApp.id)2030 2031 return JsonResponse(2032 {2033 'status': tl1_cmd['status'],2034 'data': tl1_cmd['data']2035 }2036 )2037 cmd = f'DEL-PONVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::CVLAN={vlan_ASTINET},UV={vlan_ASTINET},SERVICENAME={service};'2038 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2039 if tl1_cmd['status'] == False:2040 logAppFailed(logApp.id)2041 2042 return JsonResponse(2043 {2044 'status': tl1_cmd['status'],2045 'data': tl1_cmd['data']2046 }2047 )2048 if service == "VPNIP":2049 vlan_VPNIP = request.POST['vlan_VPNIP']2050 lan_VPNIP = request.POST.getlist('lan_VPNIP')2051 lan_CMD = ''2052 datas.append(f'###################Delete {service}###################')2053 for lan in lan_VPNIP:2054 lan_CMD += f'-{lan}'2055 command = f'other|{vendor_code}|{ip_gpon}|{slot}-{port}|{sn};vpnip|{lan_CMD[1:]}|{vlan_VPNIP}'2056 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Delete Service {service} {vendor_name}", time=datetime.now(), command=command, status='In Progress', message='No Error', logapp=logApp)2057 log.save()2058 if vendor_code == "fh":2059 for lan in lan_VPNIP:2060 cmd = f'DEL-LANPORTVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=MAC,ONUID={sn},ONUPORT=1-1-1-{lan}:5::UV={vlan_VPNIP};'2061 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2062 if tl1_cmd['status'] == False:2063 logAppFailed(logApp.id)2064 2065 return JsonResponse(2066 {2067 'status': tl1_cmd['status'],2068 'data': tl1_cmd['data']2069 }2070 )2071 else:2072 for lan in lan_VPNIP:2073 cmd = f'CFG-LANPORT::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn},ONUPORT=1-1-1-{lan}:5::VLANMOD=None;'2074 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2075 if tl1_cmd['status'] == False:2076 logAppFailed(logApp.id)2077 2078 return JsonResponse(2079 {2080 'status': tl1_cmd['status'],2081 'data': tl1_cmd['data']2082 }2083 )2084 cmd = f'DEL-PONVLAN::OLTID={ip_gpon},PONID=1-1-{slot}-{port},ONUIDTYPE=SN,ONUID={sn}:5::CVLAN={vlan_VPNIP},UV={vlan_VPNIP},SERVICENAME={service};'2085 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2086 if tl1_cmd['status'] == False:2087 logAppFailed(logApp.id)2088 2089 return JsonResponse(2090 {2091 'status': tl1_cmd['status'],2092 'data': tl1_cmd['data']2093 }2094 )2095 s.close()2096 logAppSuccess(logApp.id)2097 datas = '\n'.join(datas)2098 request.session['hasil'] = datas2099 request.session['hw'] = False2100 return JsonResponse(2101 {2102 'status': True,2103 }2104 )2105@login_required(login_url=settings.URL_SEBELUM_LOGIN)2106@user_passes_test(check_permissions)2107def config_batch(request):2108 if session_login(request) == 'zero':2109 return redirect('login:formOtp')2110 page_title = 'CONFIG BATCH'2111 if request.method == "POST":2112 datas = []2113 data = request.POST['cmd_gpon'].splitlines()2114 list_np = []2115 logApp = logAppIn(request, page_title, f'{page_title} NMS')2116 for data1 in data:2117 data_dump1 = data1.split(';')2118 data_dump2 = data_dump1[0].split('|')2119 tl1 = ServerTl1.objects.get(server_gpon__ip_gpon=data_dump2[2])2120 ip_server = tl1.ip_server2121 port_tl1 = tl1.port_tl12122 s = socket(AF_INET, SOCK_STREAM)2123 s.connect((ip_server, port_tl1))2124 if data_dump2[1].upper() == "FH":2125 cmd_login = f'LOGIN:::CTAG::UN={tl1.user_tl1},PWD={tl1.pass_tl1};'2126 s.send(cmd_login.encode())2127 time.sleep(2)2128 ip_gpon = data_dump2[2]2129 slot_port = data_dump2[3].split('-')2130 slot = slot_port[0]2131 port = slot_port[1]2132 sn = data_dump2[4]2133 list_np.append(ip_server)2134 np_array = np.array(list_np)2135 ip_servers = ', '.join(np.unique(np_array))2136 target = f'{page_title} NMS: {ip_servers}'2137 logAppUpdate = LogApp.objects.get(pk=logApp.id)2138 logAppUpdate.target = target2139 logAppUpdate.save()2140 datas.append(f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}\n")2141 data_ip_port = []2142 cmd_ip = []2143 cmd_ont = None2144 for data2 in data1.split(';'):2145 data3 = data2.split('|')2146 if data3[0].upper() == "ONT":2147 datas.append("=================CREATE ONT=================")2148 if data3[1].upper() == "FH" or data3[1] == "fh":2149 if len(data3) > 6:2150 cmd_option = f'AUTHTYPE=MAC,ONUID={data3[4]},ONUTYPE={data3[5].upper()},NAME={data3[6]} | {data3[4]};'2151 elif len(data3) > 5:2152 cmd_option = f'AUTHTYPE=MAC,ONUID={data3[4]},ONUTYPE={data3[5].upper()};'2153 else:2154 cmd_option = f'AUTHTYPE=MAC,ONUID={data3[4]},ONUTYPE=AN5506-04-F1;'2155 onuidtype = "MAC"2156 else:2157 if len(data3) > 6:2158 cmd_option = f'AUTHTYPE=SN,ONUID={data3[4]},ONUTYPE={data3[5].upper()},NAME={data3[6]}|{data3[4]};'2159 elif len(data3) > 5:2160 cmd_option = f'AUTHTYPE=SN,ONUID={data3[4]},ONUTYPE={data3[5].upper()};'2161 else:2162 cmd_option = f'AUTHTYPE=SN,ONUID={data3[4]},ONUTYPE=ZTEG-F609;'2163 onuidtype = "SN"2164 data_ip_port.append(data3[2].upper())2165 data_ip_port.append(data3[3].upper())2166 data_ip_port.append(onuidtype)2167 data_ip_port.append(data3[4].upper())2168 data_ip_port.append(data3[1])2169 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action="Register ONT", time=datetime.now(), command=data2, status='In Progress', message='No Error', logapp=logApp)2170 log.save()2171 cmd = f'ADD-ONU::OLTID={data_ip_port[0]},PONID=1-1-{data_ip_port[1]}:::{cmd_option}'2172 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2173 if tl1_cmd['status'] == False:2174 logAppFailed(logApp.id)2175 2176 return JsonResponse(2177 {2178 'status': tl1_cmd['status'],2179 'data': tl1_cmd['data']2180 }2181 )2182 cmd_ont = f'other|{ip_gpon}|{slot}-{port}|{sn}'2183 cmd_fhzte = f'OLTID={data_ip_port[0]},PONID=1-1-{data_ip_port[1]},ONUIDTYPE={onuidtype},ONUID={data_ip_port[3]}'2184 cmd_zte = f'DID={data_ip_port[0]},OID={data_ip_port[3]}'2185 cmd_ip.append(cmd_fhzte)2186 cmd_ip.append(cmd_zte)2187 elif data3[0].upper() == "OTHER":2188 if data3[1].upper() == "FH" or data3[1] == "fh":2189 onuidtype = "MAC"2190 else:2191 onuidtype = "SN"2192 data_ip_port.append(data3[2].upper())2193 data_ip_port.append(data3[3].upper())2194 data_ip_port.append(onuidtype)2195 data_ip_port.append(data3[4].upper())2196 data_ip_port.append(data3[1])2197 cmd_fhzte = f'OLTID={data_ip_port[0]},PONID=1-1-{data_ip_port[1]},ONUIDTYPE={onuidtype},ONUID={data_ip_port[3]}'2198 cmd_zte = f'DID={data_ip_port[0]},OID={data_ip_port[3]}'2199 cmd_ont = data22200 cmd_ip.append(cmd_fhzte)2201 cmd_ip.append(cmd_zte)2202 if data3[0].upper() == "INET":2203 datas.append("=================INTERNET=================")2204 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action="Configure Internet", time=datetime.now(), command=f'{cmd_ont};{data2}', status='In Progress', message='No Error', logapp=logApp)2205 log.save()2206 if data_ip_port[4].upper() == "FH" or data_ip_port[4].upper() == "fh":2207 if (len(data3) > 5):2208 cmd_bw = f'UPPROFILENAME=UP-{data3[4]},DOWNPROFILENAME=DOWN-{data3[5]};'2209 else:2210 cmd_bw = 'UPPROFILENAME=UP-2253KB0,DOWNPROFILENAME=DOWN-11264KB0;'2211 userAccount = data3[2].split('@')2212 cmd = f'SET-WANSERVICE::{cmd_ip[0]}:5::STATUS=1,MODE=2,CONNTYPE=2,VLAN={data3[1]},COS=0,NAT=1,IPMODE=3,PPPOEPROXY=1,PPPOEUSER={data3[2]},PPPOEPASSWD={data3[3]},PPPOENAME={userAccount[0]},PPPOEMODE=1,UPORT=3,{cmd_bw}'2213 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2214 if tl1_cmd['status'] == False:2215 logAppFailed(logApp.id)2216 return JsonResponse(2217 {2218 'status': tl1_cmd['status'],2219 'data': tl1_cmd['data']2220 }2221 )2222 cmd = f'SET-WANSERVICE::{cmd_ip[0]}:5::STATUS=1,MODE=2,CONNTYPE=2,VLAN={data3[1]},COS=0,NAT=1,IPMODE=3,PPPOEPROXY=1,PPPOEUSER={data3[2]},PPPOEPASSWD={data3[3]},PPPOENAME={userAccount[0]},PPPOEMODE=1,SSID=1,{cmd_bw}'2223 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2224 if tl1_cmd['status'] == False:2225 logAppFailed(logApp.id)2226 2227 return JsonResponse(2228 {2229 'status': tl1_cmd['status'],2230 'data': tl1_cmd['data']2231 }2232 )2233 else:2234 if (len(data3) > 6):2235 vport = data3[4]2236 up_bw = f'UP-{data3[5]}'2237 down_bw = f'DOWN-{data3[6]}'2238 elif (len(data3) > 4):2239 vport = data3[4]2240 up_bw = 'UP-2253KB0'2241 down_bw = 'DOWN-11264KB0'2242 else:2243 vport = '3'2244 up_bw = 'UP-2253KB0'2245 down_bw = 'DOWN-11264KB0'2246 cmd = f'ADD-PONVLAN::{cmd_ip[0]}:5::CVLAN={data3[1]},UV={data3[1]},SERVICENAME=SPEEDY;'2247 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2248 if tl1_cmd['status'] == False:2249 logAppFailed(logApp.id)2250 2251 return JsonResponse(2252 {2253 'status': tl1_cmd['status'],2254 'data': tl1_cmd['data']2255 }2256 )2257 cmd = f'CFG-ONUBW::{cmd_ip[0]}:::UPBW={up_bw},DOWNBW={down_bw},SERVICENAME=SPEEDY;'2258 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2259 if tl1_cmd['status'] == False:2260 logAppFailed(logApp.id)2261 2262 return JsonResponse(2263 {2264 'status': tl1_cmd['status'],2265 'data': tl1_cmd['data']2266 }2267 )2268 cmd = f'CHG-PORTLOCATING::{cmd_ip[1]}:::VIFID={vport},FORMAT=dsl-forum;'2269 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2270 if tl1_cmd['status'] == False:2271 logAppFailed(logApp.id)2272 2273 return JsonResponse(2274 {2275 'status': tl1_cmd['status'],2276 'data': tl1_cmd['data']2277 }2278 )2279 cmd = f'CHG-PORT-PPPOEPLUS::{cmd_ip[1]}:::VIFID={vport},STATUS=enable;'2280 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2281 if tl1_cmd['status'] == False:2282 logAppFailed(logApp.id)2283 2284 return JsonResponse(2285 {2286 'status': tl1_cmd['status'],2287 'data': tl1_cmd['data']2288 }2289 )2290 cmd = f'CHG-ONUWANIP::{cmd_ip[1]}:::IPHOSTID=1,PPPOEUSER={data3[2]},PPPOEPWD={data3[3]},VID={data3[1]};'2291 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2292 if tl1_cmd['status'] == False:2293 logAppFailed(logApp.id)2294 2295 return JsonResponse(2296 {2297 'status': tl1_cmd['status'],2298 'data': tl1_cmd['data']2299 }2300 )2301 cmd = f'CHG-ONUWAN::{cmd_ip[1]}:::WANID=1,IPHOSTID=1,SERVICETYPE=Internet;'2302 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2303 if tl1_cmd['status'] == False:2304 logAppFailed(logApp.id)2305 2306 return JsonResponse(2307 {2308 'status': tl1_cmd['status'],2309 'data': tl1_cmd['data']2310 }2311 )2312 if data3[0].upper() == "VOICE":2313 datas.append("=================VOICE=================")2314 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action="Configure VOICE", time=datetime.now(), command=f'{cmd_ont};{data2}', status='In Progress', message='No Error', logapp=logApp)2315 log.save()2316 if data_ip_port[4].upper() == "FH" or data_ip_port[4].upper() == "fh":2317 cmd = f'CFG-VOIPSERVICE::{cmd_ip[0]},ONUPORT=1-1-1-1:5::PHONENUMBER={data3[2]},PT=SIP,VOIPVLAN={data3[1]},SCOS=7,EID=@telkom.net.id,SIPUSERNAME={data3[2]},SIPUSERPWD={data3[3]},IPMODE=DHCP;'2318 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2319 if tl1_cmd['status'] == False:2320 logAppFailed(logApp.id)2321 2322 return JsonResponse(2323 {2324 'status': tl1_cmd['status'],2325 'data': tl1_cmd['data']2326 }2327 )2328 else:2329 if (len(data3) > 4):2330 vport = data3[4]2331 else:2332 vport = '2'2333 cmd = f'ADD-PONVLAN::{cmd_ip[0]}:5::CVLAN={data3[1]},UV={data3[1]},SERVICENAME=VOICE;\n'2334 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2335 if tl1_cmd['status'] == False:2336 logAppFailed(logApp.id)2337 2338 return JsonResponse(2339 {2340 'status': tl1_cmd['status'],2341 'data': tl1_cmd['data']2342 }2343 )2344 cmd = f'CFG-ONUBW::{cmd_ip[0]}:::UPBW=UP-1M,DOWNBW=DOWN-1M,SERVICENAME=VOICE;'2345 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2346 if tl1_cmd['status'] == False:2347 logAppFailed(logApp.id)2348 2349 return JsonResponse(2350 {2351 'status': tl1_cmd['status'],2352 'data': tl1_cmd['data']2353 }2354 )2355 cmd = f'CHG-PORT-DHCP::{cmd_ip[1]}:::VIFID={vport},OPTION82STAT=Enable;'2356 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2357 if tl1_cmd['status'] == False:2358 logAppFailed(logApp.id)2359 2360 return JsonResponse(2361 {2362 'status': tl1_cmd['status'],2363 'data': tl1_cmd['data']2364 }2365 )2366 cmd = f'CFG-VOIPSERVICE::{cmd_ip[0]},ONUPORT=1-1-1-1:::PT=SIP,PHONENUMBER={data3[2]},SIPREGDM="10.0.0.10::10.0.0.40",SIPUSERNAME={data3[2]}@telkom.net.id,SIPUSERPWD={data3[3]},VOIPVLAN={data3[1]},CCOS=0,IPMODE=DHCP,IPHOSTID=2;'2367 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2368 if tl1_cmd['status'] == False:2369 logAppFailed(logApp.id)2370 2371 return JsonResponse(2372 {2373 'status': tl1_cmd['status'],2374 'data': tl1_cmd['data']2375 }2376 )2377 if data3[0].upper() == "IPTV" or data3[0].upper() == "WIFIID" or data3[0].upper() == "ASTINET" or data3[0].upper() == "VPNIP":2378 datas.append(f"================={data3[0].upper()}=================")2379 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action=f"Configure {data3[0].upper()}", time=datetime.now(), command=f'{cmd_ont};{data2}', status='In Progress', message='No Error', logapp=logApp)2380 log.save()2381 port_lan = []2382 if len(data3) > 1:2383 for lan in data3[1].split('-'):2384 port_lan.append(lan)2385 else:2386 lan = '4'2387 port_lan.append(lan)2388 if len(data3) > 4:2389 up_bw = data3[3]2390 down_bw = data3[4]2391 bw_lan = f'BW={up_bw}_{down_bw}'2392 else:2393 up_bw = "2253KA4"2394 down_bw = "9012KA4"2395 bw_lan = ';'2396 if data_ip_port[4].upper() == "FH" or data_ip_port[4].upper() == "fh":2397 for onuport in port_lan:2398 if data3[0].upper() == "IPTV":2399 cmd = f'ADD-LANIPTVPORT::{cmd_ip[0]},ONUPORT=1-1-1-{onuport}:5::MVLAN=110,MCOS=4;'2400 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2401 if tl1_cmd['status'] == False:2402 logAppFailed(logApp.id)2403 2404 return JsonResponse(2405 {2406 'status': tl1_cmd['status'],2407 'data': tl1_cmd['data']2408 }2409 )2410 cmd = f'CFG-LANPORTVLAN::{cmd_ip[0]},ONUPORT=1-1-1-{onuport}:5::CVLAN=111,CCOS=4;'2411 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2412 if tl1_cmd['status'] == False:2413 logAppFailed(logApp.id)2414 2415 return JsonResponse(2416 {2417 'status': tl1_cmd['status'],2418 'data': tl1_cmd['data']2419 }2420 )2421 cmd = f'CFG-LANPORT::{cmd_ip[0]},ONUPORT=1-1-1-{onuport}:5::BW=DOWN8MKA4_UP2253KA4;'2422 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2423 if tl1_cmd['status'] == False:2424 logAppFailed(logApp.id)2425 2426 return JsonResponse(2427 {2428 'status': tl1_cmd['status'],2429 'data': tl1_cmd['data']2430 }2431 )2432 if data3[0].upper() != "IPTV":2433 cmd = f'CFG-LANPORTVLAN::{cmd_ip[0]},ONUPORT=1-1-1-{onuport}:5::CVLAN={data3[2]},CCOS=4;'2434 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2435 if tl1_cmd['status'] == False:2436 logAppFailed(logApp.id)2437 2438 return JsonResponse(2439 {2440 'status': tl1_cmd['status'],2441 'data': tl1_cmd['data']2442 }2443 )2444 cmd = f'CFG-LANPORT::{cmd_ip[0]},ONUPORT=1-1-1-{onuport}:5::{bw_lan}'2445 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2446 if tl1_cmd['status'] == False:2447 logAppFailed(logApp.id)2448 2449 return JsonResponse(2450 {2451 'status': tl1_cmd['status'],2452 'data': tl1_cmd['data']2453 }2454 )2455 else:2456 if data3[0].upper() == "IPTV":2457 cmd = f'ADD-PONVLAN::{cmd_ip[0]}:::CVLAN=111,UV=111,SERVICENAME=USEETV;'2458 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2459 if tl1_cmd['status'] == False:2460 logAppFailed(logApp.id)2461 2462 return JsonResponse(2463 {2464 'status': tl1_cmd['status'],2465 'data': tl1_cmd['data']2466 }2467 )2468 cmd = f'CFG-ONUBW::{cmd_ip[0]}:::UPBW=UP-2253KA4,DOWNBW=DOWN-9012KA4,SERVICENAME=USEETV;'2469 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2470 if tl1_cmd['status'] == False:2471 logAppFailed(logApp.id)2472 2473 return JsonResponse(2474 {2475 'status': tl1_cmd['status'],2476 'data': tl1_cmd['data']2477 }2478 )2479 else:2480 cmd = f'ADD-PONVLAN::{cmd_ip[0]}:::CVLAN={data3[2]},UV={data3[2]},SERVICENAME={data3[0].upper()};'2481 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2482 if tl1_cmd['status'] == False:2483 logAppFailed(logApp.id)2484 2485 return JsonResponse(2486 {2487 'status': tl1_cmd['status'],2488 'data': tl1_cmd['data']2489 }2490 )2491 cmd = f'CFG-ONUBW::{cmd_ip[0]}:::UPBW=UP-{up_bw},DOWNBW=DOWN-{down_bw},SERVICENAME={data3[0].upper()};'2492 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2493 if tl1_cmd['status'] == False:2494 logAppFailed(logApp.id)2495 2496 return JsonResponse(2497 {2498 'status': tl1_cmd['status'],2499 'data': tl1_cmd['data']2500 }2501 )2502 for onuport in port_lan:2503 if data3[0].upper() == "IPTV":2504 cmd = f'ADD-LANIPTVPORT::{cmd_ip[0]},ONUPORT=1-1-1-{onuport}:::MVLAN=110,SERVICENAME=USEETV;'2505 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2506 if tl1_cmd['status'] == False:2507 logAppFailed(logApp.id)2508 2509 return JsonResponse(2510 {2511 'status': tl1_cmd['status'],2512 'data': tl1_cmd['data']2513 }2514 )2515 cmd = f'CFG-LANPORT::{cmd_ip[0]},ONUPORT=1-1-1-{onuport}:::VLANMOD=Hybrid,PVID=111;'2516 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2517 if tl1_cmd['status'] == False:2518 logAppFailed(logApp.id)2519 2520 return JsonResponse(2521 {2522 'status': tl1_cmd['status'],2523 'data': tl1_cmd['data']2524 }2525 )2526 cmd = f'CHG-ONUUNI-PON::{cmd_ip[1]},ONUPORT={onuport}:::IPRETRIEVEMODE=FromNetwork;'2527 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2528 if tl1_cmd['status'] == False:2529 logAppFailed(logApp.id)2530 2531 return JsonResponse(2532 {2533 'status': tl1_cmd['status'],2534 'data': tl1_cmd['data']2535 }2536 )2537 elif data3[0].upper() == "WIFIID":2538 cmd = f'CFG-LANPORT::{cmd_ip[0]},ONUPORT=1-1-1-{onuport}:::VLANMOD=Hybrid,PVID={data3[2]};'2539 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2540 if tl1_cmd['status'] == False:2541 logAppFailed(logApp.id)2542 2543 return JsonResponse(2544 {2545 'status': tl1_cmd['status'],2546 'data': tl1_cmd['data']2547 }2548 )2549 cmd = f'CHG-ONUUNI-PON::{cmd_ip[1]},ONUPORT={onuport}:::IPRETRIEVEMODE=FromNetwork;'2550 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2551 if tl1_cmd['status'] == False:2552 logAppFailed(logApp.id)2553 2554 return JsonResponse(2555 {2556 'status': tl1_cmd['status'],2557 'data': tl1_cmd['data']2558 }2559 )2560 else:2561 cmd = f'CFG-LANPORT::{cmd_ip[0]},ONUPORT=1-1-1-{onuport}:::VLANMOD=Hybrid,PVID={data3[2]};'2562 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2563 if tl1_cmd['status'] == False:2564 logAppFailed(logApp.id)2565 2566 return JsonResponse(2567 {2568 'status': tl1_cmd['status'],2569 'data': tl1_cmd['data']2570 }2571 )2572 if data_dump2[1].upper() == "FH":2573 s.send(b'LOGOUT:::5::;')2574 time.sleep(2)2575 s.close()2576 logAppSuccess(logApp.id)2577 datas = '\n'.join(datas)2578 request.session['hasil'] = datas2579 request.session['hw'] = False2580 return JsonResponse(2581 {2582 'status': True,2583 }2584 )2585 else:2586 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))2587 placeholder = "Contoh Fiberhome :\n"2588 placeholder += "=====CREATE ONT==========\n"2589 placeholder += "ont|fh|172.29.215.6|6-6|FHTT06138248\n"2590 placeholder += "ont|fh|172.29.215.6|6-6|FHTT06138248|HG6243C\n"2591 placeholder += "ont|fh|172.29.215.6|6-6|FHTT06138248|HG6243C|{NAMA_PELANGGAN}\n"2592 placeholder += "=====CREATE INTERNET==========\n"2593 placeholder += "other|fh|172.29.215.6|6-6|FHTT06138248;INET|1904|131626153157@telkom.net|707341163\n"2594 placeholder += "other|fh|172.29.215.6|6-6|FHTT06138248;INET|1904|131626153157@telkom.net|707341163|1536K|15360K\n"2595 placeholder += "=====CREATE VOICE==========\n"2596 placeholder += "other|fh|172.29.215.6|6-6|FHTT06138248;VOICE|532|+622666221191|190718488\n"2597 placeholder += "=====CREATE IPTV==========\n"2598 placeholder += "other|fh|172.29.215.6|6-6|FHTT06138248;IPTV\n"2599 placeholder += "=====CREATE 3P/2P/1P + ONT==========\n"2600 placeholder += "ont|fh|172.29.215.6|6-6|FHTT06138248|HG6243C|NAMA_PELANGGAN;INET|1904|131626153157@telkom.net|707341163|1536K|15360K;VOICE|532|+622666221191|190718488;IPTV\n"2601 placeholder += "\n"2602 placeholder += "\n"2603 placeholder += "Contoh ZTE :\n"2604 placeholder += "=====CREATE ONT==========\n"2605 placeholder += "ont|zte|172.21.202.4|12-2|ZTEGC6753017\n"2606 placeholder += "ont|zte|172.21.202.4|12-2|ZTEGC6753017|ZTEG-F609\n"2607 placeholder += "ont|zte|172.21.202.4|12-2|ZTEGC6753017|ZTEG-F609|NAMA_PELANGGAN\n"2608 placeholder += "=====CREATE INTERNET==========\n"2609 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;INET|770|131626153157@telkom.net|707341163|\n"2610 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;INET|770|131626153157@telkom.net|707341163|{vport}\n"2611 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;INET|770|131626153157@telkom.net|707341163|{vport}|1536K|15360K\n"2612 placeholder += "=====CREATE VOICE==========\n"2613 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;VOICE|571|+622667121278|9866556\n"2614 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;VOICE|571|+622667121278|9866556|{vport}\n"2615 placeholder += "=====CREATE IPTV==========\n"2616 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;IPTV\n"2617 placeholder += "=====CREATE 3P/2P/1P + ONT==========\n"2618 placeholder += "ont|zte|172.21.202.4|12-2|ZTEGC6753017|ZTEG-F609|NAMA_PELANGGAN;INET|770|131626153157@telkom.net|707341163|1|1536K|15360K;VOICE|571|+622667121278|9866556|2;IPTV\n"2619 context = {2620 'page_title': page_title,2621 'vendors': vendor,2622 'placeholder': placeholder,2623 'client_ip': get_client_ip(request),2624 }2625 return render(request, 'config.html', context)2626@login_required(login_url=settings.URL_SEBELUM_LOGIN)2627@user_passes_test(check_permissions)2628def delete_config_batch(request):2629 if session_login(request) == 'zero':2630 return redirect('login:formOtp')2631 page_title = 'DELETE BATCH'2632 if request.method == "POST":2633 datas = []2634 data = request.POST['cmd_gpon']2635 list_np = []2636 logApp = logAppIn(request, page_title, f'{page_title} NMS')2637 for data1 in data.splitlines():2638 data_dump1 = data1.split(';')2639 data_dump2 = data_dump1[0].split('|')2640 tl1 = ServerTl1.objects.get(server_gpon__ip_gpon=data_dump2[2])2641 ip_server = tl1.ip_server2642 port_tl1 = tl1.port_tl12643 s = socket(AF_INET, SOCK_STREAM)2644 s.connect((ip_server, port_tl1))2645 if data_dump2[1].upper() == "FH":2646 cmd_login = f'LOGIN:::CTAG::UN={tl1.user_tl1},PWD={tl1.pass_tl1};'2647 s.send(cmd_login.encode())2648 time.sleep(2)2649 ip_gpon = data_dump2[2]2650 slot_port = data_dump2[3].split('-')2651 slot = slot_port[0]2652 port = slot_port[1]2653 sn = data_dump2[4]2654 list_np.append(ip_server)2655 np_array = np.array(list_np)2656 ip_servers = ', '.join(np.unique(np_array))2657 target = f'{page_title} NMS: {ip_servers}'2658 logAppUpdate = LogApp.objects.get(pk=logApp.id)2659 logAppUpdate.target = target2660 logAppUpdate.save()2661 datas.append(f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}\n")2662 data_ip_port = []2663 cmd_ip = []2664 cmd_ont = None2665 for data2 in data1.split(';'):2666 data3 = data2.split('|')2667 if data3[0].upper() == "ONT":2668 datas.append("=================DELETE ONT=================")2669 if data3[1].upper() == "FH" or data3[1] == "fh":2670 cmd_option = f'ONUIDTYPE=MAC,ONUID={data3[4]};'2671 onuidtype = "MAC"2672 else:2673 cmd_option = f'ONUIDTYPE=SN,ONUID={data3[4]};'2674 onuidtype = "SN"2675 data_ip_port.append(data3[2].upper())2676 data_ip_port.append(data3[3].upper())2677 data_ip_port.append(onuidtype)2678 data_ip_port.append(data3[4].upper())2679 data_ip_port.append(data3[1])2680 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action="Delete ONT", time=datetime.now(), command=data2, status='In Progress', message='No Error', logapp=logApp)2681 log.save()2682 cmd = f'DEL-ONU::OLTID={data_ip_port[0]},PONID=1-1-{data_ip_port[1]}:::{cmd_option}'2683 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2684 if tl1_cmd['status'] == False:2685 logAppFailed(logApp.id)2686 2687 return JsonResponse(2688 {2689 'status': tl1_cmd['status'],2690 'data': tl1_cmd['data']2691 }2692 )2693 cmd_ont = f'other|{ip_gpon}|{slot}-{port}|{sn}'2694 cmd_fhzte = f'OLTID={data_ip_port[0]},PONID=1-1-{data_ip_port[1]},ONUIDTYPE={onuidtype},ONUID={data_ip_port[3]}'2695 cmd_zte = f'DID={data_ip_port[0]},OID={data_ip_port[3]}'2696 cmd_ip.append(cmd_fhzte)2697 cmd_ip.append(cmd_zte)2698 elif data3[0].upper() == "OTHER":2699 if data3[1].upper() == "FH" or data3[1] == "fh":2700 onuidtype = "MAC"2701 else:2702 onuidtype = "SN"2703 data_ip_port.append(data3[2].upper())2704 data_ip_port.append(data3[3].upper())2705 data_ip_port.append(onuidtype)2706 data_ip_port.append(data3[4].upper())2707 data_ip_port.append(data3[1])2708 cmd_ont = data22709 cmd_fhzte = f'OLTID={data_ip_port[0]},PONID=1-1-{data_ip_port[1]},ONUIDTYPE={onuidtype},ONUID={data_ip_port[3]}'2710 cmd_zte = f'DID={data_ip_port[0]},OID={data_ip_port[3]}'2711 cmd_ip.append(cmd_fhzte)2712 cmd_ip.append(cmd_zte)2713 if data3[0].upper() == "INET":2714 datas.append("=================DELETE INTERNET=================")2715 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action="Delete Internet", time=datetime.now(), command=f'{cmd_ont};{data2}', status='In Progress', message='No Error', logapp=logApp)2716 log.save()2717 if data_ip_port[4].upper() == "FH" or data_ip_port[4].upper() == "fh":2718 cmd = f'SET-WANSERVICE::{cmd_ip[0]}:5::STATUS=2,MODE=2,CONNTYPE=2,VLAN={data3[1]},COS=0,NAT=1,IPMODE=3,PPPOEPROXY=1,PPPOEUSER=aaa@aaa,PPPOEPASSWD=aaa,PPPOENAME=aaa,PPPOEMODE=1,UPORT=1;'2719 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2720 if tl1_cmd['status'] == False:2721 logAppFailed(logApp.id)2722 2723 return JsonResponse(2724 {2725 'status': tl1_cmd['status'],2726 'data': tl1_cmd['data']2727 }2728 )2729 cmd = f'SET-WANSERVICE::{cmd_ip[0]}:5::STATUS=2,MODE=2,CONNTYPE=2,VLAN={data3[1]},COS=0,NAT=1,IPMODE=3,PPPOEPROXY=1,PPPOEUSER=aaa@aaa,PPPOEPASSWD=aaa,PPPOENAME=aaa,PPPOEMODE=1,UPORT=2;'2730 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2731 if tl1_cmd['status'] == False:2732 logAppFailed(logApp.id)2733 2734 return JsonResponse(2735 {2736 'status': tl1_cmd['status'],2737 'data': tl1_cmd['data']2738 }2739 )2740 cmd = f'SET-WANSERVICE::{cmd_ip[0]}:5::STATUS=2,MODE=2,CONNTYPE=2,VLAN={data3[1]},COS=0,NAT=1,IPMODE=3,PPPOEPROXY=1,PPPOEUSER=aaa@aaa,PPPOEPASSWD=aaa,PPPOENAME=aaa,PPPOEMODE=1,UPORT=3;'2741 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2742 if tl1_cmd['status'] == False:2743 logAppFailed(logApp.id)2744 2745 return JsonResponse(2746 {2747 'status': tl1_cmd['status'],2748 'data': tl1_cmd['data']2749 }2750 )2751 cmd = f'SET-WANSERVICE::{cmd_ip[0]}:5::STATUS=2,MODE=2,CONNTYPE=2,VLAN={data3[1]},COS=0,NAT=1,IPMODE=3,PPPOEPROXY=1,PPPOEUSER=aaa@aaa,PPPOEPASSWD=aaa,PPPOENAME=aaa,PPPOEMODE=1,UPORT=4;'2752 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2753 if tl1_cmd['status'] == False:2754 logAppFailed(logApp.id)2755 2756 return JsonResponse(2757 {2758 'status': tl1_cmd['status'],2759 'data': tl1_cmd['data']2760 }2761 )2762 cmd = f'SET-WANSERVICE::{cmd_ip[0]}:5::STATUS=2,MODE=2,CONNTYPE=2,VLAN={data3[1]},COS=0,NAT=1,IPMODE=3,PPPOEPROXY=1,PPPOEUSER=aaa@aaa,PPPOEPASSWD=aaa,PPPOENAME=aaa,PPPOEMODE=1,SSID=1;'2763 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2764 if tl1_cmd['status'] == False:2765 logAppFailed(logApp.id)2766 2767 return JsonResponse(2768 {2769 'status': tl1_cmd['status'],2770 'data': tl1_cmd['data']2771 }2772 )2773 else:2774 cmd = f'DLT-ONUWAN::{cmd_ip[1]}:::WANID=1,IPHOSTID=1;'2775 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2776 if tl1_cmd['status'] == False:2777 logAppFailed(logApp.id)2778 2779 return JsonResponse(2780 {2781 'status': tl1_cmd['status'],2782 'data': tl1_cmd['data']2783 }2784 )2785 cmd = f'DLT-ONUWANIP::{cmd_ip[1]}:::IPHOSTID=1;'2786 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2787 if tl1_cmd['status'] == False:2788 logAppFailed(logApp.id)2789 2790 return JsonResponse(2791 {2792 'status': tl1_cmd['status'],2793 'data': tl1_cmd['data']2794 }2795 )2796 cmd = f'DEL-PONVLAN::{cmd_ip[0]}:5::CVLAN={data3[1]},UV={data3[1]},SERVICENAME=SPEEDY;'2797 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2798 if tl1_cmd['status'] == False:2799 logAppFailed(logApp.id)2800 2801 return JsonResponse(2802 {2803 'status': tl1_cmd['status'],2804 'data': tl1_cmd['data']2805 }2806 )2807 if data3[0].upper() == "VOICE":2808 datas.append("=================DELETE VOICE=================")2809 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action="Delete VOICE", time=datetime.now(), command=f'{cmd_ont};{data2}', status='In Progress', message='No Error', logapp=logApp)2810 log.save()2811 if data_ip_port[4].upper() == "FH" or data_ip_port[4].upper() == "fh":2812 cmd = f'DEL-VOIPSERVICE::{cmd_ip[0]},ONUPORT=1-1-1-1:5::;'2813 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2814 if tl1_cmd['status'] == False:2815 logAppFailed(logApp.id)2816 2817 return JsonResponse(2818 {2819 'status': tl1_cmd['status'],2820 'data': tl1_cmd['data']2821 }2822 )2823 else:2824 cmd = f'DEL-VOIPSERVICE::{cmd_ip[0]},ONUPORT=1-1-1-1:::;'2825 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2826 if tl1_cmd['status'] == False:2827 logAppFailed(logApp.id)2828 2829 return JsonResponse(2830 {2831 'status': tl1_cmd['status'],2832 'data': tl1_cmd['data']2833 }2834 )2835 cmd = f'DEL-PONVLAN::{cmd_ip[0]}:5::CVLAN={data3[1]},UV={data3[1]},SERVICENAME=VOICE;\n'2836 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2837 if tl1_cmd['status'] == False:2838 logAppFailed(logApp.id)2839 2840 return JsonResponse(2841 {2842 'status': tl1_cmd['status'],2843 'data': tl1_cmd['data']2844 }2845 )2846 if data3[0].upper() == "IPTV":2847 datas.append("=================DELETE USEETV=================")2848 log = LogTL1(target=f"IP GPON: {ip_gpon}, SLOT/PORT: {slot}/{port}, SN: {sn}", action="Delete IPTV", time=datetime.now(), command=f'{cmd_ont};{data2}', status='Progress', message='No Error', logapp=logApp)2849 log.save()2850 if data_ip_port[4].upper() == "FH" or data_ip_port[4].upper() == "fh":2851 cmd = f'DEL-LANIPTVPORT::{cmd_ip[0]},ONUPORT=1-1-1-4:5::MVLAN=110;'2852 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2853 if tl1_cmd['status'] == False:2854 logAppFailed(logApp.id)2855 2856 return JsonResponse(2857 {2858 'status': tl1_cmd['status'],2859 'data': tl1_cmd['data']2860 }2861 )2862 cmd = f'DEL-LANPORTVLAN::{cmd_ip[0]},ONUPORT=1-1-1-4:5::UV=111;'2863 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2864 if tl1_cmd['status'] == False:2865 logAppFailed(logApp.id)2866 2867 return JsonResponse(2868 {2869 'status': tl1_cmd['status'],2870 'data': tl1_cmd['data']2871 }2872 )2873 else:2874 cmd = f'CFG-LANPORT::{cmd_ip[0]},ONUPORT=1-1-1-4:::VLANMOD=None;'2875 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2876 if tl1_cmd['status'] == False:2877 logAppFailed(logApp.id)2878 2879 return JsonResponse(2880 {2881 'status': tl1_cmd['status'],2882 'data': tl1_cmd['data']2883 }2884 )2885 cmd = f'CHG-ONUUNI-PON::{cmd_ip[1]},ONUPORT=4:::IPRETRIEVEMODE=NoControl;'2886 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2887 if tl1_cmd['status'] == False:2888 logAppFailed(logApp.id)2889 2890 return JsonResponse(2891 {2892 'status': tl1_cmd['status'],2893 'data': tl1_cmd['data']2894 }2895 )2896 cmd = f'DEL-LANIPTVPORT::{cmd_ip[0]},ONUPORT=1-1-1-4:::MVLAN=110;'2897 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2898 if tl1_cmd['status'] == False:2899 logAppFailed(logApp.id)2900 2901 return JsonResponse(2902 {2903 'status': tl1_cmd['status'],2904 'data': tl1_cmd['data']2905 }2906 )2907 cmd = f'DEL-PONVLAN::{cmd_ip[0]}:::CVLAN=111,UV=111,SERVICENAME=USEETV;'2908 tl1_cmd = tl1_command(s, cmd, datas, log, log.id)2909 if tl1_cmd['status'] == False:2910 logAppFailed(logApp.id)2911 2912 return JsonResponse(2913 {2914 'status': tl1_cmd['status'],2915 'data': tl1_cmd['data']2916 }2917 )2918 if data_dump2[1].upper() == "FH":2919 s.send(b'LOGOUT:::5::;')2920 time.sleep(2)2921 s.close()2922 logAppSuccess(logApp.id)2923 datas = '\n'.join(datas)2924 request.session['hasil'] = datas2925 request.session['hw'] = False2926 return JsonResponse(2927 {2928 'status': True,2929 }2930 )2931 else:2932 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))2933 placeholder = "Contoh Fiberhome :\n"2934 placeholder += "=====DELETE ONT==========\n"2935 placeholder += "ont|fh|172.29.215.6|6-6|FHTT06138248\n"2936 placeholder += "=====DELETE INTERNET==========\n"2937 placeholder += "other|fh|172.29.215.6|6-6|FHTT06138248;INET|1904\n"2938 placeholder += "=====DELETE VOICE==========\n"2939 placeholder += "other|fh|172.29.215.6|6-6|FHTT06138248;VOICE\n"2940 placeholder += "=====DELETE IPTV==========\n"2941 placeholder += "other|fh|172.29.215.6|6-6|FHTT06138248;IPTV\n"2942 placeholder += "\n"2943 placeholder += "\n"2944 placeholder += "Contoh ZTE :\n"2945 placeholder += "=====DELETE ONT==========\n"2946 placeholder += "ont|zte|172.21.202.4|12-2|ZTEGC6753017\n"2947 placeholder += "=====CREATE INTERNET==========\n"2948 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;INET|770\n"2949 placeholder += "=====CREATE VOICE==========\n"2950 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;VOICE|571\n"2951 placeholder += "=====CREATE IPTV==========\n"2952 placeholder += "other|zte|172.21.202.4|12-2|ZTEGC6753017;IPTV\n"2953 context = {2954 'page_title': page_title,2955 'vendors': vendor,2956 'placeholder': placeholder,2957 'client_ip': get_client_ip(request),2958 }2959 return render(request, 'config.html', context)2960@login_required(login_url=settings.URL_SEBELUM_LOGIN)2961@user_passes_test(check_permissions)2962def resultConfig(request):2963 if request.is_ajax():2964 if request.method == 'POST':2965 if request.session.modified == False:2966 del request.session['hasil']2967 del request.session['hw']2968 return JsonResponse(2969 {2970 'status' : True2971 }2972 )2973 if 'hasil' in request.session:2974 hasil = request.session['hasil']2975 hw = request.session['hw']2976 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))2977 context = {2978 'page_title': 'Result',2979 'vendors': vendor,2980 'hasil' : hasil,2981 'hw' : hw,2982 'client_ip': get_client_ip(request),2983 }2984 if request.session.modified == False:2985 del request.session['hasil']2986 del request.session['hw']2987 return render(request, 'result_config.html', context)2988 else:2989 return redirect('auto_tl1:home')2990@login_required(login_url=settings.URL_SEBELUM_LOGIN)2991def daftar_perangkat(request, vendor_tipe):2992 if session_login(request) == 'zero':2993 return redirect('login:formOtp')2994 if vendor_tipe == "zte":2995 page_title = "Perangkat GPON ZTE"2996 vendor_perangkat = "zte"2997 elif vendor_tipe == "fh":2998 page_title = "Perangkat GPON FIBERHOME"2999 vendor_perangkat = "fh"3000 else:3001 page_title = "Perangkat GPON HUAWEI"3002 vendor_perangkat = "hw"3003 gpon = GponDevice.objects.select_related('ip_server').filter(ip_server__vendor=vendor_tipe).order_by('sto', 'hostname')3004 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))3005 context = {3006 'page_title' : page_title,3007 'gpons': gpon,3008 'vendors': vendor,3009 'vendor_perangkat' : vendor_perangkat,3010 'client_ip': get_client_ip(request),3011 }3012 return render(request, 'perangkat.html', context)3013@login_required(login_url=settings.URL_SEBELUM_LOGIN)3014def serverNms(request):3015 if session_login(request) == 'zero':3016 return redirect('login:formOtp')3017 if request.method == 'POST':3018 if request.is_ajax():3019 server = ServerTl1.objects.get(ip_server=request.POST['ip_server'])3020 param = '-n 3' if platform.system().lower() == 'windows' else '-c 3'3021 restultado = os.popen(f'ping {param} {server.ip_server}').read()3022 if request.is_ajax():3023 if "TTL" in restultado:3024 server.status = 'up'3025 server.save()3026 else:3027 server.status = 'down'3028 server.save()3029 return JsonResponse({3030 'status': server.status3031 })3032 else:3033 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))3034 server = ServerTl1.objects.values('id', 'name', 'ip_server', 'vendor', 'status', 'vendor')3035 context = {3036 'page_title' : 'Server NMS',3037 'vendors' : vendor,3038 'servers' : server,3039 'client_ip': get_client_ip(request),3040 }3041 return render(request, 'servernms.html', context)3042@login_required(login_url=settings.URL_SEBELUM_LOGIN)3043def cekLogApp(request):3044 if session_login(request) == 'zero':3045 return redirect('login:formOtp')3046 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))3047 dataLog = LogApp.objects.all().order_by('-time')3048 context = {3049 'page_title': 'Log SAC',3050 'logapp' : dataLog,3051 'vendors': vendor,3052 'client_ip': get_client_ip(request),3053 }3054 return render(request, 'logapp.html', context)3055@login_required(login_url=settings.URL_SEBELUM_LOGIN)3056def cekLog(request, logappId):3057 if session_login(request) == 'zero':3058 return redirect('login:formOtp')3059 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))3060 dataLog = LogTL1.objects.filter(logapp_id=logappId)3061 context = {3062 'page_title': 'Log',3063 'logs' : dataLog,3064 'vendors': vendor,3065 'client_ip': get_client_ip(request),3066 }3067 return render(request, 'log.html', context)3068@login_required(login_url=settings.URL_SEBELUM_LOGIN)3069def cekLogDetail(request, log_id):3070 if session_login(request) == 'zero':3071 return redirect('login:formOtp')3072 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))3073 dataLog = LogTL1.objects.filter(pk=log_id)3074 context = {3075 'page_title': 'Log',3076 'logs': dataLog,3077 'vendors': vendor,3078 'client_ip': get_client_ip(request),3079 }3080 return render(request, 'logdetail.html', context)3081@login_required(login_url=settings.URL_SEBELUM_LOGIN)3082def nossfLog(request):3083 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))3084 r = requests.get('http://cmon.telkom.co.id/cacti/noss-osm/cekorder.log')3085 data = []3086 data.append('')3087 content = r.content.decode()3088 if r.status_code == 200 and 'Mercusuar' not in content:3089 data.append(content)3090 data = '\n'.join(data)3091 context = {3092 'page_title': 'Log NOSS-F',3093 'vendors': vendor,3094 'client_ip': get_client_ip(request),3095 'nossflog' : data3096 }3097 elif r.status_code == 500:3098 context = {3099 'page_title': 'Log NOSS-F',3100 'vendors': vendor,3101 'client_ip': get_client_ip(request),3102 'nossflog': 'empty'3103 }3104 else:3105 context = {3106 'page_title': 'Log NOSS-F',3107 'vendors': vendor,3108 'client_ip': get_client_ip(request),3109 'nossflog': 'empty'3110 }3111 return render(request, 'nossflog.html', context)3112@login_required(login_url=settings.URL_SEBELUM_LOGIN)3113@user_passes_test(check_permissions)3114def userActive(request):3115 if session_login(request) == 'zero':3116 return redirect('login:formOtp')3117 vendor = ServerTl1.objects.values('vendor').order_by('vendor').annotate(vcount=Count('vendor'))3118 context = {3119 'page_title' : 'User Active',3120 'vendors': vendor,3121 'client_ip': get_client_ip(request),3122 }3123 return render(request, 'user_active.html', context)3124@user_passes_test(check_permissions)3125def tbUserActive(request, sessionid):3126 if session_login(request) == 'zero':3127 return redirect('login:formOtp')3128 if sessionid == request.COOKIES['sessionid']:3129 userActive = UserActive.objects.all().order_by('-last_login')3130 context = {3131 'userActives' : userActive,3132 }3133 return render(request, 'tb_user_active.html', context)3134@login_required(login_url=settings.URL_SEBELUM_LOGIN)3135def getPdf(request, vendor_tipe):3136 if session_login(request) == 'zero':3137 return redirect('login:formOtp')3138 if vendor_tipe == "zte":3139 page_title = "Perangkat GPON ZTE"3140 elif vendor_tipe == "fh":3141 page_title = "Perangkat GPON FIBERHOME"3142 else:3143 page_title = "Perangkat GPON HUAWEI"3144 gpon = GponDevice.objects.select_related('ip_server').filter(ip_server__vendor=vendor_tipe).order_by('sto', 'hostname')3145 context = {3146 'page_title': page_title,3147 'gpons': gpon,3148 'date' : datetime.now(),3149 'client_ip': get_client_ip(request),3150 }3151 pdf = render_to_pdf('cetak_perangkat.html', context)3152 return HttpResponse(pdf, content_type='application/pdf')3153@login_required(login_url=settings.URL_SEBELUM_LOGIN)3154def getExcel(request, vendor_tipe):3155 if session_login(request) == 'zero':3156 return redirect('login:formOtp')3157 response = HttpResponse(content_type='application/ms-excel')3158 response['Content-Disposition'] = 'attachment; filename="Gpon.xls"'3159 wb = xlwt.Workbook(encoding='utf-8')3160 ws = wb.add_sheet('GPON')3161 # Sheet header, first row3162 row_num = 03163 font_style = xlwt.XFStyle()3164 font_style.font.bold = True3165 columns = ['HOSTNAME', 'IP GPON', 'VLAN INTERNET', 'VLAN VOICE', 'STO', 'SERVER', ]3166 for col_num in range(len(columns)):3167 ws.write(row_num, col_num, columns[col_num], font_style)3168 # Sheet body, remaining rows3169 font_style = xlwt.XFStyle()3170 rows = GponDevice.objects.select_related('ip_server').filter(ip_server__vendor=vendor_tipe).values_list('hostname', 'ip_gpon', 'vlan_inet', 'vlan_voice', 'sto__sto_name', 'ip_server__name', )3171 for row in rows:3172 row_num += 13173 for col_num in range(len(row)):3174 ws.write(row_num, col_num, row[col_num], font_style)3175 wb.save(response)3176 return response3177class GponApi(APIView):3178 def get(self, request):3179 gpon = GponDevice.objects.all()3180 serializer = GponSerializer(gpon, many=True)3181 return Response({'gpon' : serializer.data})3182 def post(self, request):3183 gpon = GponDevice.objects.all()3184 serializer = GponSerializer(data=gpon)3185 if serializer.is_valid(raise_exception=True):3186 gpon_saved = serializer.save()3187 return Response({'success' : f"Gpon {gpon_saved.hostname} create successfully"})3188@api_view(['GET'])3189def gpon_all_api(request):3190 gpon = GponDevice.objects.all()3191 serializer = GponSerializer(gpon, many=True)3192 return JsonResponse({"data_gpon" : serializer.data})3193@api_view(['GET'])3194def gpon_get_api(request, name_gpon):3195 gpon = GponDevice.objects.filter(sto__sto_code=name_gpon)3196 serializer = GponSerializer(gpon, many=True)3197 datas = serializer.data3198 return JsonResponse(datas, safe=False)3199@api_view(['POST'])3200def login_api(request):3201 username_login = request.POST['username']3202 password_login = request.POST['password']3203 user = authenticate(request, username=username_login, password=password_login)3204 data = {'status' : 'failed'}3205 if user is not None:3206 data['status'] = "success"3207 user_data = User.objects.get(username=username_login)3208 data['user'] = user_data.username3209 if user_data.is_staff:3210 data['level'] = 'admin'3211 else:3212 data['level'] = 'superadmin'...

Full Screen

Full Screen

svga_dump.py

Source:svga_dump.py Github

copy

Full Screen

1#!/usr/bin/env python2'''3Generates dumper for the SVGA 3D command stream using pygccxml.4Jose Fonseca <jfonseca@vmware.com>5'''6copyright = '''7/**********************************************************8 * Copyright 2009 VMware, Inc. All rights reserved.9 *10 * Permission is hereby granted, free of charge, to any person11 * obtaining a copy of this software and associated documentation12 * files (the "Software"), to deal in the Software without13 * restriction, including without limitation the rights to use, copy,14 * modify, merge, publish, distribute, sublicense, and/or sell copies15 * of the Software, and to permit persons to whom the Software is16 * furnished to do so, subject to the following conditions:17 *18 * The above copyright notice and this permission notice shall be19 * included in all copies or substantial portions of the Software.20 *21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND24 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS25 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN26 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN27 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE28 * SOFTWARE.29 *30 **********************************************************/31 '''32import os33import sys34from pygccxml import parser35from pygccxml import declarations36from pygccxml.declarations import algorithm37from pygccxml.declarations import decl_visitor38from pygccxml.declarations import type_traits39from pygccxml.declarations import type_visitor40enums = True41class decl_dumper_t(decl_visitor.decl_visitor_t):42 def __init__(self, instance = '', decl = None):43 decl_visitor.decl_visitor_t.__init__(self)44 self._instance = instance45 self.decl = decl46 def clone(self):47 return decl_dumper_t(self._instance, self.decl)48 def visit_class(self):49 class_ = self.decl50 assert self.decl.class_type in ('struct', 'union')51 for variable in class_.variables():52 if variable.name != '':53 #print 'variable = %r' % variable.name54 dump_type(self._instance + '.' + variable.name, variable.type)55 def visit_enumeration(self):56 if enums:57 print ' switch(%s) {' % ("(*cmd)" + self._instance,)58 for name, value in self.decl.values:59 print ' case %s:' % (name,)60 print ' _debug_printf("\\t\\t%s = %s\\n");' % (self._instance, name)61 print ' break;'62 print ' default:'63 print ' _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)64 print ' break;'65 print ' }'66 else:67 print ' _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)68def dump_decl(instance, decl):69 dumper = decl_dumper_t(instance, decl)70 algorithm.apply_visitor(dumper, decl)71class type_dumper_t(type_visitor.type_visitor_t):72 def __init__(self, instance, type_):73 type_visitor.type_visitor_t.__init__(self)74 self.instance = instance75 self.type = type_76 def clone(self):77 return type_dumper_t(self.instance, self.type)78 def visit_char(self):79 self.print_instance('%i')80 81 def visit_unsigned_char(self):82 self.print_instance('%u')83 def visit_signed_char(self):84 self.print_instance('%i')85 86 def visit_wchar(self):87 self.print_instance('%i')88 89 def visit_short_int(self):90 self.print_instance('%i')91 92 def visit_short_unsigned_int(self):93 self.print_instance('%u')94 95 def visit_bool(self):96 self.print_instance('%i')97 98 def visit_int(self):99 self.print_instance('%i')100 101 def visit_unsigned_int(self):102 self.print_instance('%u')103 104 def visit_long_int(self):105 self.print_instance('%li')106 107 def visit_long_unsigned_int(self):108 self.print_instance('%lu')109 110 def visit_long_long_int(self):111 self.print_instance('%lli')112 113 def visit_long_long_unsigned_int(self):114 self.print_instance('%llu')115 116 def visit_float(self):117 self.print_instance('%f')118 119 def visit_double(self):120 self.print_instance('%f')121 122 def visit_array(self):123 for i in range(type_traits.array_size(self.type)):124 dump_type(self.instance + '[%i]' % i, type_traits.base_type(self.type))125 def visit_pointer(self):126 self.print_instance('%p')127 def visit_declarated(self):128 #print 'decl = %r' % self.type.decl_string129 decl = type_traits.remove_declarated(self.type)130 dump_decl(self.instance, decl)131 def print_instance(self, format):132 print ' _debug_printf("\\t\\t%s = %s\\n", %s);' % (self.instance, format, "(*cmd)" + self.instance)133def dump_type(instance, type_):134 type_ = type_traits.remove_alias(type_)135 visitor = type_dumper_t(instance, type_)136 algorithm.apply_visitor(visitor, type_)137def dump_struct(decls, class_):138 print 'static void'139 print 'dump_%s(const %s *cmd)' % (class_.name, class_.name)140 print '{'141 dump_decl('', class_)142 print '}'143 print ''144cmds = [145 ('SVGA_3D_CMD_SURFACE_DEFINE', 'SVGA3dCmdDefineSurface', (), 'SVGA3dSize'),146 ('SVGA_3D_CMD_SURFACE_DESTROY', 'SVGA3dCmdDestroySurface', (), None),147 ('SVGA_3D_CMD_SURFACE_COPY', 'SVGA3dCmdSurfaceCopy', (), 'SVGA3dCopyBox'),148 ('SVGA_3D_CMD_SURFACE_STRETCHBLT', 'SVGA3dCmdSurfaceStretchBlt', (), None),149 ('SVGA_3D_CMD_SURFACE_DMA', 'SVGA3dCmdSurfaceDMA', (), 'SVGA3dCopyBox'),150 ('SVGA_3D_CMD_CONTEXT_DEFINE', 'SVGA3dCmdDefineContext', (), None),151 ('SVGA_3D_CMD_CONTEXT_DESTROY', 'SVGA3dCmdDestroyContext', (), None),152 ('SVGA_3D_CMD_SETTRANSFORM', 'SVGA3dCmdSetTransform', (), None),153 ('SVGA_3D_CMD_SETZRANGE', 'SVGA3dCmdSetZRange', (), None),154 ('SVGA_3D_CMD_SETRENDERSTATE', 'SVGA3dCmdSetRenderState', (), 'SVGA3dRenderState'),155 ('SVGA_3D_CMD_SETRENDERTARGET', 'SVGA3dCmdSetRenderTarget', (), None),156 ('SVGA_3D_CMD_SETTEXTURESTATE', 'SVGA3dCmdSetTextureState', (), 'SVGA3dTextureState'),157 ('SVGA_3D_CMD_SETMATERIAL', 'SVGA3dCmdSetMaterial', (), None),158 ('SVGA_3D_CMD_SETLIGHTDATA', 'SVGA3dCmdSetLightData', (), None),159 ('SVGA_3D_CMD_SETLIGHTENABLED', 'SVGA3dCmdSetLightEnabled', (), None),160 ('SVGA_3D_CMD_SETVIEWPORT', 'SVGA3dCmdSetViewport', (), None),161 ('SVGA_3D_CMD_SETCLIPPLANE', 'SVGA3dCmdSetClipPlane', (), None),162 ('SVGA_3D_CMD_CLEAR', 'SVGA3dCmdClear', (), 'SVGA3dRect'),163 ('SVGA_3D_CMD_PRESENT', 'SVGA3dCmdPresent', (), 'SVGA3dCopyRect'),164 ('SVGA_3D_CMD_SHADER_DEFINE', 'SVGA3dCmdDefineShader', (), None),165 ('SVGA_3D_CMD_SHADER_DESTROY', 'SVGA3dCmdDestroyShader', (), None),166 ('SVGA_3D_CMD_SET_SHADER', 'SVGA3dCmdSetShader', (), None),167 ('SVGA_3D_CMD_SET_SHADER_CONST', 'SVGA3dCmdSetShaderConst', (), None),168 ('SVGA_3D_CMD_DRAW_PRIMITIVES', 'SVGA3dCmdDrawPrimitives', (('SVGA3dVertexDecl', 'numVertexDecls'), ('SVGA3dPrimitiveRange', 'numRanges')), 'SVGA3dVertexDivisor'),169 ('SVGA_3D_CMD_SETSCISSORRECT', 'SVGA3dCmdSetScissorRect', (), None),170 ('SVGA_3D_CMD_BEGIN_QUERY', 'SVGA3dCmdBeginQuery', (), None),171 ('SVGA_3D_CMD_END_QUERY', 'SVGA3dCmdEndQuery', (), None),172 ('SVGA_3D_CMD_WAIT_FOR_QUERY', 'SVGA3dCmdWaitForQuery', (), None),173 #('SVGA_3D_CMD_PRESENT_READBACK', None, (), None),174 ('SVGA_3D_CMD_BLIT_SURFACE_TO_SCREEN', 'SVGA3dCmdBlitSurfaceToScreen', (), 'SVGASignedRect'),175]176def dump_cmds():177 print r'''178void 179svga_dump_command(uint32_t cmd_id, const void *data, uint32_t size)180{181 const uint8_t *body = (const uint8_t *)data;182 const uint8_t *next = body + size;183'''184 print ' switch(cmd_id) {'185 indexes = 'ijklmn'186 for id, header, body, footer in cmds:187 print ' case %s:' % id188 print ' _debug_printf("\\t%s\\n");' % id189 print ' {'190 print ' const %s *cmd = (const %s *)body;' % (header, header)191 if len(body):192 print ' unsigned ' + ', '.join(indexes[:len(body)]) + ';'193 print ' dump_%s(cmd);' % header194 print ' body = (const uint8_t *)&cmd[1];'195 for i in range(len(body)):196 struct, count = body[i]197 idx = indexes[i]198 print ' for(%s = 0; %s < cmd->%s; ++%s) {' % (idx, idx, count, idx)199 print ' dump_%s((const %s *)body);' % (struct, struct)200 print ' body += sizeof(%s);' % struct201 print ' }'202 if footer is not None:203 print ' while(body + sizeof(%s) <= next) {' % footer204 print ' dump_%s((const %s *)body);' % (footer, footer)205 print ' body += sizeof(%s);' % footer206 print ' }'207 if id == 'SVGA_3D_CMD_SHADER_DEFINE':208 print ' svga_shader_dump((const uint32_t *)body,'209 print ' (unsigned)(next - body)/sizeof(uint32_t),'210 print ' FALSE);'211 print ' body = next;'212 print ' }'213 print ' break;'214 print ' default:'215 print ' _debug_printf("\\t0x%08x\\n", cmd_id);'216 print ' break;'217 print ' }'218 print r'''219 while(body + sizeof(uint32_t) <= next) {220 _debug_printf("\t\t0x%08x\n", *(const uint32_t *)body);221 body += sizeof(uint32_t);222 }223 while(body + sizeof(uint32_t) <= next)224 _debug_printf("\t\t0x%02x\n", *body++);225}226'''227 print r'''228void 229svga_dump_commands(const void *commands, uint32_t size)230{231 const uint8_t *next = commands;232 const uint8_t *last = next + size;233 234 assert(size % sizeof(uint32_t) == 0);235 236 while(next < last) {237 const uint32_t cmd_id = *(const uint32_t *)next;238 if(SVGA_3D_CMD_BASE <= cmd_id && cmd_id < SVGA_3D_CMD_MAX) {239 const SVGA3dCmdHeader *header = (const SVGA3dCmdHeader *)next;240 const uint8_t *body = (const uint8_t *)&header[1];241 next = body + header->size;242 if(next > last)243 break;244 svga_dump_command(cmd_id, body, header->size);245 }246 else if(cmd_id == SVGA_CMD_FENCE) {247 _debug_printf("\tSVGA_CMD_FENCE\n");248 _debug_printf("\t\t0x%08x\n", ((const uint32_t *)next)[1]);249 next += 2*sizeof(uint32_t);250 }251 else {252 _debug_printf("\t0x%08x\n", cmd_id);253 next += sizeof(uint32_t);254 }255 }256}257'''258def main():259 print copyright.strip()260 print261 print '/**'262 print ' * @file'263 print ' * Dump SVGA commands.'264 print ' *'265 print ' * Generated automatically from svga3d_reg.h by svga_dump.py.'266 print ' */'267 print268 print '#include "svga_types.h"'269 print '#include "svga_shader_dump.h"'270 print '#include "svga3d_reg.h"'271 print272 print '#include "util/u_debug.h"'273 print '#include "svga_dump.h"'274 print275 config = parser.config_t(276 include_paths = ['../../../include', '../include'],277 compiler = 'gcc',278 )279 headers = [280 'svga_types.h', 281 'svga3d_reg.h', 282 ]283 decls = parser.parse(headers, config, parser.COMPILATION_MODE.ALL_AT_ONCE)284 global_ns = declarations.get_global_namespace(decls)285 names = set()286 for id, header, body, footer in cmds:287 names.add(header)288 for struct, count in body:289 names.add(struct)290 if footer is not None:291 names.add(footer)292 for class_ in global_ns.classes(lambda decl: decl.name in names):293 dump_struct(decls, class_)294 dump_cmds()295if __name__ == '__main__':...

Full Screen

Full Screen

SSDB.py

Source:SSDB.py Github

copy

Full Screen

1# encoding=utf-82# Generated by cpy3# 2016-04-11 20:40:38.1746344import os, sys5from sys import stdin, stdout6import socket7class SSDB_Response(object):8 pass9 def __init__(this, code='', data_or_message=None):10 pass11 this.type = 'none'12 this.code = code13 this.data = None14 this.message = None15 this.set(code, data_or_message)16 def set(this, code, data_or_message=None):17 pass18 this.code = code19 if code=='ok':20 pass21 this.data = data_or_message22 else:23 pass24 if isinstance(data_or_message, list):25 pass26 if len(data_or_message)>0:27 pass28 this.message = data_or_message[0]29 else:30 pass31 this.message = data_or_message32 def __repr__(this):33 pass34 return ((((str(this.code) + ' ') + str(this.message)) + ' ') + str(this.data))35 def ok(this):36 pass37 return this.code=='ok'38 def not_found(this):39 pass40 return this.code=='not_found'41 def str_resp(this, resp):42 pass43 this.type = 'val'44 if resp[0]=='ok':45 pass46 if len(resp)==2:47 pass48 this.set('ok', resp[1])49 else:50 pass51 this.set('server_error', 'Invalid response')52 else:53 pass54 this.set(resp[0], resp[1 : ])55 return this56 def str_resp(this, resp):57 pass58 this.type = 'val'59 if resp[0]=='ok':60 pass61 if len(resp)==2:62 pass63 this.set('ok', resp[1])64 else:65 pass66 this.set('server_error', 'Invalid response')67 else:68 pass69 this.set(resp[0], resp[1 : ])70 return this71 def int_resp(this, resp):72 pass73 this.type = 'val'74 if resp[0]=='ok':75 pass76 if len(resp)==2:77 pass78 try:79 pass80 val = int(resp[1])81 this.set('ok', val)82 except Exception , e:83 pass84 this.set('server_error', 'Invalid response')85 else:86 pass87 this.set('server_error', 'Invalid response')88 else:89 pass90 this.set(resp[0], resp[1 : ])91 return this92 def float_resp(this, resp):93 pass94 this.type = 'val'95 if resp[0]=='ok':96 pass97 if len(resp)==2:98 pass99 try:100 pass101 val = float(resp[1])102 this.set('ok', val)103 except Exception , e:104 pass105 this.set('server_error', 'Invalid response')106 else:107 pass108 this.set('server_error', 'Invalid response')109 else:110 pass111 this.set(resp[0], resp[1 : ])112 return this113 def list_resp(this, resp):114 pass115 this.type = 'list'116 this.set(resp[0], resp[1 : ])117 return this118 def int_map_resp(this, resp):119 pass120 this.type = 'map'121 if resp[0]=='ok':122 pass123 if len(resp) % 2==1:124 pass125 data = {'index': [],'items': {},}126 i = 1127 while i<len(resp):128 pass129 k = resp[i]130 v = resp[(i + 1)]131 try:132 pass133 v = int(v)134 except Exception , e:135 pass136 v = - (1)137 data['index'].append(k)138 data['items'][k] = v139 pass140 i += 2141 this.set('ok', data)142 else:143 pass144 this.set('server_error', 'Invalid response')145 else:146 pass147 this.set(resp[0], resp[1 : ])148 return this149 def str_map_resp(this, resp):150 pass151 this.type = 'map'152 if resp[0]=='ok':153 pass154 if len(resp) % 2==1:155 pass156 data = {'index': [],'items': {},}157 i = 1158 while i<len(resp):159 pass160 k = resp[i]161 v = resp[(i + 1)]162 data['index'].append(k)163 data['items'][k] = v164 pass165 i += 2166 this.set('ok', data)167 else:168 pass169 this.set('server_error', 'Invalid response')170 else:171 pass172 this.set(resp[0], resp[1 : ])173 return this174class SSDB(object):175 pass176 def __init__(this, host, port):177 pass178 this.recv_buf = ''179 this._closed = False180 this.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)181 this.sock.connect(tuple([host, port]))182 this.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)183 def close(this):184 pass185 if not (this._closed):186 pass187 this.sock.close()188 this._closed = True189 def closed(this):190 pass191 return this._closed192 def request(this, cmd, params=None):193 pass194 if params==None:195 pass196 params = []197 params = ([cmd] + params)198 this.send(params)199 resp = this.recv()200 if resp==None:201 pass202 return SSDB_Response('error', 'Unknown error')203 if len(resp)==0:204 pass205 return SSDB_Response('disconnected', 'Connection closed')206 ret = SSDB_Response()207 # {{{ switch: cmd208 _continue_1 = False209 while True:210 if False or ((cmd) == 'ping') or ((cmd) == 'set') or ((cmd) == 'del') or ((cmd) == 'qset') or ((cmd) == 'zset') or ((cmd) == 'hset') or ((cmd) == 'qpush') or ((cmd) == 'qpush_front') or ((cmd) == 'qpush_back') or ((cmd) == 'zdel') or ((cmd) == 'hdel') or ((cmd) == 'multi_set') or ((cmd) == 'multi_del') or ((cmd) == 'multi_hset') or ((cmd) == 'multi_hdel') or ((cmd) == 'multi_zset') or ((cmd) == 'multi_zdel'):211 pass212 if len(resp)>1:213 pass214 return ret.int_resp(resp)215 else:216 pass217 return SSDB_Response(resp[0], None)218 break219 if False or ((cmd) == 'version') or ((cmd) == 'substr') or ((cmd) == 'get') or ((cmd) == 'getset') or ((cmd) == 'hget') or ((cmd) == 'qfront') or ((cmd) == 'qback') or ((cmd) == 'qget'):220 pass221 return ret.str_resp(resp)222 break223 if False or ((cmd) == 'qpop') or ((cmd) == 'qpop_front') or ((cmd) == 'qpop_back'):224 pass225 size = 1226 try:227 pass228 size = int(params[2])229 except Exception , e:230 pass231 if size==1:232 pass233 return ret.str_resp(resp)234 else:235 pass236 return ret.list_resp(resp)237 break238 if False or ((cmd) == 'dbsize') or ((cmd) == 'getbit') or ((cmd) == 'setbit') or ((cmd) == 'countbit') or ((cmd) == 'bitcount') or ((cmd) == 'strlen') or ((cmd) == 'ttl') or ((cmd) == 'expire') or ((cmd) == 'setnx') or ((cmd) == 'incr') or ((cmd) == 'decr') or ((cmd) == 'zincr') or ((cmd) == 'zdecr') or ((cmd) == 'hincr') or ((cmd) == 'hdecr') or ((cmd) == 'hsize') or ((cmd) == 'zsize') or ((cmd) == 'qsize') or ((cmd) == 'zget') or ((cmd) == 'zrank') or ((cmd) == 'zrrank') or ((cmd) == 'zsum') or ((cmd) == 'zcount') or ((cmd) == 'zremrangebyrank') or ((cmd) == 'zremrangebyscore') or ((cmd) == 'hclear') or ((cmd) == 'zclear') or ((cmd) == 'qclear') or ((cmd) == 'qpush') or ((cmd) == 'qpush_front') or ((cmd) == 'qpush_back') or ((cmd) == 'qtrim_front') or ((cmd) == 'qtrim_back'):239 pass240 return ret.int_resp(resp)241 break242 if False or ((cmd) == 'zavg'):243 pass244 return ret.float_resp(resp)245 break246 if False or ((cmd) == 'keys') or ((cmd) == 'rkeys') or ((cmd) == 'zkeys') or ((cmd) == 'zrkeys') or ((cmd) == 'hkeys') or ((cmd) == 'hrkeys') or ((cmd) == 'list') or ((cmd) == 'hlist') or ((cmd) == 'hrlist') or ((cmd) == 'zlist') or ((cmd) == 'zrlist'):247 pass248 return ret.list_resp(resp)249 break250 if False or ((cmd) == 'scan') or ((cmd) == 'rscan') or ((cmd) == 'hgetall') or ((cmd) == 'hscan') or ((cmd) == 'hrscan'):251 pass252 return ret.str_map_resp(resp)253 break254 if False or ((cmd) == 'zscan') or ((cmd) == 'zrscan') or ((cmd) == 'zrange') or ((cmd) == 'zrrange') or ((cmd) == 'zpop_front') or ((cmd) == 'zpop_back'):255 pass256 return ret.int_map_resp(resp)257 break258 if False or ((cmd) == 'auth') or ((cmd) == 'exists') or ((cmd) == 'hexists') or ((cmd) == 'zexists'):259 pass260 return ret.int_resp(resp)261 break262 if False or ((cmd) == 'multi_exists') or ((cmd) == 'multi_hexists') or ((cmd) == 'multi_zexists'):263 pass264 return ret.int_map_resp(resp)265 break266 if False or ((cmd) == 'multi_get') or ((cmd) == 'multi_hget'):267 pass268 return ret.str_map_resp(resp)269 break270 if False or ((cmd) == 'multi_hsize') or ((cmd) == 'multi_zsize') or ((cmd) == 'multi_zget'):271 pass272 return ret.int_map_resp(resp)273 break274 ### default275 return ret.list_resp(resp)276 break277 break278 if _continue_1:279 continue280 # }}} switch281 return SSDB_Response('error', 'Unknown error')282 def send(this, data):283 pass284 ps = []285 _cpy_r_0 = _cpy_l_1 = data286 if type(_cpy_r_0).__name__ == 'dict': _cpy_b_3=True; _cpy_l_1=_cpy_r_0.iterkeys()287 else: _cpy_b_3=False;288 for _cpy_k_2 in _cpy_l_1:289 if _cpy_b_3: p=_cpy_r_0[_cpy_k_2]290 else: p=_cpy_k_2291 pass292 p = str(p)293 ps.append(str(len(p)))294 ps.append(p)295 nl = '\n'296 s = (nl.join(ps) + '\n\n')297 try:298 pass299 while True:300 pass301 ret = this.sock.send(s)302 if ret==0:303 pass304 return - (1)305 s = s[ret : ]306 if len(s)==0:307 pass308 break309 except socket.error , e:310 pass311 return - (1)312 return ret313 def net_read(this):314 pass315 try:316 pass317 data = this.sock.recv(1024 * 8)318 except Exception , e:319 pass320 data = ''321 if data=='':322 pass323 this.close()324 return 0325 this.recv_buf += data326 return len(data)327 def recv(this):328 pass329 while True:330 pass331 ret = this.parse()332 if ret==None:333 pass334 if this.net_read()==0:335 pass336 return []337 else:338 pass339 return ret340 def parse(this):341 pass342 ret = []343 spos = 0344 epos = 0345 while True:346 pass347 spos = epos348 epos = this.recv_buf.find('\n', spos)349 if epos==- (1):350 pass351 break352 epos += 1353 line = this.recv_buf[spos : epos]354 spos = epos355 if line.strip()=='':356 pass357 if len(ret)==0:358 pass359 continue360 else:361 pass362 this.recv_buf = this.recv_buf[spos : ]363 return ret364 try:365 pass366 num = int(line)367 except Exception , e:368 pass369 return []370 epos = (spos + num)371 if epos>len(this.recv_buf):372 pass373 break374 data = this.recv_buf[spos : epos]375 ret.append(data)376 spos = epos377 epos = this.recv_buf.find('\n', spos)378 if epos==- (1):379 pass380 break381 epos += 1...

Full Screen

Full Screen

qq.py

Source:qq.py Github

copy

Full Screen

1# $Id$2from dpkt import Packet3# header_type4QQ_HEADER_BASIC_FAMILY = 0x025QQ_HEADER_P2P_FAMILY = 0x006QQ_HEADER_03_FAMILY = 0x037QQ_HEADER_04_FAMILY = 0x048QQ_HEADER_05_FAMILY = 0x059header_type_str = [10 "QQ_HEADER_P2P_FAMILY",11 "Unknown Type",12 "QQ_HEADER_03_FAMILY",13 "QQ_HEADER_04_FAMILY",14 "QQ_HEADER_05_FAMILY",15]16# command17QQ_CMD_LOGOUT = 0x000118QQ_CMD_KEEP_ALIVE = 0x000219QQ_CMD_MODIFY_INFO = 0x000420QQ_CMD_SEARCH_USER = 0x000521QQ_CMD_GET_USER_INFO = 0x000622QQ_CMD_ADD_FRIEND = 0x000923QQ_CMD_DELETE_FRIEND = 0x000A24QQ_CMD_ADD_FRIEND_AUTH = 0x000B25QQ_CMD_CHANGE_STATUS = 0x000D26QQ_CMD_ACK_SYS_MSG = 0x001227QQ_CMD_SEND_IM = 0x001628QQ_CMD_RECV_IM = 0x001729QQ_CMD_REMOVE_SELF = 0x001C30QQ_CMD_REQUEST_KEY = 0x001D31QQ_CMD_LOGIN = 0x002232QQ_CMD_GET_FRIEND_LIST = 0x002633QQ_CMD_GET_ONLINE_OP = 0x002734QQ_CMD_SEND_SMS = 0x002D35QQ_CMD_CLUSTER_CMD = 0x003036QQ_CMD_TEST = 0x003137QQ_CMD_GROUP_DATA_OP = 0x003C38QQ_CMD_UPLOAD_GROUP_FRIEND = 0x003D39QQ_CMD_FRIEND_DATA_OP = 0x003E40QQ_CMD_DOWNLOAD_GROUP_FRIEND = 0x005841QQ_CMD_FRIEND_LEVEL_OP = 0x005C 42QQ_CMD_PRIVACY_DATA_OP = 0x005E43QQ_CMD_CLUSTER_DATA_OP = 0x005F44QQ_CMD_ADVANCED_SEARCH = 0x006145QQ_CMD_REQUEST_LOGIN_TOKEN = 0x006246QQ_CMD_USER_PROPERTY_OP = 0x006547QQ_CMD_TEMP_SESSION_OP = 0x006648QQ_CMD_SIGNATURE_OP = 0x006749QQ_CMD_RECV_MSG_SYS = 0x008050QQ_CMD_RECV_MSG_FRIEND_CHANGE_STATUS = 0x008151QQ_CMD_WEATHER_OP = 0x00A652QQ_CMD_ADD_FRIEND_EX = 0x00A753QQ_CMD_AUTHORIZE = 0X00A854QQ_CMD_UNKNOWN = 0xFFFF55QQ_SUB_CMD_SEARCH_ME_BY_QQ_ONLY = 0x0356QQ_SUB_CMD_SHARE_GEOGRAPHY = 0x0457QQ_SUB_CMD_GET_FRIEND_LEVEL = 0x0258QQ_SUB_CMD_GET_CLUSTER_ONLINE_MEMBER = 0x01 59QQ_05_CMD_REQUEST_AGENT = 0x002160QQ_05_CMD_REQUEST_FACE = 0x002261QQ_05_CMD_TRANSFER = 0x002362QQ_05_CMD_REQUEST_BEGIN = 0x002663QQ_CLUSTER_CMD_CREATE_CLUSTER= 0x0164QQ_CLUSTER_CMD_MODIFY_MEMBER= 0x0265QQ_CLUSTER_CMD_MODIFY_CLUSTER_INFO= 0x0366QQ_CLUSTER_CMD_GET_CLUSTER_INFO= 0x0467QQ_CLUSTER_CMD_ACTIVATE_CLUSTER= 0x0568QQ_CLUSTER_CMD_SEARCH_CLUSTER= 0x0669QQ_CLUSTER_CMD_JOIN_CLUSTER= 0x0770QQ_CLUSTER_CMD_JOIN_CLUSTER_AUTH= 0x0871QQ_CLUSTER_CMD_EXIT_CLUSTER= 0x0972QQ_CLUSTER_CMD_SEND_IM= 0x0A73QQ_CLUSTER_CMD_GET_ONLINE_MEMBER= 0x0B74QQ_CLUSTER_CMD_GET_MEMBER_INFO= 0x0C75QQ_CLUSTER_CMD_MODIFY_CARD = 0x0E76QQ_CLUSTER_CMD_GET_CARD_BATCH= 0x0F77QQ_CLUSTER_CMD_GET_CARD = 0x1078QQ_CLUSTER_CMD_COMMIT_ORGANIZATION = 0x1179QQ_CLUSTER_CMD_UPDATE_ORGANIZATION= 0x1280QQ_CLUSTER_CMD_COMMIT_MEMBER_ORGANIZATION = 0x1381QQ_CLUSTER_CMD_GET_VERSION_ID= 0x1982QQ_CLUSTER_CMD_SEND_IM_EX = 0x1A83QQ_CLUSTER_CMD_SET_ROLE = 0x1B84QQ_CLUSTER_CMD_TRANSFER_ROLE = 0x1C85QQ_CLUSTER_CMD_CREATE_TEMP = 0x3086QQ_CLUSTER_CMD_MODIFY_TEMP_MEMBER = 0x3187QQ_CLUSTER_CMD_EXIT_TEMP = 0x3288QQ_CLUSTER_CMD_GET_TEMP_INFO = 0x3389QQ_CLUSTER_CMD_MODIFY_TEMP_INFO = 0x3490QQ_CLUSTER_CMD_SEND_TEMP_IM = 0x3591QQ_CLUSTER_CMD_SUB_CLUSTER_OP = 0x3692QQ_CLUSTER_CMD_ACTIVATE_TEMP = 0x3793QQ_CLUSTER_SUB_CMD_ADD_MEMBER = 0x0194QQ_CLUSTER_SUB_CMD_REMOVE_MEMBER = 0x0295QQ_CLUSTER_SUB_CMD_GET_SUBJECT_LIST = 0x0296QQ_CLUSTER_SUB_CMD_GET_DIALOG_LIST = 0x0197QQ_SUB_CMD_GET_ONLINE_FRIEND = 0x298QQ_SUB_CMD_GET_ONLINE_SERVICE = 0x399QQ_SUB_CMD_UPLOAD_GROUP_NAME = 0x2100QQ_SUB_CMD_DOWNLOAD_GROUP_NAME = 0x1101QQ_SUB_CMD_SEND_TEMP_SESSION_IM = 0x01102QQ_SUB_CMD_BATCH_DOWNLOAD_FRIEND_REMARK = 0x0103QQ_SUB_CMD_UPLOAD_FRIEND_REMARK = 0x1104QQ_SUB_CMD_REMOVE_FRIEND_FROM_LIST = 0x2105QQ_SUB_CMD_DOWNLOAD_FRIEND_REMARK = 0x3106QQ_SUB_CMD_MODIFY_SIGNATURE = 0x01107QQ_SUB_CMD_DELETE_SIGNATURE = 0x02108QQ_SUB_CMD_GET_SIGNATURE = 0x03109QQ_SUB_CMD_GET_USER_PROPERTY = 0x01110QQ_SUB_CMD_GET_WEATHER = 0x01111QQ_FILE_CMD_HEART_BEAT = 0x0001112QQ_FILE_CMD_HEART_BEAT_ACK = 0x0002113QQ_FILE_CMD_TRANSFER_FINISHED = 0x0003114QQ_FILE_CMD_FILE_OP = 0x0007115QQ_FILE_CMD_FILE_OP_ACK = 0x0008116QQ_FILE_CMD_SENDER_SAY_HELLO = 0x0031117QQ_FILE_CMD_SENDER_SAY_HELLO_ACK = 0x0032118QQ_FILE_CMD_RECEIVER_SAY_HELLO = 0x0033119QQ_FILE_CMD_RECEIVER_SAY_HELLO_ACK = 0x0034120QQ_FILE_CMD_NOTIFY_IP_ACK = 0x003C121QQ_FILE_CMD_PING = 0x003D122QQ_FILE_CMD_PONG = 0x003E123QQ_FILE_CMD_YES_I_AM_BEHIND_FIREWALL = 0x0040124QQ_FILE_CMD_REQUEST_AGENT = 0x0001125QQ_FILE_CMD_CHECK_IN = 0x0002126QQ_FILE_CMD_FORWARD = 0x0003127QQ_FILE_CMD_FORWARD_FINISHED = 0x0004128QQ_FILE_CMD_IT_IS_TIME = 0x0005129QQ_FILE_CMD_I_AM_READY = 0x0006130command_str = {131 0x0001: "QQ_CMD_LOGOUT",132 0x0002: "QQ_CMD_KEEP_ALIVE",133 0x0004: "QQ_CMD_MODIFY_INFO",134 0x0005: "QQ_CMD_SEARCH_USER",135 0x0006: "QQ_CMD_GET_USER_INFO",136 0x0009: "QQ_CMD_ADD_FRIEND",137 0x000A: "QQ_CMD_DELETE_FRIEND",138 0x000B: "QQ_CMD_ADD_FRIEND_AUTH",139 0x000D: "QQ_CMD_CHANGE_STATUS",140 0x0012: "QQ_CMD_ACK_SYS_MSG",141 0x0016: "QQ_CMD_SEND_IM",142 0x0017: "QQ_CMD_RECV_IM",143 0x001C: "QQ_CMD_REMOVE_SELF",144 0x001D: "QQ_CMD_REQUEST_KEY",145 0x0022: "QQ_CMD_LOGIN",146 0x0026: "QQ_CMD_GET_FRIEND_LIST",147 0x0027: "QQ_CMD_GET_ONLINE_OP",148 0x002D: "QQ_CMD_SEND_SMS",149 0x0030: "QQ_CMD_CLUSTER_CMD",150 0x0031: "QQ_CMD_TEST",151 0x003C: "QQ_CMD_GROUP_DATA_OP",152 0x003D: "QQ_CMD_UPLOAD_GROUP_FRIEND",153 0x003E: "QQ_CMD_FRIEND_DATA_OP",154 0x0058: "QQ_CMD_DOWNLOAD_GROUP_FRIEND",155 0x005C: "QQ_CMD_FRIEND_LEVEL_OP",156 0x005E: "QQ_CMD_PRIVACY_DATA_OP",157 0x005F: "QQ_CMD_CLUSTER_DATA_OP",158 0x0061: "QQ_CMD_ADVANCED_SEARCH",159 0x0062: "QQ_CMD_REQUEST_LOGIN_TOKEN",160 0x0065: "QQ_CMD_USER_PROPERTY_OP",161 0x0066: "QQ_CMD_TEMP_SESSION_OP",162 0x0067: "QQ_CMD_SIGNATURE_OP",163 0x0080: "QQ_CMD_RECV_MSG_SYS",164 0x0081: "QQ_CMD_RECV_MSG_FRIEND_CHANGE_STATUS",165 0x00A6: "QQ_CMD_WEATHER_OP",166 0x00A7: "QQ_CMD_ADD_FRIEND_EX",167 0x00A8: "QQ_CMD_AUTHORIZE",168 0xFFFF: "QQ_CMD_UNKNOWN",169 0x0021: "_CMD_REQUEST_AGENT",170 0x0022: "_CMD_REQUEST_FACE",171 0x0023: "_CMD_TRANSFER",172 0x0026: "_CMD_REQUEST_BEGIN",173}174class QQBasicPacket(Packet):175 __hdr__ = (176 ('header_type', 'B', 2),177 ('source', 'H', 0),178 ('command', 'H', 0),179 ('sequence', 'H', 0),180 ('qqNum', 'L', 0),181 )182class QQ3Packet(Packet):183 __hdr__ = (184 ('header_type', 'B', 3),185 ('command', 'B', 0),186 ('sequence', 'H', 0),187 ('unknown1', 'L', 0),188 ('unknown2', 'L', 0),189 ('unknown3', 'L', 0),190 ('unknown4', 'L', 0),191 ('unknown5', 'L', 0),192 ('unknown6', 'L', 0),193 ('unknown7', 'L', 0),194 ('unknown8', 'L', 0),195 ('unknown9', 'L', 0),196 ('unknown10', 'B', 1),197 ('unknown11', 'B', 0),198 ('unknown12', 'B', 0),199 ('source', 'H', 0),200 ('unknown13', 'B', 0),201 )202class QQ5Packet(Packet):203 __hdr__ = (204 ('header_type', 'B', 5),205 ('source', 'H', 0),206 ('unknown', 'H', 0),207 ('command', 'H', 0),208 ('sequence', 'H', 0),209 ('qqNum', 'L', 0),...

Full Screen

Full Screen

pydevd_comm_constants.py

Source:pydevd_comm_constants.py Github

copy

Full Screen

1CMD_RUN = 1012CMD_LIST_THREADS = 1023CMD_THREAD_CREATE = 1034CMD_THREAD_KILL = 1045CMD_THREAD_SUSPEND = 1056CMD_THREAD_RUN = 1067CMD_STEP_INTO = 1078CMD_STEP_OVER = 1089CMD_STEP_RETURN = 10910CMD_GET_VARIABLE = 11011CMD_SET_BREAK = 11112CMD_REMOVE_BREAK = 11213CMD_EVALUATE_EXPRESSION = 11314CMD_GET_FRAME = 11415CMD_EXEC_EXPRESSION = 11516CMD_WRITE_TO_CONSOLE = 11617CMD_CHANGE_VARIABLE = 11718CMD_RUN_TO_LINE = 11819CMD_RELOAD_CODE = 11920CMD_GET_COMPLETIONS = 1202122# Note: renumbered (conflicted on merge)23CMD_CONSOLE_EXEC = 12124CMD_ADD_EXCEPTION_BREAK = 12225CMD_REMOVE_EXCEPTION_BREAK = 12326CMD_LOAD_SOURCE = 12427CMD_ADD_DJANGO_EXCEPTION_BREAK = 12528CMD_REMOVE_DJANGO_EXCEPTION_BREAK = 12629CMD_SET_NEXT_STATEMENT = 12730CMD_SMART_STEP_INTO = 12831CMD_EXIT = 12932CMD_SIGNATURE_CALL_TRACE = 1303334CMD_SET_PY_EXCEPTION = 13135CMD_GET_FILE_CONTENTS = 13236CMD_SET_PROPERTY_TRACE = 13337# Pydev debug console commands38CMD_EVALUATE_CONSOLE_EXPRESSION = 13439CMD_RUN_CUSTOM_OPERATION = 13540CMD_GET_BREAKPOINT_EXCEPTION = 13641CMD_STEP_CAUGHT_EXCEPTION = 13742CMD_SEND_CURR_EXCEPTION_TRACE = 13843CMD_SEND_CURR_EXCEPTION_TRACE_PROCEEDED = 13944CMD_IGNORE_THROWN_EXCEPTION_AT = 14045CMD_ENABLE_DONT_TRACE = 14146CMD_SHOW_CONSOLE = 1424748CMD_GET_ARRAY = 14349CMD_STEP_INTO_MY_CODE = 14450CMD_GET_CONCURRENCY_EVENT = 14551CMD_SHOW_RETURN_VALUES = 14652CMD_INPUT_REQUESTED = 14753CMD_GET_DESCRIPTION = 1485455CMD_PROCESS_CREATED = 14956CMD_SHOW_CYTHON_WARNING = 15057CMD_LOAD_FULL_VALUE = 1515859CMD_GET_THREAD_STACK = 1526061# This is mostly for unit-tests to diagnose errors on ci.62CMD_THREAD_DUMP_TO_STDERR = 1536364# Sent from the client to signal that we should stop when we start executing user code.65CMD_STOP_ON_START = 1546667# When the debugger is stopped in an exception, this command will provide the details of the current exception (in the current thread).68CMD_GET_EXCEPTION_DETAILS = 1556970# Allows configuring pydevd settings (can be called multiple times and only keys71# available in the json will be configured -- keys not passed will not change the72# previous configuration).73CMD_PYDEVD_JSON_CONFIG = 1567475CMD_THREAD_SUSPEND_SINGLE_NOTIFICATION = 15776CMD_THREAD_RESUME_SINGLE_NOTIFICATION = 1587778CMD_STEP_OVER_MY_CODE = 15979CMD_STEP_RETURN_MY_CODE = 1608081CMD_REDIRECT_OUTPUT = 20082CMD_GET_NEXT_STATEMENT_TARGETS = 20183CMD_SET_PROJECT_ROOTS = 2028485CMD_MODULE_EVENT = 20386CMD_PROCESS_EVENT = 2048788CMD_AUTHENTICATE = 2058990CMD_STEP_INTO_COROUTINE = 2069192CMD_LOAD_SOURCE_FROM_FRAME_ID = 2079394CMD_VERSION = 50195CMD_RETURN = 50296CMD_SET_PROTOCOL = 50397CMD_ERROR = 9019899# this number can be changed if there's need to do so100# if the io is too big, we'll not send all (could make the debugger too non-responsive)101MAX_IO_MSG_SIZE = 10000102103VERSION_STRING = "@@BUILD_NUMBER@@"104105from _pydev_bundle._pydev_filesystem_encoding import getfilesystemencoding106file_system_encoding = getfilesystemencoding()107filesystem_encoding_is_utf8 = file_system_encoding.lower() in ('utf-8', 'utf_8', 'utf8')108109ID_TO_MEANING = {110 '101': 'CMD_RUN',111 '102': 'CMD_LIST_THREADS',112 '103': 'CMD_THREAD_CREATE',113 '104': 'CMD_THREAD_KILL',114 '105': 'CMD_THREAD_SUSPEND',115 '106': 'CMD_THREAD_RUN',116 '107': 'CMD_STEP_INTO',117 '108': 'CMD_STEP_OVER',118 '109': 'CMD_STEP_RETURN',119 '110': 'CMD_GET_VARIABLE',120 '111': 'CMD_SET_BREAK',121 '112': 'CMD_REMOVE_BREAK',122 '113': 'CMD_EVALUATE_EXPRESSION',123 '114': 'CMD_GET_FRAME',124 '115': 'CMD_EXEC_EXPRESSION',125 '116': 'CMD_WRITE_TO_CONSOLE',126 '117': 'CMD_CHANGE_VARIABLE',127 '118': 'CMD_RUN_TO_LINE',128 '119': 'CMD_RELOAD_CODE',129 '120': 'CMD_GET_COMPLETIONS',130 '121': 'CMD_CONSOLE_EXEC',131 '122': 'CMD_ADD_EXCEPTION_BREAK',132 '123': 'CMD_REMOVE_EXCEPTION_BREAK',133 '124': 'CMD_LOAD_SOURCE',134 '125': 'CMD_ADD_DJANGO_EXCEPTION_BREAK',135 '126': 'CMD_REMOVE_DJANGO_EXCEPTION_BREAK',136 '127': 'CMD_SET_NEXT_STATEMENT',137 '128': 'CMD_SMART_STEP_INTO',138 '129': 'CMD_EXIT',139 '130': 'CMD_SIGNATURE_CALL_TRACE',140141 '131': 'CMD_SET_PY_EXCEPTION',142 '132': 'CMD_GET_FILE_CONTENTS',143 '133': 'CMD_SET_PROPERTY_TRACE',144 '134': 'CMD_EVALUATE_CONSOLE_EXPRESSION',145 '135': 'CMD_RUN_CUSTOM_OPERATION',146 '136': 'CMD_GET_BREAKPOINT_EXCEPTION',147 '137': 'CMD_STEP_CAUGHT_EXCEPTION',148 '138': 'CMD_SEND_CURR_EXCEPTION_TRACE',149 '139': 'CMD_SEND_CURR_EXCEPTION_TRACE_PROCEEDED',150 '140': 'CMD_IGNORE_THROWN_EXCEPTION_AT',151 '141': 'CMD_ENABLE_DONT_TRACE',152 '142': 'CMD_SHOW_CONSOLE',153 '143': 'CMD_GET_ARRAY',154 '144': 'CMD_STEP_INTO_MY_CODE',155 '145': 'CMD_GET_CONCURRENCY_EVENT',156 '146': 'CMD_SHOW_RETURN_VALUES',157 '147': 'CMD_INPUT_REQUESTED',158 '148': 'CMD_GET_DESCRIPTION',159160 '149': 'CMD_PROCESS_CREATED', # Note: this is actually a notification of a sub-process created.161 '150': 'CMD_SHOW_CYTHON_WARNING',162 '151': 'CMD_LOAD_FULL_VALUE',163 '152': 'CMD_GET_THREAD_STACK',164 '153': 'CMD_THREAD_DUMP_TO_STDERR',165 '154': 'CMD_STOP_ON_START',166 '155': 'CMD_GET_EXCEPTION_DETAILS',167 '156': 'CMD_PYDEVD_JSON_CONFIG',168 '157': 'CMD_THREAD_SUSPEND_SINGLE_NOTIFICATION',169 '158': 'CMD_THREAD_RESUME_SINGLE_NOTIFICATION',170171 '159': 'CMD_STEP_OVER_MY_CODE',172 '160': 'CMD_STEP_RETURN_MY_CODE',173174 '200': 'CMD_REDIRECT_OUTPUT',175 '201': 'CMD_GET_NEXT_STATEMENT_TARGETS',176 '202': 'CMD_SET_PROJECT_ROOTS',177 '203': 'CMD_MODULE_EVENT',178 '204': 'CMD_PROCESS_EVENT', # DAP process event.179180 '205': 'CMD_AUTHENTICATE',181182 '206': 'CMD_STEP_INTO_COROUTINE',183184 '207': 'CMD_LOAD_SOURCE_FROM_FRAME_ID',185186 '501': 'CMD_VERSION',187 '502': 'CMD_RETURN',188 '503': 'CMD_SET_PROTOCOL',189 '901': 'CMD_ERROR',190}191192193def constant_to_str(constant):194 s = ID_TO_MEANING.get(str(constant))195 if not s:196 s = '<Unknown: %s>' % (constant,) ...

Full Screen

Full Screen

const.py

Source:const.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2USHRT_MAX = 655353CMD_DB_RRQ = 7 # Read in some kind of data from the machine4CMD_USER_WRQ = 8 # Upload the user information (from PC to terminal).5CMD_USERTEMP_RRQ = 9 # Read some fingerprint template or some kind of data entirely6CMD_USERTEMP_WRQ = 10 # Upload some fingerprint template7CMD_OPTIONS_RRQ = 11 # Read in the machine some configuration parameter8CMD_OPTIONS_WRQ = 12 # Set machines configuration parameter9CMD_ATTLOG_RRQ = 13 # Read all attendance record10CMD_CLEAR_DATA = 14 # clear Data11CMD_CLEAR_ATTLOG = 15 # Clear attendance records12CMD_DELETE_USER = 18 # Delete some user13CMD_DELETE_USERTEMP = 19 # Delete some fingerprint template14CMD_CLEAR_ADMIN = 20 # Cancel the manager15CMD_USERGRP_RRQ = 21 # Read the user grouping16CMD_USERGRP_WRQ = 22 # Set users grouping17CMD_USERTZ_RRQ = 23 # Read the user Time Zone set18CMD_USERTZ_WRQ = 24 # Write the user Time Zone set19CMD_GRPTZ_RRQ = 25 # Read the group Time Zone set20CMD_GRPTZ_WRQ = 26 # Write the group Time Zone set21CMD_TZ_RRQ = 27 # Read Time Zone set22CMD_TZ_WRQ = 28 # Write the Time Zone23CMD_ULG_RRQ = 29 # Read unlocks combination24CMD_ULG_WRQ = 30 # write unlocks combination25CMD_UNLOCK = 31 # unlock26CMD_CLEAR_ACC = 32 # Restores Access Control set to the default condition.27CMD_CLEAR_OPLOG = 33 # Delete attendance machines all attendance record.28CMD_OPLOG_RRQ = 34 # Read manages the record29CMD_GET_FREE_SIZES = 50 # Obtain machines condition, like user recording number and so on30CMD_ENABLE_CLOCK = 57 # Ensure the machine to be at the normal work condition31CMD_STARTVERIFY = 60 # Ensure the machine to be at the authentication condition32CMD_STARTENROLL = 61 # Start to enroll some user, ensure the machine to be at the registration user condition33CMD_CANCELCAPTURE = 62 # Make the machine to be at the waiting order status, please refers to the CMD_STARTENROLL description.34CMD_STATE_RRQ = 64 # Gain the machine the condition35CMD_WRITE_LCD = 66 # Write LCD36CMD_CLEAR_LCD = 67 # Clear the LCD captions (clear screen).37CMD_GET_PINWIDTH = 69 # Obtain the length of user’s serial number38CMD_SMS_WRQ = 70 # Upload the short message.39CMD_SMS_RRQ = 71 # Download the short message40CMD_DELETE_SMS = 72 # Delete the short message41CMD_UDATA_WRQ = 73 # Set user’s short message42CMD_DELETE_UDATA = 74 # Delete user’s short message43CMD_DOORSTATE_RRQ = 75 # Obtain the door condition44CMD_WRITE_MIFARE = 76 # Write the Mifare card45CMD_EMPTY_MIFARE = 78 # Clear the Mifare card46CMD_GET_TIME = 201 # Obtain the machine time47CMD_SET_TIME = 202 # Set machines time48CMD_REG_EVENT = 500 # Register the event49CMD_CONNECT = 1000 # Connections requests50CMD_EXIT = 1001 # Disconnection requests51CMD_ENABLEDEVICE = 1002 # Ensure the machine to be at the normal work condition52CMD_DISABLEDEVICE = 1003 # Make the machine to be at the shut-down condition, generally demonstrates ‘in the work ...’on LCD53CMD_RESTART = 1004 # Restart the machine.54CMD_POWEROFF = 1005 # Shut-down power source55CMD_SLEEP = 1006 # Ensure the machine to be at the idle state.56CMD_RESUME = 1007 # Awakens the sleep machine (temporarily not to support)57CMD_CAPTUREFINGER = 1009 # Captures fingerprints picture58CMD_TEST_TEMP = 1011 # Test some fingerprint exists or does not59CMD_CAPTUREIMAGE = 1012 # Capture the entire image60CMD_REFRESHDATA = 1013 # Refresh the machine interior data61CMD_REFRESHOPTION = 1014 # Refresh the configuration parameter62CMD_TESTVOICE = 1017 # Play voice63CMD_GET_VERSION = 1100 # Obtain the firmware edition64CMD_CHANGE_SPEED = 1101 # Change transmission speed65CMD_AUTH = 1102 # Connections authorizations66CMD_PREPARE_DATA = 1500 # Prepares to transmit the data67CMD_DATA = 1501 # Transmit a data packet68CMD_FREE_DATA = 1502 # Clear machines opened buffer69CMD_ACK_OK = 2000 # Return value for order perform successfully70CMD_ACK_ERROR = 2001 # Return value for order perform failed71CMD_ACK_DATA = 2002 # Return data72CMD_ACK_RETRY = 2003 # * Regstered event occorred */73CMD_ACK_REPEAT = 2004 # Not available74CMD_ACK_UNAUTH = 2005 # Connection unauthorized75CMD_ACK_UNKNOWN = 0xffff# Unkown order76CMD_ACK_ERROR_CMD = 0xfffd# Order false77CMD_ACK_ERROR_INIT = 0xfffc#/* Not Initializated */78CMD_ACK_ERROR_DATA = 0xfffb# Not available79EF_ATTLOG = 1 # Be real-time to verify successfully80EF_FINGER = (1<<1)# be real–time to press fingerprint (be real time to return data type sign)81EF_ENROLLUSER = (1<<2)# Be real-time to enroll user82EF_ENROLLFINGER = (1<<3)# be real-time to enroll fingerprint83EF_BUTTON = (1<<4)# be real-time to press button84EF_UNLOCK = (1<<5)# be real-time to unlock85EF_VERIFY = (1<<7)# be real-time to verify fingerprint86EF_FPFTR = (1<<8)# be real-time capture fingerprint minutia87EF_ALARM = (1<<9)# Alarm signal88USER_DEFAULT = 089USER_ENROLLER = 290USER_MANAGER = 691USER_ADMIN = 1492FCT_ATTLOG = 193FCT_WORKCODE = 894FCT_FINGERTMP = 295FCT_OPLOG = 496FCT_USER = 597FCT_SMS = 698FCT_UDATA = 799MACHINE_PREPARE_DATA_1 = 20560 # 0x5050...

Full Screen

Full Screen

test_cmd.py

Source:test_cmd.py Github

copy

Full Screen

1"""Tests for distutils.cmd."""2import unittest3import os4from test.test_support import captured_stdout, run_unittest56from distutils.cmd import Command7from distutils.dist import Distribution8from distutils.errors import DistutilsOptionError9from distutils import debug1011class MyCmd(Command):12 def initialize_options(self):13 pass1415class CommandTestCase(unittest.TestCase):1617 def setUp(self):18 dist = Distribution()19 self.cmd = MyCmd(dist)2021 def test_ensure_string_list(self):2223 cmd = self.cmd24 cmd.not_string_list = ['one', 2, 'three']25 cmd.yes_string_list = ['one', 'two', 'three']26 cmd.not_string_list2 = object()27 cmd.yes_string_list2 = 'ok'28 cmd.ensure_string_list('yes_string_list')29 cmd.ensure_string_list('yes_string_list2')3031 self.assertRaises(DistutilsOptionError,32 cmd.ensure_string_list, 'not_string_list')3334 self.assertRaises(DistutilsOptionError,35 cmd.ensure_string_list, 'not_string_list2')3637 cmd.option1 = 'ok,dok'38 cmd.ensure_string_list('option1')39 self.assertEqual(cmd.option1, ['ok', 'dok'])4041 cmd.option2 = ['xxx', 'www']42 cmd.ensure_string_list('option2')4344 cmd.option3 = ['ok', 2]45 self.assertRaises(DistutilsOptionError, cmd.ensure_string_list,46 'option3')474849 def test_make_file(self):5051 cmd = self.cmd5253 # making sure it raises when infiles is not a string or a list/tuple54 self.assertRaises(TypeError, cmd.make_file,55 infiles=1, outfile='', func='func', args=())5657 # making sure execute gets called properly58 def _execute(func, args, exec_msg, level):59 self.assertEqual(exec_msg, 'generating out from in')60 cmd.force = True61 cmd.execute = _execute62 cmd.make_file(infiles='in', outfile='out', func='func', args=())6364 def test_dump_options(self):6566 msgs = []67 def _announce(msg, level):68 msgs.append(msg)69 cmd = self.cmd70 cmd.announce = _announce71 cmd.option1 = 172 cmd.option2 = 173 cmd.user_options = [('option1', '', ''), ('option2', '', '')]74 cmd.dump_options()7576 wanted = ["command options for 'MyCmd':", ' option1 = 1',77 ' option2 = 1']78 self.assertEqual(msgs, wanted)7980 def test_ensure_string(self):81 cmd = self.cmd82 cmd.option1 = 'ok'83 cmd.ensure_string('option1')8485 cmd.option2 = None86 cmd.ensure_string('option2', 'xxx')87 self.assertTrue(hasattr(cmd, 'option2'))8889 cmd.option3 = 190 self.assertRaises(DistutilsOptionError, cmd.ensure_string, 'option3')9192 def test_ensure_filename(self):93 cmd = self.cmd94 cmd.option1 = __file__95 cmd.ensure_filename('option1')96 cmd.option2 = 'xxx'97 self.assertRaises(DistutilsOptionError, cmd.ensure_filename, 'option2')9899 def test_ensure_dirname(self):100 cmd = self.cmd101 cmd.option1 = os.path.dirname(__file__) or os.curdir102 cmd.ensure_dirname('option1')103 cmd.option2 = 'xxx'104 self.assertRaises(DistutilsOptionError, cmd.ensure_dirname, 'option2')105106 def test_debug_print(self):107 cmd = self.cmd108 with captured_stdout() as stdout:109 cmd.debug_print('xxx')110 stdout.seek(0)111 self.assertEqual(stdout.read(), '')112113 debug.DEBUG = True114 try:115 with captured_stdout() as stdout:116 cmd.debug_print('xxx')117 stdout.seek(0)118 self.assertEqual(stdout.read(), 'xxx\n')119 finally:120 debug.DEBUG = False121122def test_suite():123 return unittest.makeSuite(CommandTestCase)124125if __name__ == '__main__': ...

Full Screen

Full Screen

open_qa-installer.py

Source:open_qa-installer.py Github

copy

Full Screen

2import time3import sys4import os5from optparse import OptionParser6def run_cmd(command):7 print "CMD: " + command8 print9 os.system(command)10 print 11 time.sleep(1)12 return13def main():14 print15 print "===== OPEN QA INSTALLER ON AWS ======"16 print17 parser = OptionParser()18 parser.add_option("-t", "--instance-type", dest="instance", help="linux distro instance type: ['amazon-linux', 'rhel6']")19 parser.add_option("-e", "--email", dest="email", help="admin email")20 (options, args) = parser.parse_args()21 if options.instance is None:22 print "Need Input 'instance'; Use --help Option"23 exit()24 25 if options.email is None:26 print "Need Input 'email'; Use --help Option"27 exit()28 print "=== ENVIRONMENT ==="29 print30 print "INSTANCE TYPE: " + options.instance31 print "EMAL: " + options.email32 print33 print34 cmd = "sudo yum -y update"35 run_cmd(cmd)36 cmd = "sudo yum -y install httpd"37 run_cmd(cmd)38 39 cmd = "sudo chkconfig httpd on"40 run_cmd(cmd)41 42 cmd = "sudo service httpd start"43 run_cmd(cmd)44 45 cmd = "sudo netstat -tulpn | grep :80"46 run_cmd(cmd)47 48 cmd = "sudo httpd -V"49 run_cmd(cmd)50 cmd = "sudo sed --in-place 's/#HTTPD=/HTTPD=/' /etc/sysconfig/httpd"51 run_cmd(cmd)52 cmd = "sudo sed --in-place 's/ServerAdmin .*/ServerAdmin " + options.email + "/' /etc/httpd/conf/httpd.conf"53 run_cmd(cmd)54 55 cmd = "sudo yum -y install php"56 run_cmd(cmd)57 if options.instance is "rhel6":58 cmd = "sudo yum -y install php-zts"59 run_cmd(cmd)60 cmd = "sudo ln --symbolic --force /usr/share/zoneinfo/America/Los_Angeles /etc/localtime"61 run_cmd(cmd)62 cmd = "sudo service ntpd restart"63 run_cmd(cmd)64 cmd = "sudo service httpd restart"65 run_cmd(cmd)66 cmd = "sudo cp -r ../../open-qa/. /var/www/html/."67 run_cmd(cmd)68 print69 print "===== OPEN QA INSTALLER ON AWS : DONE ====="70 print71if __name__ == "__main__":72 main()...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { cmd } = require('fast-check-monorepo');2const { check } = require('fast-check');3check(4 cmd(5 (a, b) => {6 const c = a + b;7 return c;8 },9 { numRuns: 100 }10);11const { cmd } = require('fast-check');12const { check } = require('fast-check');13check(14 cmd(15 (a, b) => {16 const c = a + b;17 return c;18 },19 { numRuns: 100 }20);21It seems that the cmd method of fast-check is not compatible with the check method of fast-check. I can't use the cmd method of fast-check-monorepo because it doesn't have the full set of methods (such as string16bits, array, etc.) that the cmd method of fast-check has. I also can't use the cmd method of fast-check because it doesn't have the full set of methods (such as cmd, modelRun, etc.) that the cmd method of fast-check-monorepo has. Is there a way to use the cmd method of fast-check-monorepo with the check method of fast-check-monorepo?22const { check, property } = require('fast-check');23function reverseString(str) {24 .split('')25 .reverse()26 .join('');27}28describe('reverseString', () => {29 it('should reverse a string', () => {30 check(31 property(32 str => {33 return reverseString(str) === str.split('').reverse().join('');34 },35 { numRuns: 100 }36 );37 });38});

Full Screen

Using AI Code Generation

copy

Full Screen

1const { cmd } = require('fast-check-monorepo');2const { fastCheck } = require('fast-check');3const { check } = fastCheck;4const { cmd } = require('fast-check-monorepo');5const { fastCheck } = require('fast-check');6const { check } = fastCheck;7const { cmd } = require('fast-check-monorepo');8const { fastCheck } = require('fast-check');9const { check } = fastCheck;10const { cmd } = require('fast-check-monorepo');11const { fastCheck } = require('fast-check');12const { check } = fastCheck;13const { cmd } = require('fast-check-monorepo');14const { fastCheck } = require('fast-check');15const { check } = fastCheck;16const { cmd } = require('fast-check-monorepo');17const { fastCheck } = require('fast-check');18const { check } = fastCheck;19const { cmd } = require('fast-check-monorepo');20const { fastCheck } = require('fast-check');21const { check } = fastCheck;22const { cmd } = require('fast-check-monorepo');23const { fastCheck } = require('fast-check');24const { check } = fastCheck;25const { cmd } = require('fast-check-monorepo');26const { fastCheck } = require('fast-check');27const { check } = fastCheck;28const { cmd } = require('fast-check-monorepo');29const { fastCheck } = require('fast-check');30const { check } = fastCheck;31const { cmd } = require('fast-check-monorepo');32const { fastCheck } = require('fast-check');33const { check } = fastCheck;34const { cmd

Full Screen

Using AI Code Generation

copy

Full Screen

1const cmd = require('fast-check-monorepo/cmd');2const { run } = require('fast-check-monorepo/cmd/utils');3const { runTests } = require('fast-check-monorepo/cmd/tests');4const { runCoverage } = require('fast-check-monorepo/cmd/coverage');5const { runLint } = require('fast-check-monorepo/cmd/lint');6const { runFormat } = require('fast-check-monorepo/cmd/format');7const { runBuild } = require('fast-check-monorepo/cmd/build');8const { runWatch } = require('fast-check-monorepo/cmd/watch');9run(cmd({10 tests: runTests({ files: ['tests/**/*-test.js'] }),11 coverage: runCoverage({ files: ['tests/**/*-test.js'] }),12 lint: runLint({ files: ['src/**/*.js', 'tests/**/*.js'] }),13 format: runFormat({ files: ['src/**/*.js', 'tests/**/*.js'] }),14 build: runBuild({ files: ['src/**/*.js', 'tests/**/*.js'] }),15 watch: runWatch({ files: ['src/**/*.js', 'tests/**/*.js'] })16}));

Full Screen

Using AI Code Generation

copy

Full Screen

1const fastCheck = require("fast-check");2const cmd = fastCheck.cmd;3const { run } = require("fast-check-monorepo");4const { cmd1, cmd2 } = require("./commands");5const runCmd = run(cmd);6runCmd(cmd1);7runCmd(cmd2);8const fastCheck = require("fast-check");9const cmd = fastCheck.cmd;10const { cmd1, cmd2 } = require("./commands");11const { cmd1, cmd2 } = require("./commands");12const runCmd = run(cmd);13runCmd(cmd1);14runCmd(cmd2);15const fastCheck = require("fast-check");16const cmd = fastCheck.cmd;17const { cmd1, cmd2 } = require("./commands");18module.exports = {19 cmd1: cmd("cmd1", { a: fastCheck.integer() }, () => {}),20 cmd2: cmd("cmd2", { b: fastCheck.string() }, () => {}),21};22const fastCheck = require("fast-check");23const cmd = fastCheck.cmd;24const { cmd1, cmd2 } = require("./commands");25module.exports = {26 cmd1: cmd("cmd1", { a: fastCheck.integer() }, () => {}),27 cmd2: cmd("cmd2", { b: fastCheck.string() }, () => {}),28};29const fastCheck = require("fast-check");30const cmd = fastCheck.cmd;31const { run } = require("fast-check-monorepo");32const { cmd1, cmd2 } = require("./commands");33const runCmd = run(cmd);34runCmd(cmd1);35runCmd(cmd2);36const fastCheck = require("fast-check");37const cmd = fastCheck.cmd;38const { cmd1, cmd2 } = require("./commands");39module.exports = {40 cmd1: cmd("cmd1", { a: fastCheck.integer() }, () => {}),41 cmd2: cmd("cmd2", { b: fastCheck.string() }, () => {}),42};

Full Screen

Using AI Code Generation

copy

Full Screen

1const fastCheck = require('fast-check');2const fc = fastCheck.default;3let cmd = fc.cmd(fc.integer(), (n) => {4 return n > 0;5});6let cmds = fc.commands([cmd], 1000);7fc.assert(8 fc.property(cmds, (cmds) => {9 })10);11const fastCheck = require('fast-check');12const fc = fastCheck.default;13let cmd = fc.cmd(fc.string(), fc.integer(), (s, n) => {14 return s.length > n;15});16let cmds = fc.commands([cmd], 1000);17fc.assert(18 fc.property(cmds, (cmds) => {19 })20);21const fastCheck = require('fast-check');22const fc = fastCheck.default;23let cmd = fc.cmd(fc.array(fc.integer()), (arr) => {24 return arr.length > 0;25});26let cmds = fc.commands([cmd], 1000);27fc.assert(28 fc.property(cmds, (cmds) => {29 })30);31const fastCheck = require('fast-check');32const fc = fastCheck.default;33let cmd = fc.cmd(fc.object(), (obj) => {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { cmd } = require('fast-check-monorepo');2const { run } = cmd;3const res = run("ls -l", { cwd: "/Users/robert" });4console.log(res);5', stderr: '' }6const { cmd } = require('fast-check');7const { run } = cmd;8const res = run("ls -l", { cwd: "/Users/robert" });9console.log(res);10', stderr: '' }11const { cmd } = require('fast-check');12const { run } = cmd;13const res = run("ls -l", { cwd: "/Users/robert" });14console.log(res);15', stderr: '' }16const { cmd } = require('fast-check');17const { run } = cmd;18const res = run("ls -l", { cwd: "/Users/robert" });19console.log(res);20', stderr: '' }21const { cmd } = require('fast-check');22const { run } = cmd;23const res = run("ls -l", { cwd: "/Users/robert" });24console.log(res);25', stderr: '' }26const { cmd } = require('fast-check');27const { run } = cmd;28const res = run("ls -l", { cwd: "/Users/robert" });29console.log(res);30', stderr: '' }31const { cmd } = require('fast-check');32const { run } = cmd;33const res = run("ls -l", { cwd: "/Users/robert" });34console.log(res);35', stderr: '' }36const { cmd } = require('fast-check');37const { run } = cmd;38const res = run("ls -l", { cwd: "/Users/robert" });39console.log(res);

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful