Beispiel #1
0
 def readConf(self):
     PluginConfig.readConf(self)
     DatabaseConfig.setup(self, self.conffile)
     #update_command
     try:
         self.update_commands_cron = self.get(
             'main', 'update_commands_cron')
     except (NoOptionError, NoSectionError):
         self.update_commands_cron = '10 12 * * *'
     try:
         self.enable_update_commands = int(
             self.get('main', 'enable_update_commands'))
     except:
         self.enable_update_commands = 1
     #add_update_description
     try:
         self.add_update_description_cron = self.get(
             'main', 'add_update_description_cron')
     except (NoOptionError, NoSectionError):
         self.add_update_description_cron = '0 */1 * * *'
     try:
         self.enable_update_description = int(
             self.get('main', 'enable_update_description'))
     except:
         self.enable_update_description = 1
Beispiel #2
0
 def readConf(self):
     PluginConfig.readConf(self)
     DatabaseConfig.setup(self, self.conffile)
     #update_command
     try:
         self.update_commands_cron = self.get('main',
                                              'update_commands_cron')
     except (NoOptionError, NoSectionError):
         self.update_commands_cron = '10 12 * * *'
     try:
         self.enable_update_commands = int(
             self.get('main', 'enable_update_commands'))
     except:
         self.enable_update_commands = 1
     #add_update_description
     try:
         self.add_update_description_cron = self.get(
             'main', 'add_update_description_cron')
     except (NoOptionError, NoSectionError):
         self.add_update_description_cron = '0 */1 * * *'
     try:
         self.enable_update_description = int(
             self.get('main', 'enable_update_description'))
     except:
         self.enable_update_description = 1
Beispiel #3
0
 def readConf(self):
     PluginConfig.readConf(self)
     DatabaseConfig.setup(self, self.conffile)
     try:
         self.historization = self.get('data', 'historization')
     except (NoOptionError, NoSectionError):
         self.historization = '15 2 * * *'
     try:
         self.indicators = self.get('data', 'indicators')
     except (NoOptionError, NoSectionError):
         self.indicators = 'indicators.xml'
     try:
         self.updateTemplate = self.get('data', 'updateTemplate')
     except (NoOptionError, NoSectionError):
         self.updateTemplate = 'default.xml'
Beispiel #4
0
 def readConf(self):
     PluginConfig.readConf(self)
     DatabaseConfig.setup(self, self.conffile)
     report_img_path = 'file:///etc/mmc/plugins/report/img/'
     try:
         self.historization = self.get('data', 'historization')
     except (NoOptionError, NoSectionError):
         self.historization = '15 22 * * *'
     try:
         self.indicators = self.get('data', 'indicators')
     except (NoOptionError, NoSectionError):
         self.indicators = 'indicators.xml'
     try:
         self.reportTemplate = self.get('data', 'reportTemplate')
     except (NoOptionError, NoSectionError):
         self.reportTemplate = 'default.xml'
     try:
         self.reportCSS = os.path.join(reportconfdir, 'css', self.get('data', 'reportCSS'))
     except (NoOptionError, NoSectionError, OSError):
         self.reportCSS = os.path.join(reportconfdir, 'css', 'style.css')
     try:
         self.graphCSS = [os.path.join(reportconfdir, 'css', f) for f in self.get('data', 'graphCSS').replace(' ', '').split(',')]
     except (NoOptionError, NoSectionError, OSError):
         self.graphCSS = []
     try:
         self.company = self.get('pdfvars', 'company')
     except (NoOptionError, NoSectionError):
         self.company = 'Company'
     try:
         self.company_logo_path = report_img_path + self.get('pdfvars', 'company_logo_path')
     except (NoOptionError, NoSectionError):
         self.company_logo_path = report_img_path + 'mandriva.png'
     try:
         self.pulse_logo_path = report_img_path + self.get('pdfvars', 'pulse_logo_path')
     except (NoOptionError, NoSectionError):
         self.pulse_logo_path = report_img_path + 'pulse.png'
Beispiel #5
0
 def setup(self, config_file):
     # read the database configuration
     DatabaseConfig.setup(self, config_file)
Beispiel #6
0
    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']
Beispiel #7
0
    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']
Beispiel #8
0
 def setup(self, config_file):
     # read the database configuration
     DatabaseConfig.setup(self, config_file)
Beispiel #9
0
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
Beispiel #10
0
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