def configure(self, options, conf): Plugin.configure(self, options, conf) if not self.enabled: return ICPlugin.hostname = options.hostname ICPlugin.username = options.username ICPlugin.password = options.password ICPlugin.rest_session = idigi_rest_api.rest_session( options.hostname, auth=(options.username, options.password), verify=False, timeout=120) ICPlugin.session = requests.session(auth=(options.username, options.password), verify=False, timeout=120) ICPlugin.admin_session = requests.session(auth=('testbed', 'Sa!test11'), verify=False) ICPlugin.push_client = idigi_monitor_api.push_client( options.username, options.password, hostname=options.hostname, secure=False) ICPlugin.device_id = options.device_id ICPlugin.device_type = options.device_type ICPlugin.vendor_id = options.vendor_id ICPlugin.ipaddr = options.ipaddr ICPlugin.configuration = options.configuration
def loop(args): logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.INFO) LOG.info("Creating Push Client.") client = push_client(args.username, args.password, hostname=args.host, secure=not args.insecure) topics = ['FileData'] LOG.info("Checking to see if Monitor Already Exists.") monitor_id = client.get_monitor(topics) # Delete Monitor if it Exists. if monitor_id is not None: LOG.info("Monitor already exists, deleting it.") client.delete_monitor(monitor_id) monitor_id = client.create_monitor(topics, format_type='json', compression=args.compression, batch_size=args.batchsize, batch_duration=args.batchduration) try: callback = json_cb(args.dest_root) client.create_session(callback, monitor_id) while True: time.sleep(.31416) except KeyboardInterrupt: # Expect KeyboardInterrupt (CTRL+C or CTRL+D) and print friendly msg. LOG.warn("Closing Sessions and Cleaning Up.") finally: client.stop_all() LOG.info("Deleting Monitor %s." % monitor_id) client.delete_monitor(monitor_id) LOG.info("Done")
def main(): """ Main function call """ args = get_parser().parse_args() logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p', level=logging.INFO) LOG.info("Creating Push Client.") client = push_client(args.username, args.password, hostname=args.host, secure=not args.insecure) topics = args.topics.split(',') LOG.info("Checking to see if Monitor Already Exists.") monitor_id = client.get_monitor(topics) # Delete Monitor if it Exists. if monitor_id is not None: LOG.info("Monitor already exists, deleting it.") client.delete_monitor(monitor_id) monitor_id = client.create_monitor(topics, format_type=args.format, compression=args.compression, batch_size=args.batchsize, batch_duration=args.batchduration) try: callback = json_cb if args.format == "json" else xml_cb client.create_session(callback, monitor_id) while True: time.sleep(.31416) except KeyboardInterrupt: # Expect KeyboardInterrupt (CTRL+C or CTRL+D) and print friendly msg. LOG.warn("Closing Sessions and Cleaning Up.") finally: client.stop_all() LOG.info("Deleting Monitor %s." % monitor_id) client.delete_monitor(monitor_id) LOG.info("Done")
'device_id', type=str, help='The full device id of the device to capture tracing on.') parser.add_argument('--host', '-a', dest='host', action='store', type=str, default='test.idigi.com', help='iDigi server to connect to.') args = parser.parse_args() client = push_client(args.username, args.password, hostname=args.host, secure=True) topics = ['FileData/~%%2F%s/trace.log' % args.device_id] log.info("Checking to see if Monitor Already Exists.") monitor = client.get_monitor(topics) # Delete Monitor if it Exists. if monitor is not None: log.info("Monitor already exists, deleting it.") client.delete_monitor(monitor) monitor = client.create_monitor(topics, format_type='json') try:
help='Username to authenticate with.') parser.add_argument('password', type=str, help='Password to authenticate with.') parser.add_argument('device_id', type=str, help='The full device id of the device to capture tracing on.') parser.add_argument('--host', '-a', dest='host', action='store', type=str, default='test.idigi.com', help='iDigi server to connect to.') args = parser.parse_args() client = push_client(args.username, args.password, hostname=args.host, secure=True) topics = ['FileData/~%%2F%s/trace.log' % args.device_id ] log.info("Checking to see if Monitor Already Exists.") monitor = client.get_monitor(topics) # Delete Monitor if it Exists. if monitor is not None: log.info("Monitor already exists, deleting it.") client.delete_monitor(monitor) monitor = client.create_monitor(topics, format_type='json') try: