+ if args.verbosity >= 1:
+ print_to_stderr("DEBUG: VIRL simulation session-id: {}"
+ .format(session_id))
+
+ # Set session expiry to autokill sessions if not done from jenkins
+ if not args.keep:
+ if args.verbosity >= 1:
+ print_to_stderr("DEBUG: Setting expire for session-id: {}"
+ .format(session_id))
+ try:
+ req = requests.put('http://' + args.virl_ip +
+ '/simengine/rest/admin-update/' + session_id +
+ '/expiry',
+ auth=(args.admin_username, args.password),
+ params={'user': args.username,
+ 'expires': args.expiry})
+ if args.verbosity >= 2:
+ print_to_stderr("DEBUG: - Request URL {}"
+ .format(req.url))
+ print_to_stderr("{}"
+ .format(req.text))
+ print_to_stderr("DEBUG: - Response Code {}"
+ .format(req.status_code))
+ if req.status_code != 200:
+ raise RuntimeError("ERROR: Setting expiry to simulation - "
+ "Status other than 200 HTTP OK:\n{}"
+ .format(req.content))
+ except (requests.exceptions.RequestException,
+ RuntimeError) as ex_error:
+ print_to_stderr(ex_error)
+ req = requests.get('http://' + args.virl_ip +
+ '/simengine/rest/stop/' + session_id,
+ auth=(args.username, args.password))
+ os.remove(temp_topology)
+ print "{}".format(session_id)
+ sys.exit(1)