def setRoot(self, root): logging.getLogger().debug(root) if self.pid != None and self.pid != '' and not root: return self.onError("Can't get path for package %s" % self.pid) self.root = root # If is an empty Package, avoid file uploading if self.pinfos['size'] == 0 : self.pinfos['files'] = None # Prepare command parameters for database insertion cmd = prepareCommand(self.pinfos, self.params) # cmd['maxbw'] is in kbits, set in bits cmd['maxbw'] = int(cmd['maxbw']) * 1024 cmd['start_file'], patternActions = MscDatabase().applyCmdPatterns(cmd['start_file'], { 'do_reboot': cmd['do_reboot'], 'do_halt': cmd['issue_halt_to'], 'do_wol': cmd['do_wol'], 'do_inventory': cmd['do_inventory'], } ) addCmd = MscDatabase().addCommand( # TODO: refactor to get less args self.ctx, self.pid, cmd['start_file'], cmd['parameters'], cmd['files'], self.targets, # TODO : need to convert array into something that we can get back ... self.mode, self.gid, cmd['start_script'], cmd['clean_on_success'], cmd['start_date'], cmd['end_date'], "root", # TODO: may use another login name cmd['title'], patternActions['do_halt'], patternActions['do_reboot'], patternActions['do_wol'], cmd['next_connection_delay'], cmd['max_connection_attempt'], patternActions['do_inventory'], cmd['maxbw'], self.root, cmd['deployment_intervals'], self.bundle_id, self.order_in_bundle, cmd['proxy_mode'], self.proxies, cmd['state'] ) if type(addCmd) != int: addCmd.addCallbacks(self.sendResult, self.onError) else: self.onError('Error while creating the command')
def add_command_quick(self, cmd, target, desc, gid = None): """ Deprecated """ ctx = self.currentContext d = MscDatabase().addCommandQuick(ctx, cmd, target, desc, gid) d.addCallbacks(xmlrpcCleanup, lambda err: err) return d
def add_command_quick(self, cmd, target, desc, gid=None): """ Deprecated """ ctx = self.currentContext d = MscDatabase().addCommandQuick(ctx, cmd, target, desc, gid) d.addCallbacks(xmlrpcCleanup, lambda err: err) return d
def setRoot(self, root): logging.getLogger().debug(root) if self.pid != None and self.pid != '' and not root: return self.onError("Can't get path for package %s" % self.pid) self.root = root # If is an empty Package, avoid file uploading if self.pinfos['size'] == 0: self.pinfos['files'] = None # Prepare command parameters for database insertion cmd = prepareCommand(self.pinfos, self.params) # cmd['maxbw'] is in kbits, set in bits cmd['maxbw'] = int(cmd['maxbw']) * 1024 cmd['start_file'], patternActions = MscDatabase().applyCmdPatterns( cmd['start_file'], { 'do_reboot': cmd['do_reboot'], 'do_halt': cmd['issue_halt_to'], 'do_wol': cmd['do_wol'], 'do_inventory': cmd['do_inventory'], }) addCmd = MscDatabase().addCommand( # TODO: refactor to get less args self.ctx, self.pid, cmd['start_file'], cmd['parameters'], cmd['files'], self. targets, # TODO : need to convert array into something that we can get back ... self.mode, self.gid, cmd['start_script'], cmd['clean_on_success'], cmd['start_date'], cmd['end_date'], "root", # TODO: may use another login name cmd['title'], patternActions['do_halt'], patternActions['do_reboot'], patternActions['do_wol'], cmd['next_connection_delay'], cmd['max_connection_attempt'], patternActions['do_inventory'], cmd['maxbw'], self.root, cmd['deployment_intervals'], self.bundle_id, self.order_in_bundle, cmd['proxy_mode'], self.proxies, cmd['state']) if type(addCmd) != int: addCmd.addCallbacks(self.sendResult, self.onError) else: self.onError('Error while creating the command')
def createBundle(self): # treat bundle title try: title = self.params['bundle_title'] except: title = '' # ie. "no title" self.params['bundle_title'] = None if title == None or title == '': title = get_default_bundle_name(len(self.porders)) # Insert bundle object self.session = create_session() bundle = MscDatabase().createBundle(title, self.session) commands = [] for p in self.porders: p_api, pid, order = self.porders[p] pinfos = self.packages[pid] ppath = self.ppaths[pid] params = self.params.copy() if int(order) == int(self.first_order): params['do_wol'] = self.do_wol else: params['do_wol'] = 'off' if int(order) == int(self.last_order): params['do_inventory'] = self.do_inventory params['issue_halt_to'] = self.issue_halt_to else: params['do_inventory'] = 'off' params['issue_halt_to'] = '' # override possible choice of do_reboot from the gui by the one declared in the package # (in bundle mode, the gui does not offer enough choice to say when to reboot) params['do_reboot'] = pinfos['do_reboot'] cmd = prepareCommand(pinfos, params) command = cmd.copy() command['package_id'] = pid command['connect_as'] = 'root' command['mode'] = self.mode command['root'] = ppath command['order_in_bundle'] = order command['proxies'] = self.proxies command['fk_bundle'] = bundle.id commands.append(command) add = MscDatabase().addCommands(self.ctx, self.session, self.targets, commands, self.gid) if type(add) != int: add.addCallbacks(self.sendResult, self.onError) else: self.onError("Error while creating the bundle")
def createBundle(self): # treat bundle title try: title = self.params['bundle_title'] except: title = '' # ie. "no title" self.params['bundle_title'] = None if title == None or title == '': title = get_default_bundle_name(len(self.porders)) # Insert bundle object self.session = create_session() bundle = MscDatabase().createBundle(title, self.session) bundle_id = bundle.id commands = [] for p in self.porders: p_api, pid, order = self.porders[p] pinfos = self.packages[pid] ppath = self.ppaths[pid] params = self.params.copy() if int(order) == int(self.first_order): params['do_wol'] = self.do_wol else: params['do_wol'] = 'off' if int(order) == int(self.last_order): params['do_inventory'] = self.do_inventory params['issue_halt_to'] = self.issue_halt_to else: params['do_inventory'] = 'off' params['issue_halt_to'] = '' # override possible choice of do_reboot from the gui by the one declared in the package # (in bundle mode, the gui does not offer enough choice to say when to reboot) params['do_reboot'] = pinfos['do_reboot'] cmd = prepareCommand(pinfos, params) command = cmd.copy() command['package_id'] = pid command['connect_as'] = 'root' command['mode'] = self.mode command['root'] = ppath command['order_in_bundle'] = order command['proxies'] = self.proxies command['fk_bundle'] = bundle.id commands.append(command) add = MscDatabase().addCommands(self.ctx, self.session, self.targets, commands, self.gid) if type(add) != int: add.addCallbacks(self.sendResult, self.onError) else: self.onError("Error while creating the bundle")
def createBundle(self): # treat bundle title try: title = self.params["bundle_title"] except: title = "" # ie. "no title" self.params["bundle_title"] = None if title == None or title == "": title = get_default_bundle_name(len(self.porders)) # Insert bundle object self.session = create_session() bundle = MscDatabase().createBundle(title, self.session) commands = [] for p in self.porders: p_api, pid, order = self.porders[p] pinfos = self.packages[pid] ppath = self.ppaths[pid] params = self.params.copy() if int(order) == int(self.first_order): params["do_wol"] = self.do_wol else: params["do_wol"] = "off" # override possible choice of do_reboot from the gui by the one declared in the package # (in bundle mode, the gui does not offer enough choice to say when to reboot) params["do_reboot"] = pinfos["do_reboot"] cmd = prepareCommand(pinfos, params) command = cmd.copy() command["package_id"] = pid command["connect_as"] = "root" command["mode"] = self.mode command["root"] = ppath command["order_in_bundle"] = order command["proxies"] = self.proxies command["fk_bundle"] = bundle.id command["do_windows_update"] = "disable" commands.append(command) add = MscDatabase().addCommands(self.ctx, self.session, self.targets, commands, self.gid) if type(add) != int: add.addCallbacks(self.sendResult, self.onError) else: self.onError("Error while creating the bundle")
def setRoot(self, root): logging.getLogger().debug(root) if self.pid != None and self.pid != "" and not root: return self.onError("Can't get path for package %s" % self.pid) self.root = root # If is an empty Package, avoid file uploading if "size" in self.pinfos: if self.pinfos["size"] == 0: self.pinfos["files"] = None # Prepare command parameters for database insertion cmd = prepareCommand(self.pinfos, self.params) # cmd['maxbw'] is in kbits, set in bits cmd["maxbw"] = int(cmd["maxbw"]) * 1024 cmd["do_wol_with_imaging"] = "disable" cmd["do_windows_update"] = "disable" _patterns = { "do_reboot": cmd["do_reboot"], "do_halt": cmd["issue_halt_to"], "do_wol": cmd["do_wol"], "do_wol_with_imaging": cmd["do_wol_with_imaging"], "do_windows_update": cmd["do_windows_update"], "do_inventory": cmd["do_inventory"], } cmd["start_file"], patternActions = MscDatabase().applyCmdPatterns(cmd["start_file"], _patterns) addCmd = MscDatabase().addCommand( # TODO: refactor to get less args self.ctx, self.pid, cmd["start_file"], cmd["parameters"], cmd["files"], self.targets, # TODO : need to convert array into something that we can get back ... self.mode, self.gid, cmd["start_script"], cmd["clean_on_success"], cmd["start_date"], cmd["end_date"], "root", # TODO: may use another login name cmd["title"], patternActions["do_halt"], patternActions["do_reboot"], patternActions["do_wol"], patternActions["do_wol_with_imaging"], patternActions["do_windows_update"], cmd["next_connection_delay"], cmd["max_connection_attempt"], patternActions["do_inventory"], cmd["maxbw"], self.root, cmd["deployment_intervals"], self.bundle_id, self.order_in_bundle, cmd["proxy_mode"], self.proxies, cmd["state"], cmd_type=self.cmd_type, ) if type(addCmd) != int: addCmd.addCallbacks(self.sendResult, self.onError) else: self.onError("Error while creating the command")