def setup(self, config_file): # read the database configuration DatabaseConfig.setup(self, config_file) # read the other inventory default parameters if self.cp.has_section("graph"): for i in self.getInventoryParts(): if self.cp.has_option("graph", i): self.graph[i] = self.cp.get("graph", i).split('|') else: self.graph[i] = [] if self.cp.has_option("expert_mode", i): self.expert_mode[i] = self.cp.get("expert_mode", i).split('|') else: self.expert_mode[i] = [] if self.cp.has_section("computers"): if self.cp.has_option("computers", "display"): self.display = map(lambda x: x.split('::'), self.cp.get("computers", "display").split('||')) # Registry::Path::path||Registry::Value::srvcomment::Path==srvcomment if self.cp.has_option("computers", "content") and not self.cp.get("computers", "content") == '': for c in map(lambda x: x.split('::'), self.cp.get("computers", "content").split('||')): if not self.content.has_key(c[0]): self.content[c[0]] = [] self.content[c[0]].append( map(lambda x: desArrayIfUnic(x.split('==')), c[1:])) if self.cp.has_section('querymanager'): if self.cp.has_option('querymanager', 'list'): simple = self.cp.get('querymanager', 'list') self.list = {} if simple != '': # Software/ProductName||Hardware/ProcessorType||Hardware/OperatingSystem||Drive/TotalSpace for l in simple.split('||'): self.list[l] = ['string'] # TODO also int... if self.cp.has_option('querymanager', 'double'): double = self.cp.get('querymanager', 'double') self.double = {} if double != '': # Software/Products::Software/ProductName##Software/ProductVersion for l in double.split('||'): name, vals = l.split('::') val1, val2 = vals.split('##') self.double[name] = [[val1, 'string'], [val2, 'string']] if self.cp.has_option('querymanager', 'halfstatic'): halfstatic = self.cp.get('querymanager', 'halfstatic') self.halfstatic = {} if halfstatic != '': # Registry/Value::Path##DisplayName for l in halfstatic.split('||'): name, vals = l.split('::') k, v = vals.split('##') self.halfstatic[name] = ['string', k, v] if self.cp.has_option('querymanager', 'extended'): extended = self.cp.get('querymanager', 'extended') self.extended = {} if extended != '': for l in extended.split('||'): self.extended[l] = ['string']
def generation_Commands(driver,host,port): # Read config from ini file inifile = path.join(mmcconfdir, "plugins", "pulse2.ini") config = DatabaseConfig() config.setup(inifile) dbpasswd = config.dbpasswd connectionC=create_engine('%s://mmc:%s@%s:%s/msc' %(driver,dbpasswd,host,port)) c=connectionC.connect() now = time.time() tomorrow = now + 3600*24 start_date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(now)) end_date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(tomorrow)) statement = """INSERT INTO `commands` (id,state,creation_date,start_file,parameters, start_script,clean_on_success,files,start_date, end_date,connect_as,creator,dispatched,title, do_inventory,do_wol,next_connection_delay, max_connection_attempt,pre_command_hook, post_command_hook,pre_run_hook,post_run_hook, on_success_hook,on_failure_hook,maxbw, deployment_intervals,do_reboot,do_halt,fk_bundle, order_in_bundle,package_id,proxy_mode) VALUES (1,'active','%s','sleep 360\n','', 'enable','enable','','%s','%s','root','root','YES', 'Test Mandriva : Pause 6 minute\n','disable', 'disable',360,3,NULL,NULL,NULL,NULL,NULL,NULL, 0,NULL,'disable','',NULL,NULL,NULL,'none') """ % (start_date, start_date, end_date) c.execute(statement) statement = """INSERT INTO `commands` (id,state,creation_date,start_file,parameters, start_script,clean_on_success,files,start_date, end_date,connect_as,creator,dispatched,title, do_inventory,do_wol,next_connection_delay, max_connection_attempt,pre_command_hook, post_command_hook,pre_run_hook,post_run_hook, on_success_hook,on_failure_hook,maxbw, deployment_intervals,do_reboot,do_halt,fk_bundle, order_in_bundle,package_id,proxy_mode) VALUES (2,'active','%s','sleep 360\n','', 'enable','enable','','%s','%s','root','root','YES', 'Test Mandriva : Pause 6 minute\n','disable', 'disable',360,3,NULL,NULL,NULL,NULL,NULL,NULL, 0,NULL,'disable','',NULL,NULL,NULL,'none') """ % (start_date, start_date, end_date) c.execute(statement) statement = """ INSERT INTO `commands_on_host` (id, fk_commands, host, start_date, end_date, current_state, stage, awoken, uploaded, executed, deleted, inventoried, rebooted, halted, next_launch_date, attempts_left, attempts_failed, balance, next_attempt_date_time, current_launcher, fk_target, scheduler, last_wol_attempt,fk_use_as_proxy, order_in_proxy, max_clients_per_proxy) VALUES (1,1,'localhost','%s','%s', 'execution_in_progress','pending','IGNORED','IGNORED', 'WORK_IN_PROGRESS','TODO','TODO','TODO','TODO', '2009-10-29 22:53:59',3,0,0,0,'launcher_01',1, 'scheduler_01',NULL,NULL,NULL,0) """ % (start_date, end_date) c.execute(statement) statement = """ INSERT INTO `commands_on_host` (id, fk_commands, host, start_date, end_date, current_state, stage, awoken, uploaded, executed, deleted, inventoried, rebooted, halted, next_launch_date, attempts_left, attempts_failed, balance, next_attempt_date_time, current_launcher, fk_target, scheduler, last_wol_attempt,fk_use_as_proxy, order_in_proxy, max_clients_per_proxy) VALUES (2,2,'localhost','%s','%s', 'scheduled','pending','IGNORED','IGNORED','TODO', 'TODO','TODO','TODO','TODO','2009-10-29 23:53:59', 3,0,0,0,'launcher_01',1,'scheduler_01', NULL,NULL,NULL,0) """ % (start_date, end_date) c.execute(statement) statement = """ INSERT INTO `commands_on_host` (id, fk_commands, host, start_date, end_date, current_state, stage, awoken, uploaded, executed, deleted, inventoried, rebooted, halted, next_launch_date, attempts_left, attempts_failed, balance, next_attempt_date_time, current_launcher, fk_target, scheduler, last_wol_attempt,fk_use_as_proxy, order_in_proxy, max_clients_per_proxy) VALUES (3,1,'localhost','%s','%s', 'scheduled','pending','IGNORED','IGNORED','TODO', 'TODO','TODO','TODO','TODO','2009-10-29 23:53:59', 3,0,0,0,'launcher_01',1,'scheduler_01', NULL,NULL,NULL,0) """ % (start_date, end_date) c.execute(statement) c.execute(""" INSERT INTO `target` VALUES (1,'localhost','file://0','','UUID1','','','','') """) c.close() return connectionC
def setup(self, config_file): # read the database configuration DatabaseConfig.setup(self, config_file)
def generation_Commands(driver, host, port): # Read config from ini file inifile = path.join(mmcconfdir, "plugins", "pulse2.ini") config = DatabaseConfig() config.setup(inifile) dbpasswd = config.dbpasswd connectionC = create_engine('%s://mmc:%s@%s:%s/msc' % (driver, dbpasswd, host, port)) c = connectionC.connect() now = time.time() tomorrow = now + 3600 * 24 start_date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(now)) end_date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(tomorrow)) statement = """INSERT INTO `commands` (id,state,creation_date,start_file,parameters, start_script,clean_on_success,files,start_date, end_date,connect_as,creator,dispatched,title, do_inventory,do_wol,next_connection_delay, max_connection_attempt,pre_command_hook, post_command_hook,pre_run_hook,post_run_hook, on_success_hook,on_failure_hook,maxbw, deployment_intervals,do_reboot,do_halt,fk_bundle, order_in_bundle,package_id,proxy_mode) VALUES (1,'active','%s','sleep 360\n','', 'enable','enable','','%s','%s','root','root','YES', 'Test Mandriva : Pause 6 minute\n','disable', 'disable',360,3,NULL,NULL,NULL,NULL,NULL,NULL, 0,NULL,'disable','',NULL,NULL,NULL,'none') """ % (start_date, start_date, end_date) c.execute(statement) statement = """INSERT INTO `commands` (id,state,creation_date,start_file,parameters, start_script,clean_on_success,files,start_date, end_date,connect_as,creator,dispatched,title, do_inventory,do_wol,next_connection_delay, max_connection_attempt,pre_command_hook, post_command_hook,pre_run_hook,post_run_hook, on_success_hook,on_failure_hook,maxbw, deployment_intervals,do_reboot,do_halt,fk_bundle, order_in_bundle,package_id,proxy_mode) VALUES (2,'active','%s','sleep 360\n','', 'enable','enable','','%s','%s','root','root','YES', 'Test Mandriva : Pause 6 minute\n','disable', 'disable',360,3,NULL,NULL,NULL,NULL,NULL,NULL, 0,NULL,'disable','',NULL,NULL,NULL,'none') """ % (start_date, start_date, end_date) c.execute(statement) statement = """ INSERT INTO `commands_on_host` (id, fk_commands, host, start_date, end_date, current_state, stage, awoken, uploaded, executed, deleted, inventoried, rebooted, halted, next_launch_date, attempts_left, attempts_failed, balance, next_attempt_date_time, current_launcher, fk_target, scheduler, last_wol_attempt,fk_use_as_proxy, order_in_proxy, max_clients_per_proxy) VALUES (1,1,'localhost','%s','%s', 'execution_in_progress','pending','IGNORED','IGNORED', 'WORK_IN_PROGRESS','TODO','TODO','TODO','TODO', '2009-10-29 22:53:59',3,0,0,0,'launcher_01',1, 'scheduler_01',NULL,NULL,NULL,0) """ % (start_date, end_date) c.execute(statement) statement = """ INSERT INTO `commands_on_host` (id, fk_commands, host, start_date, end_date, current_state, stage, awoken, uploaded, executed, deleted, inventoried, rebooted, halted, next_launch_date, attempts_left, attempts_failed, balance, next_attempt_date_time, current_launcher, fk_target, scheduler, last_wol_attempt,fk_use_as_proxy, order_in_proxy, max_clients_per_proxy) VALUES (2,2,'localhost','%s','%s', 'scheduled','pending','IGNORED','IGNORED','TODO', 'TODO','TODO','TODO','TODO','2009-10-29 23:53:59', 3,0,0,0,'launcher_01',1,'scheduler_01', NULL,NULL,NULL,0) """ % (start_date, end_date) c.execute(statement) statement = """ INSERT INTO `commands_on_host` (id, fk_commands, host, start_date, end_date, current_state, stage, awoken, uploaded, executed, deleted, inventoried, rebooted, halted, next_launch_date, attempts_left, attempts_failed, balance, next_attempt_date_time, current_launcher, fk_target, scheduler, last_wol_attempt,fk_use_as_proxy, order_in_proxy, max_clients_per_proxy) VALUES (3,1,'localhost','%s','%s', 'scheduled','pending','IGNORED','IGNORED','TODO', 'TODO','TODO','TODO','TODO','2009-10-29 23:53:59', 3,0,0,0,'launcher_01',1,'scheduler_01', NULL,NULL,NULL,0) """ % (start_date, end_date) c.execute(statement) c.execute( """ INSERT INTO `target` VALUES (1,'localhost','file://0','','UUID1','','','','') """ ) c.close() return connectionC