diff --git a/linux/Makefile b/linux/Makefile index 889f07d..93bcb01 100644 --- a/linux/Makefile +++ b/linux/Makefile @@ -68,6 +68,4 @@ ifeq ($(DISTRO),rh) endif uninstall: - rm -rf $(LIBDIR) - # rm -f $(BINDIR)/ogagent - rm -rf $(CFGDIR) + rm -rf $(LIBDIR) $(CFGDIR) $(BINDIR)/ogagent $(INITDIR)/ogagent diff --git a/src/opengnsys/modules/server/OpenGnSys/__init__.py b/src/opengnsys/modules/server/OpenGnSys/__init__.py index 4c0ed59..5a2a378 100644 --- a/src/opengnsys/modules/server/OpenGnSys/__init__.py +++ b/src/opengnsys/modules/server/OpenGnSys/__init__.py @@ -113,7 +113,7 @@ class OpenGnSysWorker(ServerWorker): interface = None # Bound interface for OpenGnsys REST = None # REST object logged_in = False # User session flag - locked = {} # Locked partitions + browser = {} # Browser info commands = [] # Running commands random = None # Random string for secure connections length = 32 # Random string length @@ -141,6 +141,7 @@ class OpenGnSysWorker(ServerWorker): :param route: server callback REST route to return results :param code: code to execute :param op_id: operation id. + :param send_config: indicate if client will send configuration data after command execution """ menu_url = '' # Show execution tacking log, if OGAgent runs on ogLive @@ -164,7 +165,7 @@ class OpenGnSysWorker(ServerWorker): if os_type == 'oglive': # Send configuration data, if needed if send_config: - self.REST.sendMessage('client/configs', {'mac': self.interface.mac, 'ip': self.interface.ip, + self.REST.sendMessage('ogagent/config', {'mac': self.interface.mac, 'ip': self.interface.ip, 'config': operations.get_configuration()}) self._launch_browser(menu_url) @@ -178,7 +179,7 @@ class OpenGnSysWorker(ServerWorker): # Ensure cfg has required configuration variables or an exception will be thrown url = self.service.config.get('opengnsys', 'remote') if operations.os_type == 'ogLive' and 'oglive' in os.environ: - # Replacing server IP if its running on ogLive clinet + # Replacing server IP if it's running on ogLive clinet logger.debug('Activating on ogLive client, new server is {}'.format(os.environ['oglive'])) url = parse.urlsplit(url)._replace(netloc=os.environ['oglive']).geturl() if not url.endswith(os.path.sep): @@ -226,7 +227,8 @@ class OpenGnSysWorker(ServerWorker): # Completing OGAgent initialization process os_type = operations.os_type.lower() if os_type == 'oglive': - # # Following code may be separated into a different function to launch browser while getting the disk configuration + # # Following code may be separated into a different function to launch the browser while getting the disk + # # configuration message = """ @@ -259,7 +261,7 @@ class OpenGnSysWorker(ServerWorker): f = open('/tmp/init.html', 'w') f.write(message) f.close() - # Launch the Browser + # Launching the Browser self._launch_browser('/tmp/init.html') config = operations.get_configuration() self.REST.sendMessage('ogagent/config', {'mac': self.interface.mac, 'ip': self.interface.ip, @@ -403,6 +405,7 @@ class OpenGnSysWorker(ServerWorker): id: operation id. script: command code redirect_url: callback REST route + send_config: flag to send client's configuration after command execution (optional) :param server: headers data :rtype: JSON object with launching status """ @@ -412,13 +415,14 @@ class OpenGnSysWorker(ServerWorker): script = urllib.unquote(post_params.get('script').decode('base64')).decode('utf8') op_id = post_params.get('id') route = post_params.get('redirect_uri') + send_config = (post_params.get('send_config', 'false') == 'true') # Checking if the thread id. exists for c in self.commands: if c.getName() == str(op_id): raise Exception('Task id. already exists: {}'.format(op_id)) if post_params.get('client', 'false') == 'false': # Launching a new thread - thr = threading.Thread(name=op_id, target=self._task_command, args=(route, script, op_id)) + thr = threading.Thread(name=op_id, target=self._task_command, args=(route, script, op_id, send_config)) thr.start() self.commands.append(thr) else: @@ -517,7 +521,16 @@ class OpenGnSysWorker(ServerWorker): @check_secret def process_stopcmd(self, path, get_params, post_params, server): + """ + Stops a running process identified by its trace id. + :param path: + :param get_params: + :param post_params: JSON object {"trace": trace_id} + :param server: authorization header + :return: JSON object: {"stopped": trace_id} + """ logger.debug('Received stopcmd operation with params {}:'.format(post_params)) + # Find operation id. and stop the thread op_id = post_params.get('trace') for c in self.commands: if c.is_alive() and c.getName() == str(op_id): @@ -537,7 +550,6 @@ class OpenGnSysWorker(ServerWorker): """ data = [] logger.debug('Received hardware operation') - self.checkSecret(server) # Processing data try: for comp in operations.get_hardware():