def main(argv): parser = argparse.ArgumentParser(description='***VOS Source Helper***', epilog = 'Usage example:\n'+sys.argv[0]+' --cloud_url <RT URL> --export --file=sources.txt', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--cloud_url', dest='cloud_url', action='store', help='Cloud url', required=True) parser.add_argument('--file', dest='src_file', action='store', help='Batch File with services to be processed.', required=True) parser.add_argument('--dryrun', dest='dryrun', action='store_true', help='Set Other Misc. Options', required=False) args = parser.parse_args() if args.dryrun: print "Script is running as Dryrun no changes will be applied !!" user = raw_input("Enter the Username for VOS:\n") passwd = getpass.getpass("Enter the Password:\n") vos_session = vos.vos_get_session(user,passwd) vosrt = args.cloud_url if not os.path.isfile(args.src_file): print "File %s does not exist !!" %args.src_file sys.exit(2) f = open(args.src_file) srcount = 0 ret = [] for item in f: srcname = item.strip() srcs = vos.vos_get_source_name(srcname,vosrt,vos_session) srcsy = yaml.safe_load(srcs.text) srcsy = srcsy[0] if srcsy['inputs'][0]['zixiSettings']['grooming']: if len(srcsy['inputs'][0]['zixiSettings']['grooming']['audioGrooming']['tracks']) > 1: if not srcsy['inputs'][0]['zixiSettings']['grooming']['audioGrooming']['tracks'][1]['skipProcessing']: srcsy['inputs'][0]['zixiSettings']['grooming']['audioGrooming']['tracks'][1]['skipProcessing'] = True param = json.dumps(srcsy) if args.dryrun: print "\nDry Run on Service %s - Below Parameters would be applied if not in Dryrun Mode.\n" %srcsy['name'] print param ret.append("Script would disable 2nd Audio for Source %s" %srcsy['name']) else: print "\nDisabling 2nd Audio for Source %s\n" %srcsy['name'] print vos.vos_mod_source(srcsy['id'],param,vosrt,vos_session) ret.append("Disabled 2nd Audio for Source %s" %srcsy['name']) srcount += 1 time.sleep(5) else: print "Source %s is configured but not Groomed !!!" %srcsy['name'] ret.append("Source %s is configured but not Groomed !!!" %srcsy['name']) for r in ret: print r print "%d Sources had the 2nd Audio Disabled" %srcount
def main(argv): parser = argparse.ArgumentParser( description='***VOS Cloud Helper***', epilog='Usage example:\n' + sys.argv[0] + ' --cloud_url=https://hkvpurple-01.nebula.video --cloud_username=USERNAME', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--batch_file', dest='batch_file', action='store', help='Batch File with services to be processed.', required=True) parser.add_argument('--service_off', dest='service_off', action='store_true', help='Off line Service. Provide Service ID or Name', required=False) parser.add_argument('--service_on', dest='service_on', action='store_true', help='On line Service. Provide Service ID or Name', required=False) args = parser.parse_args() if args.service_off and args.service_on: print "Pick either --service_off or --service_on option." sys.exit(2) if not os.path.isfile(args.batch_file): print "File %s does not exist !!" % args.batch_file sys.exit(2) vosrt = raw_input("Enter the VOS RT Address:\n") vos_session = vos.vos_get_session() f = open(args.batch_file) for item in f: servn = item.strip() if args.service_off: print vos.vos_service_offline(servn, vosrt, vos_session) if args.service_on: print vos.vos_service_online(servn, vosrt, vos_session)
def main(argv): parser = argparse.ArgumentParser( description='***VOS Cloud Helper***', epilog='Usage example:\n' + sys.argv[0] + ' --cloud_url=https://hkvpurple-01.nebula.video --cloud_username=USERNAME', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--cloud_url', dest='cloud_url', action='store', help='Cloud url', required=True) parser.add_argument('--json_file', dest='json_file', action='store', help='Batch File with services to be processed.', required=False) parser.add_argument('--id', dest='serv_id', action='store', help='Service ID to be deleted', required=False) args = parser.parse_args() vos_session = vos.vos_get_session() vosrt = args.cloud_url if args.json_file: if not os.path.isfile(args.json_file): print "File %s does not exist !!" % args.json_file sys.exit(2) f = open(args.json_file) serv_json = json.load(f) for serv in serv_json: print "Deleting Service: %s" % serv['name'] print vos.vos_service_delete(serv['id'], vosrt, vos_session) if args.serv_id: print "Not implemented yet !!!"
api_get_serv = "/vos-api/configure/v1/services" api_get_dest = "/vos-api/configure/v1/destinations" api_get_src = "/vos-api/configure/v1/sources" api_get_prof = "/vos-api/labwizard/v1/profiles" api_get_cl = "/vos-api/uplink-hub/v1/uplinkGroups" api_header_json = {'user-agent':'Accept:application/json'} api_header_all = {'user-agent':'Accept: */*'} vos_session = vos.vos_get_session() vos_session.post(api_proto+'://'+hostname, verify=False) vos_prof_req = vos_session.get(api_proto+'://'+hostname+api_get_prof,headers=api_header_all,verify=False) vos_dest_req = vos_session.get(api_proto+'://'+hostname+api_get_dest,headers=api_header_json,verify=False) vos_serv_req = vos_session.get(api_proto+'://'+hostname+api_get_serv,headers=api_header_all,verify=False) vos_sour_req = vos_session.get(api_proto+'://'+hostname+api_get_src,headers=api_header_all,verify=False) vos_cl_req = vos_session.get(api_proto+'://'+hostname+api_get_cl,headers=api_header_json,verify=False) # Need to add a check here. #if vos_dest_req.status_code !=200:
# Author: John Vasconcelos # Date: 06/05/2017 # Version 1.1 ########################################################### # vos.py needs to be in the same path as this script. import vos import requests import sys import json from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) vosrt = raw_input("Enter the VOS RT Url:\n") vos_session = vos.vos_get_session() cl_manual_session = vos.vos_get_session("vos", "vossdk") args = sys.argv[1] cl_list = vos.vos_get_cl_list(vosrt, vos_session) for cl in cl_list: if args == "status": cl_login = "******" api_header = {'user-agent': 'Accept: */*'}
def main(argv): parser = argparse.ArgumentParser( description='***VOS DRM System Creation***', epilog='Usage example:\n' + sys.argv[0] + ' --cloud_url=https://hkvpurple-01.nebula.video --cloud_username=USERNAME', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--cloud_url', dest='cloud_url', action='store', help='RT from where to export Configuration.', required=False) parser.add_argument('--drm_sys_id', dest='drm_sys_id', action='store', help='System ID to add resoures to.', required=True) parser.add_argument('--drm_file', dest='drm_file', action='store', help='JSON File with DRM Resources to be created', required=True) args = parser.parse_args() #Creates VOS Requests Session. It will prompt for user and password. vos_session = vos.vos_get_session() vosrt = args.cloud_url if not os.path.isfile(args.drm_file): print "File %s does not exist !!" % args.batch_file sys.exit(2) f = open(args.drm_file) drm_sys = vos.vos_get_drmsys_id(args.drm_sys_id, vosrt, vos_session) if drm_sys.status_code == 200: drmy = yaml.safe_load(drm_sys.text) resource_l = drmy['resources'] for line in f: drm_data = line.strip().split(",") drm_id = ''.join((random.choice(n_choice)) for x in range(12)) if not checkdrm_exists(resource_l, drm_data[1]): res_d = { 'resourceId': drm_data[1], 'packagingType': drm_data[2], 'id': drm_id, 'name': drm_data[0] } resource_l.append(res_d) else: print "Resource ID %s already exists and will not be created! \n" % drm_data[ 1] drmy['resources'] = resource_l param = json.dumps(drmy) #Updates the DRM File. vos.vos_mod_drm_system(args.drm_sys_id, param, vosrt, vos_session) else: sys.exit(2)
def main(argv): parser = argparse.ArgumentParser(description='***VOS Cloud Helper***', epilog = 'Usage example:\n'+sys.argv[0]+' --cloud_url=https://hkvpurple-01.nebula.video --cloud_username=USERNAME', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--cloud_url', dest='cloud_url', action='store', help='Cloud url', required=True) parser.add_argument('--service', dest='service', action='store_true', help='Delete Service', required=False) parser.add_argument('--destination', dest='destination', action='store_true', help='Delete Destination', required=False) parser.add_argument('--source', dest='source', action='store_true', help='Delete Source', required=False) parser.add_argument('--all', dest='all', action='store_true', help='Delete All', required=False) parser.add_argument('--id', dest='id', action='store', help='Delete by ID', required=False) args = parser.parse_args() if not args.service and not args.source and not args.destination: print "Please enter an option for Deletion. --service or --destination or --source" sys.exit(2) if not args.all and not args.id: print "You need to specify either --all or --id option" sys.exit(2) if args.all and args.id: print "You need to specify either --all or --id option" sys.exit(2) vos_session = vos.vos_get_session() vosrt = args.cloud_url # Delete Services if args.service: if args.source or args.destination: print "You can only pick one Option for Deletion ! Pick either --source or --service or --destination" sys.exit(2) #Delete all Services on RT if args.all: if not continue_check("ALL SERVICES",vosrt): sys.exit(2) servs = vos.vos_get_service_all(vosrt,vos_session) for serv in servs.json(): vos.log_write("INFO","Deleting Service %s ID: %s" %(serv['name'],serv['id']),log_file) vos_ret = vos.vos_service_delete(serv['id'],vosrt,vos_session) if vos_ret.status_code == 200: vos.log_write("INFO","\n%s" %json.dumps(serv),log_file) time.sleep(4) else: vos.log_write("ERROR","Failed to Delete Service %s. Error: %s - %s " %(serv['name'],vos_ret,vos_ret.text),log_file) # Delete Destinations if args.destination: if args.source or args.service: print "You can only pick one Option for Deletion ! Pick either --source or --service or --destination" sys.exit(2) #Delete all Destinations on RT if args.all: if not continue_check("ALL DESTINATIONS",vosrt): sys.exit(2) dests = vos.vos_get_destination_all(vosrt,vos_session) for dest in dests.json(): vos.log_write("INFO","Deleting Destination %s ID: %s" %(dest['name'],dest['id']),log_file) vos_ret = vos.vos_destination_delete(dest['id'],vosrt,vos_session) if vos_ret.status_code == 200: vos.log_write("INFO","\n%s" %json.dumps(dest),log_file) time.sleep(4) else: vos.log_write("ERROR","Failed to Delete Destination %s. Error: %s - %s " %(dest['name'],vos_ret,vos_ret.text),log_file) # Delete Sources if args.source: if args.destination or args.service: print "You can only pick one Option for Deletion ! Pick either --source or --service or --destination" sys.exit(2) #Delete all Sources on RT if args.all: if not continue_check("ALL SOURCES",vosrt): sys.exit(2) srcs = vos.vos_get_source_all(vosrt,vos_session) for src in srcs.json(): vos.log_write("INFO","Deleting Source %s ID: %s" %(src['name'],src['id']),log_file) vos_ret = vos.vos_source_delete(src['id'],vosrt,vos_session) if vos_ret.status_code == 200: vos.log_write("INFO","\n%s" %json.dumps(src),log_file) time.sleep(4) else: vos.log_write("ERROR","Failed to Delete Source %s. Error: %s - %s " %(src['name'],vos_ret,vos_ret.text),log_file)
def main(argv): parser = argparse.ArgumentParser( description='***VOS Cloud Helper***', epilog='Usage example:\n' + sys.argv[0] + ' --cloud_url=https://hkvpurple-01.nebula.video --cloud_username=USERNAME', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--cloud_username', dest='cloud_username', action='store', default='', help='Cloudlink username', required=False) parser.add_argument('--cloud_url', dest='cloud_url', action='store', help='Cloud url', required=True) parser.add_argument('--image_id', dest='image_id', action='store', help='Slate Image ID to be set on services', required=True) args = parser.parse_args() vosrt = args.cloud_url if not args.cloud_username: user = raw_input("Enter the Username for VOS:\n") else: user = args.cloud_username passwd = getpass.getpass("Enter the Password:\n") slate_img = args.image_id vos_session = vos.vos_get_session(user, passwd) servs = vos.vos_get_service_all(vosrt, vos_session) srv_yaml = yaml.safe_load(servs.text) for serv in srv_yaml: if not serv['addons']: serv['addons'] = { "logoAddon": None, "graphicsAddon": None, "videoInsertionAddon": None, "trafficAddon": None, "casAddon": None, "drmAddon": None, "scte35SlateAddon": { "imageId": slate_img } } else: serv['addons']['scte35SlateAddon'] = {"imageId": slate_img} param = json.dumps(serv) print "Changing slate image for Service %s" % serv['name'] print param #print vos.vos_mod_service(serv['id'],param,vosrt,vos_session) time.sleep(5)
def main(argv): parser = argparse.ArgumentParser(description='***VOS User Backup/Restore***', epilog = 'Usage example:\n'+sys.argv[0]+' --cloud_url=https://hkvpurple-01.nebula.video --cloud_username=USERNAME', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--cloud_url', dest='cloud_url', action='store', help='RT from where to export Configuration.', required=True) parser.add_argument('--user_file', dest='user_file', action='store', help='JSON File for Users', required=True) parser.add_argument('--backup', dest='backup', action='store_true', help='Backup Configuration', required=False) parser.add_argument('--restore', dest='restore', action='store_true', help='Restore Configuration', required=False) args = parser.parse_args() if args.backup and args.restore: print "Please use either --backup or --restore but not both :-)" sys.exit(2) #Creates VOS Requests Session. It will prompt for user and password. vos_session = vos.vos_get_session() vosrt = args.cloud_url # Backup Configuration if args.backup: #Backup Sources f_users = open(args.user_file,'w') vos_users = vos.vos_get_user_all(vosrt,vos_session) json.dump(vos_users.json(),f_users) f_users.close() #Restores Configuration if args.restore: #Checks if file exists if not os.path.isfile(args.user_file): print "File %s does not exist !!" %args.user_file sys.exit(2) #Restore Users with open(args.user_file) as user_data: usr_y = yaml.safe_load(user_data) for usr in usr_y: chk_usr = vos.vos_get_user_name(usr['username'],vosrt,vos_session) if not chk_usr.status_code == 200: param = json.dumps(usr) vos_ret = vos.vos_add_user(param,vosrt,vos_session) check_status(vos_ret,"User",usr['name'],usr['username']) else: vos.log_write("INFO","User %s already Exists !!!" %usr['username'],log_file)
def main(argv): parser = argparse.ArgumentParser( description='***VOS Source Helper***', epilog='Usage example:\n' + sys.argv[0] + ' --cloud_url <RT URL> --export --file=sources.txt', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--cloud_url', dest='cloud_url', action='store', help='Cloud url', required=True) parser.add_argument('--cloud_username', dest='cloud_username', action='store', default='', help='Cloudlink username', required=False) parser.add_argument('--file', dest='src_file', action='store', help='Batch File with services to be processed.', required=True) args = parser.parse_args() api_proto = "https" hostname = args.cloud_url vosrt = hostname api_get_dest = "/vos-api/configure/v1/destinations" api_header_json = {'user-agent': 'Accept:application/json'} api_header_all = {'user-agent': 'Accept: */*'} api_header_serv_post = { 'Content-Type': 'application/json', 'Accept': '*/*' } vos_session = vos.vos_get_session() vos_conn_test = vos_session.post(api_proto + '://' + hostname, verify=False) if vos_conn_test.status_code != 200: print "Error Connecting to VOS: " print vos_conn_test sys.exit(2) if not os.path.isfile(args.src_file): print "File %s does not exist !!" % args.src_file sys.exit(2) f = open(args.src_file) vos_dest_req = vos_session.get(api_proto + '://' + hostname + api_get_dest, headers=api_header_json, verify=False) d = vos_dest_req.json() cl_list = vos.vos_get_cl_list(vosrt, vos_session) for dest in f: destname = dest.split(",")[0] clname = dest.split(",")[1] for ditem in d: d_id = ditem['id'] d_name = ditem['name'] if d_name == destname.strip(): for cl in cl_list: if clname.strip() == cl['clname']: change_prof(d_id, cl['clgroup'], hostname, vos_session)
def main(argv): parser = argparse.ArgumentParser( description='***VOS Source Helper***', epilog='Usage example:\n' + sys.argv[0] + ' --cloud_url <RT URL> --export --file=sources.txt', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--cloud_url', dest='cloud_url', action='store', help='Cloud url', required=True) parser.add_argument('--cloud_username', dest='cloud_username', action='store', default='', help='Cloudlink username', required=False) parser.add_argument('--file', dest='src_file', action='store', help='Batch File with services to be processed.', required=False) parser.add_argument('--src_list_file', dest='src_list_file', action='store', help='List of Sources to be Processed', required=False) parser.add_argument('--cl_file', dest='cl_file', action='store', help='Source to CL Association File', required=False) parser.add_argument('--cloud_link', dest='cloud_link', action='store', default='', help='Cloudlink Name', required=False) parser.add_argument('--import', dest='import_src', action='store_true', help='Import Sources from a File', required=False) parser.add_argument('--export', dest='export_src', action='store_true', help='Export Sources to a File', required=False) parser.add_argument('--associate_cl', dest='ass_cl', action='store_true', help='Associate CL to Source based on a File', required=False) parser.add_argument('--set_audio_label', dest='set_audio_label', action='store_true', help='Set the Audio Label', required=False) parser.add_argument('--disable_sec_audio', dest='disable_sec_audio', action='store_true', help='Disable Secondary Audio', required=False) parser.add_argument('--set-options', dest='set_opt', action='store_true', help='Set Other Misc. Options', required=False) args = parser.parse_args() if args.import_src and args.export_src: print "Pick Either --import or --export, but not Both. :-)" sys.exit(2) if not args.import_src and not args.export_src and not args.ass_cl and not args.set_opt and not args.set_audio_label and not args.disable_sec_audio: print "Specify either --import or --export option or --associate_cl" sys.exit(2) if not args.cloud_username: user = raw_input("Enter the Username for VOS:\n") else: user = args.cloud_username passwd = getpass.getpass("Enter the Password:\n") vos_session = vos.vos_get_session(user, passwd) vosrt = args.cloud_url cl_id = "" source_list = [] if args.import_src: if not os.path.isfile(args.src_file): print "File %s does not exist !!" % args.src_file sys.exit(2) f = open(args.src_file) src_json = json.load(f) if not args.cl_file: # raw_input returns the empty string for "enter" yes = set(['yes', 'y', 'ye', '']) no = set(['no', 'n']) choice = raw_input( "--cl_file option not specified. Sources will be Imported with the CL on json file. Continue ?" ).lower() if choice in yes: pass elif choice in no: sys.exit(2) else: sys.stdout.write("Please respond with 'yes' or 'no'") for src in src_json: src_new_id = str(uuid.uuid4()) src['id'] = src_new_id if args.cl_file: if not os.path.isfile(args.cl_file): print "File %s does not exist !!" % args.cl_file sys.exit(2) clf = open(args.cl_file) for srccl in clf: srcname = srccl.split(",")[0] clname = srccl.split(",")[1] if srcname.strip() == src['name']: cl_list = vos.vos_get_cl_list(vosrt, vos_session) for cl in cl_list: if clname.strip() == cl['clname']: src['inputs'][0]['zixiSettings'][ 'harmonicUplinkSetting'][ 'uplinkGroupId'] = cl['clgroup'] param = json.dumps(src) #print param #print "\n" print vos.vos_add_source(param, vosrt, vos_session) if args.export_src: if args.src_list_file: if not os.path.isfile(args.src_list_file): print "File %s does not exist !!" % args.src_list_file sys.exit(2) slf = open(args.src_list_file) f = open(args.src_file, 'w') srcs = vos.vos_get_source_all(vosrt, vos_session).json() if args.cloud_link: cl_list = vos.vos_get_cl_list(vosrt, vos_session) for cl in cl_list: if args.cloud_link == cl['clname']: cl_id = cl['clgroup'] if not cl_id: print "Cloudlink does not Exist on this system !" sys.exit(2) for src in srcs: if cl_id: if src['inputs'][0]['zixiSettings']['harmonicUplinkSetting'][ 'uplinkGroupId'] == cl_id: print "Exporting service: %s\n" % src['name'] source_list.append(src) elif args.src_list_file: for src_exp in slf: if src['name'] == src_exp.strip(): print "Exporting service: %s\n" % src['name'] source_list.append(src) else: print "Exporting service: %s\n" % src['name'] source_list.append(src) json.dump(source_list, f) f.close() if args.ass_cl: if args.cl_file: if not os.path.isfile(args.cl_file): print "File %s does not exist !!" % args.cl_file sys.exit(2) clf = open(args.cl_file) else: print "You need to specify the option --associate_cl" sys.exit(2) for srccl in clf: srcname = srccl.split(",")[0] clname = srccl.split(",")[1] #print srcname.strip() src = vos.vos_get_source_name(srcname.strip(), vosrt, vos_session) # print src.json() if src.text: srcy = yaml.safe_load(src.text) #print srcy #print"\n\n\n\n" if srcname.strip() == srcy[0]['name']: cl_list = vos.vos_get_cl_list(vosrt, vos_session) for cl in cl_list: if clname.strip() == cl['clname']: srcy[0]['inputs'][0]['zixiSettings'][ 'harmonicUplinkSetting']['uplinkGroupId'] = cl[ 'clgroup'] param = json.dumps(srcy[0]) print vos.vos_add_source(param, vosrt, vos_session) if args.set_opt: srcs = vos.vos_get_source_all(vosrt, vos_session) srcsy = yaml.safe_load(srcs.text) for sr_opt in srcsy: print sr_opt['id'] print "\n" is_default = False index = 0 ''' if sr_opt['inputs'][0]['zixiSettings']['grooming']: for aud_gr in sr_opt['inputs'][0]['zixiSettings']['grooming']['audioGrooming']['tracks']: if aud_gr['isDefault'] and sr_opt['inputs'][0]['zixiSettings']['grooming']['audioGrooming']['tracks'][index]['hasNielsenWatermark'] == False: sr_opt['inputs'][0]['zixiSettings']['grooming']['audioGrooming']['tracks'][index]['hasNielsenWatermark'] = True is_default = True index += 1 if not is_default: sr_opt['inputs'][0]['zixiSettings']['grooming']['audioGrooming']['tracks'][0]['isDefault'] = True sr_opt['inputs'][0]['zixiSettings']['grooming']['audioGrooming']['tracks'][0]['hasNielsenWatermark'] = True ''' if not sr_opt['inputs'][1]['slateSettings']: sr_opt['inputs'][1]['slateSettings'] = { "type": "SIGNAL_LOSS", "imageId": "db6c9c17-0adf-5fbf-9db9-8c319b3be36f", "customSlateSettings": None } if not sr_opt['inputs'][1]['slateSettings'][ 'imageId'] == "db6c9c17-0adf-5fbf-9db9-8c319b3be36f": sr_opt['inputs'][1]['slateSettings'][ 'imageId'] = "db6c9c17-0adf-5fbf-9db9-8c319b3be36f" param = json.dumps(sr_opt) print vos.vos_mod_source(sr_opt['id'], param, vosrt, vos_session) time.sleep(10) if args.set_audio_label: srcs = vos.vos_get_source_all(vosrt, vos_session) srcsy = yaml.safe_load(srcs.text) for sr_opt in srcsy: print sr_opt['id'] print "\n" aud_label = 1 index = 0 #Set Audio Labels if sr_opt['inputs'][0]['zixiSettings']['grooming']: for audio in sr_opt['inputs'][0]['zixiSettings']['grooming'][ 'audioGrooming']['tracks']: if not audio['labels']: sr_opt['inputs'][0]['zixiSettings']['grooming'][ 'audioGrooming']['tracks'][index]['labels'] = [ "audio_" + str(aud_label) ] aud_label += 1 index += 1 index = 0 #Set SCTE 35 Label for data_groom in sr_opt['inputs'][0]['zixiSettings'][ 'grooming']['dataGrooming']['tracks']: if data_groom[ 'dataTrackStreamType'] == 134 and not data_groom[ 'labels']: sr_opt['inputs'][0]['zixiSettings']['grooming'][ 'dataGrooming']['tracks'][index]['labels'] = [ "SCTE-35" ] index += 1 param = json.dumps(sr_opt) #print param print vos.vos_mod_source(sr_opt['id'], param, vosrt, vos_session) time.sleep(10) #Disable Secondary Audio if args.disable_sec_audio: srcs = vos.vos_get_source_all(vosrt, vos_session) srcsy = yaml.safe_load(srcs.text) srcount = 0 ret = [] for sr_opt in srcsy: if sr_opt['inputs'][0]['zixiSettings']['grooming']: if len(sr_opt['inputs'][0]['zixiSettings']['grooming'] ['audioGrooming']['tracks']) > 1: if not sr_opt['inputs'][0]['zixiSettings']['grooming'][ 'audioGrooming']['tracks'][1]['skipProcessing']: print "\nDisabling 2nd Audio for Source %s\n" % sr_opt[ 'name'] sr_opt['inputs'][0]['zixiSettings']['grooming'][ 'audioGrooming']['tracks'][1][ 'skipProcessing'] = True param = json.dumps(sr_opt) #print param print vos.vos_mod_source(sr_opt['id'], param, vosrt, vos_session) ret.append("Disabled 2nd Audio for Source %s" % sr_opt['name']) srcount += 1 time.sleep(5) else: print "Source %s is configured but not Groomed !!!" % sr_opt[ 'name'] ret.append("Source %s is configured but not Groomed !!!" % sr_opt['name']) for r in ret: print r print "%d Sources had the 2nd Audio Disabled" % srcount
def main(argv): parser = argparse.ArgumentParser( description='***VOS Cloud Helper***', epilog='Usage example:\n' + sys.argv[0] + ' --cloud_url=https://hkvpurple-01.nebula.video --cloud_username=USERNAME', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--cloud_username', dest='cloud_username', action='store', default='', help='Cloudlink username', required=False) parser.add_argument('--cloud_url', dest='cloud_url', action='store', help='Cloud url', required=True) parser.add_argument('--batch_file', dest='batch_file', action='store', help='Batch File with services to be processed.', required=False) parser.add_argument('--image_id', dest='image_id', action='store', help='Slate Image ID to be set on services', required=False) parser.add_argument('--new-profile', dest='prof_id', action='store', help='New Profile ID', required=False) parser.add_argument( '--srv-fix-dst-order', dest='fix_order', action='store_true', help='Fixes the order of the destination Profiles - NG-16364', required=False) parser.add_argument('--drm-off', dest='drm_off', action='store_true', help='Disables DRM', required=False) parser.add_argument('--drm-on', dest='drm_on', action='store_true', help='Enables DRM', required=False) args = parser.parse_args() vosrt = args.cloud_url if not args.cloud_username: user = raw_input("Enter the Username for VOS:\n") else: user = args.cloud_username passwd = getpass.getpass("Enter the Password:\n") vos_session = vos.vos_get_session(user, passwd) servs = vos.vos_get_service_all(vosrt, vos_session) srv_yaml = yaml.safe_load(servs.text) if args.fix_order: for serv in srv_yaml: dest_id = serv['destinationId'] dest_ids = serv['destinationsId'] if not dest_id == dest_ids[0]: serv['destinationsId'] = [dest_ids[1], dest_ids[0]] param = json.dumps(serv) print "Updating service %s" % serv['name'] print vos.vos_mod_service(serv['id'], param, vosrt, vos_session) time.sleep(30) sys.exit(2) if not args.batch_file: print "Please provide the --batch_file option !!!" sys.exit(2) if not os.path.isfile(args.batch_file): print "File %s does not exist !!" % args.batch_file sys.exit(2) f = open(args.batch_file) for serv in srv_yaml: for item in f: if serv['name'] == item.strip(): # Disables DRM on all services listed in the Batch File if args.drm_off: serv['addons']['drmAddon']['enable'] = False # Enables DRM on all services listed in the Batch File if args.drm_on: serv['addons']['drmAddon']['enable'] = True if args.image_id: if not serv['addons']: serv['addons'] = { "logoAddon": None, "graphicsAddon": None, "videoInsertionAddon": None, "trafficAddon": None, "casAddon": None, "drmAddon": None, "scte35SlateAddon": { "imageId": args.image_id } } else: serv['addons']['scte35SlateAddon'] = { "imageId": args.image_id } if args.prof_id: serv['profileId'] = args.prof_id param = json.dumps(serv) print "Updating service %s" % serv['name'] print vos.vos_mod_service(serv['id'], param, vosrt, vos_session) time.sleep(5) f.seek(0)
def main(argv): parser = argparse.ArgumentParser( description='***VOS Service Migration***', epilog='Usage example:\n' + sys.argv[0] + ' --cloud_url=https://hkvpurple-01.nebula.video --cloud_username=USERNAME', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--cloud_url', dest='cloud_url', action='store', help='RT from where to export Configuration.', required=False) parser.add_argument('--srv_file', dest='srv_file', action='store', help='JSON File for Services', required=False) parser.add_argument('--src_file', dest='src_file', action='store', help='JSON File for Sources', required=False) parser.add_argument('--dst_file', dest='dst_file', action='store', help='JSON File for Destinations', required=False) parser.add_argument('--img_file', dest='img_file', action='store', help='JSON File for Images', required=False) parser.add_argument('--drm_file', dest='drm_file', action='store', help='JSON File for DRM Systems/Settings', required=False) parser.add_argument('--backup', dest='backup', action='store_true', help='Backup Configuration', required=False) parser.add_argument('--restore', dest='restore', action='store_true', help='Restore Configuration', required=False) parser.add_argument('--srv_off', dest='srv_off', action='store_true', help='Restore with Service Offline', required=False) args = parser.parse_args() if args.backup and args.restore: print "Please use either --backup or --restore but not both :-)" sys.exit(2) #Creates VOS Requests Session. It will prompt for user and password. vos_session = vos.vos_get_session() vosrt = args.cloud_url # Backup Configuration if args.backup: #Backup Sources f_src = open(args.src_file, 'w') vos_srcs = vos.vos_get_source_all(vosrt, vos_session) json.dump(vos_srcs.json(), f_src) f_src.close() #Backup Destinations f_dst = open(args.dst_file, 'w') vos_dsts = vos.vos_get_destination_all(vosrt, vos_session) json.dump(vos_dsts.json(), f_dst) f_dst.close() #Backup Services f_srv = open(args.srv_file, 'w') vos_srvs = vos.vos_get_service_all(vosrt, vos_session) json.dump(vos_srvs.json(), f_srv) f_srv.close() #Backup Images f_img = open(args.img_file, 'w') vos_imgs = vos.vos_get_image_all(vosrt, vos_session) json.dump(vos_imgs.json(), f_img) f_img.close() #Backup DRM Systems if args.drm_file: f_drm = open(args.drm_file, 'w') vos_drms = vos.vos_get_drmsys_all(vosrt, vos_session) json.dump(vos_drms.json(), f_drm) f_drm.close() #Backup DRM Settings drm_sets_file = args.drm_file + '_settings' f_drm_sets = open(drm_sets_file, 'w') vos_drm_sets = vos.vos_get_drm_settings(vosrt, vos_session) json.dump(vos_drm_sets.json(), f_drm_sets) f_drm_sets.close() #Restores Configuration if args.restore: #Restores DRM Configuration if args.drm_file: #Checks if file exists if not os.path.isfile(args.drm_file): print "File %s does not exist !!" % args.drm_file sys.exit(2) #Restores DRM Settings drm_sets_file = args.drm_file + '_settings' #Checks if file exists if not os.path.isfile(drm_sets_file): print "File %s does not exist !!" % drm_sets_file sys.exit(2) with open(args.drm_file) as drm_data: drm = yaml.safe_load(drm_data) for drm_item in drm: param = json.dumps(drm_item) vos_ret = vos.vos_drmsys_add(param, vosrt, vos_session) check_status(vos_ret, "DRM System", drm_item['name'], drm_item['id']) with open(drm_sets_file) as drm_set: for param in drm_set: vos_ret = vos.vos_mod_drm_settings(param, vosrt, vos_session) if not vos_ret.status_code == 200: vos.log_write( "ERROR", "Failed to Update DRM Settings with the following settings:\n%s" % param, log_file) #Restore Images if args.img_file: #Checks if file exists if not os.path.isfile(args.img_file): print "File %s does not exist !!" % args.img_file sys.exit(2) with open(args.img_file) as img_data: i = yaml.safe_load(img_data) for img_item in i: param = json.dumps(img_item) vos_ret = vos.vos_add_image(param, vosrt, vos_session) check_status(vos_ret, "Image", img_item['url'], img_item['id']) #Restore Sources if args.src_file: #Checks if file exists if not os.path.isfile(args.src_file): print "File %s does not exist !!" % args.src_file sys.exit(2) with open(args.src_file) as src_data: s = yaml.safe_load(src_data) for src_item in s: param = json.dumps(src_item) vos_ret = vos.vos_add_source(param, vosrt, vos_session) check_status(vos_ret, "Source", src_item['name'], src_item['id']) time.sleep(4) #Restore Destinations if args.dst_file: #Checks if file exists if not os.path.isfile(args.dst_file): print "File %s does not exist !!" % args.dst_file sys.exit(2) with open(args.dst_file) as dst_data: d = yaml.safe_load(dst_data) for dst_item in d: param = json.dumps(dst_item) vos_ret = vos.vos_add_destination(param, vosrt, vos_session) check_status(vos_ret, "Destination", dst_item['name'], dst_item['id']) time.sleep(4) #Restore Services if args.srv_file: #Checks if file exists if not os.path.isfile(args.srv_file): print "File %s does not exist !!" % args.srv_file sys.exit(2) with open(args.srv_file) as srv_data: sv = yaml.safe_load(srv_data) for srv_item in sv: if args.srv_off: srv_item['controlState'] = "OFF" param = json.dumps(srv_item) vos_ret = vos.vos_service_add(param, vosrt, vos_session) check_status(vos_ret, "Service", srv_item['name'], srv_item['id']) time.sleep(10)
10.105.154.22 10.105.154.43 10.105.154.23 10.105.154.44 10.105.154.24 10.105.154.45 10.105.154.25 10.105.154.46 10.105.154.26 10.105.154.47 10.105.154.27 10.105.154.48 10.105.154.28 ''' session = vos.vos_get_session("vos", "vossdk") cliplist = cl_list.split("\n") fip_list = [] for clip in cliplist: if clip: cl_fips = vos.get_fip_ip(session, clip) for fip in cl_fips: if not fip in fip_list: fip_list.append(fip) for fips in fip_list: print fips
def main(argv): parser = argparse.ArgumentParser( description='***VOS Check Notifications***', epilog='Usage example:\n' + sys.argv[0] + ' --cloud_url <RT URL> --active --cl-ip=10.105.134.5', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('--cloud_url', dest='cloud_url', action='store', help='Cloud url', required=True) parser.add_argument('--cloud_username', dest='cloud_username', action='store', default='', help='RT username', required=False) parser.add_argument('--cloud_pass', dest='cloud_pass', action='store', default='', help='RT Password', required=False) parser.add_argument('--mesos_master', dest='mesos_master', action='store', default='', help='Mesos Master IP', required=False) args = parser.parse_args() if args.cloud_username: user = args.cloud_username else: user = "" if args.cloud_pass: password = args.cloud_pass else: password = "" vos_session = vos.vos_get_session(user, password) if args.mesos_master: mesos_master = args.mesos_master else: mesos_master = raw_input("Enter the IP of the Mesos Master:\n") vosrt = args.cloud_url mtasks = vos.mesos_get_tasks(mesos_master) magents = vos.mesos_get_agents(mesos_master) lio_info = vos.vos_get_live_ingest(mtasks, magents, vosrt, vos_session) print "SERVICE,LIO ID,PACKAGE,NODE,NODE IP,STATE" for lio in lio_info: print "%s,%s,%s,%s,%s,%s" % (lio['servname'], lio['lioid'], lio['package'], lio['node'], lio['nodeip'], lio['state'])