Esempio n. 1
0
 def run(self, cur_bg):
     to_run = []
     _src_com = server_command.srv_command(source=cur_bg.command_xml)
     devs = device.objects.filter(
         Q(pk__in=[int(_pk) for _pk in _src_com.xpath(".//ns:object/@pk")]))
     # split for bootservers
     _boot_dict = {}
     for _dev in devs:
         if _dev.bootserver_id:
             _boot_dict.setdefault(_dev.bootserver_id, []).append(_dev)
     for srv_id, dev_list in _boot_dict.iteritems():
         # target command
         srv_com = server_command.srv_command(command="refresh")
         # only valid for one device
         srv_com["devices"] = srv_com.builder(
             "devices", *[
                 srv_com.builder("device",
                                 name=dev.name,
                                 pk="{:d}".format(dev.pk))
                 for dev in dev_list
             ])
         to_run.append((
             background_job_run(
                 background_job=cur_bg,
                 server=dev_list[0].bootserver,
                 command_xml=unicode(srv_com),
                 start=cluster_timezone.localize(datetime.datetime.now()),
             ),
             srv_com,
             icswServiceEnum.mother_server,
         ))
     return to_run
 def run(self, cur_bg):
     _src_com = server_command.srv_command(source=cur_bg.command_xml)
     # target command
     srv_com = server_command.srv_command(command="sync_sensor_threshold")
     _sc = config_tools.icswServerCheck(service_type_enum=icswServiceEnum.collectd_server)
     to_run = []
     if _sc.get_result().effective_device:
         to_run.append(
             (
                 background_job_run(
                     background_job=cur_bg,
                     server=_sc.effective_device,
                     command_xml=str(srv_com),
                     start=cluster_timezone.localize(datetime.datetime.now()),
                 ),
                 srv_com,
                 icswServiceEnum.collectd_server,
             )
         )
     else:
         self.log("no valid rrd-collector found", logging_tools.LOG_LEVEL_ERROR)
     return to_run
Esempio n. 3
0
 def run(self, cur_bg):
     to_run = []
     sensor_action = SensorAction.objects.get(Q(pk=cur_bg.options))
     _mother_com = sensor_action.get_mother_command()
     if _mother_com is not None:
         _src_com = server_command.srv_command(source=cur_bg.command_xml)
         devs = device.objects.filter(Q(pk__in=[int(_pk) for _pk in _src_com.xpath(".//ns:object/@pk")]))
         # split for bootservers
         _boot_dict = {}
         for _dev in devs:
             if _dev.bootserver_id:
                 _boot_dict.setdefault(_dev.bootserver_id, []).append(_dev)
         for srv_id, dev_list in _boot_dict.iteritems():
             # target command
             srv_com = server_command.srv_command(command=_mother_com[0])
             # only valid for one device
             srv_com["devices"] = srv_com.builder(
                 "devices",
                 *sum(
                     [
                         sensor_action.build_mother_element(srv_com.builder, dev) for dev in dev_list
                     ],
                     []
                 )
             )
             to_run.append(
                 (
                     background_job_run(
                         background_job=cur_bg,
                         server=dev_list[0].bootserver,
                         command_xml=unicode(srv_com),
                         start=cluster_timezone.localize(datetime.datetime.now()),
                     ),
                     srv_com,
                     icswServiceEnum.mother_server,
                 )
             )
     return to_run
Esempio n. 4
0
    def run(self, cur_bg):
        '''
        Find actual cluster-server of virtual desktop and reload/restart there
        :param cur_bg:
        '''
        _src_com = server_command.srv_command(source=cur_bg.command_xml)
        vdus = virtual_desktop_user_setting.objects.get(
            Q(pk=_src_com.xpath(".//ns:object/@pk")[0]))

        srv_com = server_command.srv_command(command="reload_virtual_desktop")
        srv_com["vdus"] = vdus.pk

        to_run = [(
            background_job_run(
                background_job=cur_bg,
                server=vdus.device,
                command_xml=unicode(srv_com),
                start=cluster_timezone.localize(datetime.datetime.now()),
            ),
            srv_com,
            icswServiceEnum.cluster_server,
        )]
        return to_run
Esempio n. 5
0
 def run(self, cur_bg):
     # step 1: create user homes
     _uo = user.objects
     create_user_list = _uo.exclude(
         Q(export=None)
     ).filter(
         Q(home_dir_created=False) & Q(active=True) & Q(group__active=True)
     ).select_related(
         "export__device"
     )
     to_run = []
     if create_user_list.count():
         self.log("{} to create".format(logging_tools.get_plural("user home", len(create_user_list))))
         for create_user in create_user_list:
             srv_com = server_command.srv_command(command="create_user_home")
             srv_com["server_key:username"] = create_user.login
             to_run.append(
                 (
                     background_job_run(
                         background_job=cur_bg,
                         server=create_user.export.device,
                         command_xml=unicode(srv_com),
                         start=cluster_timezone.localize(datetime.datetime.now()),
                     ),
                     srv_com,
                     icswServiceEnum.cluster_server,
                     #
                 )
             )
     else:
         self.log("no user homes to create", logging_tools.LOG_LEVEL_WARN)
     # check directory sync requests
     no_device = []
     for _config, _command, _srv_type in [
         ("ldap_server", "sync_ldap_config", icswServiceEnum.cluster_server),
         ("yp_server", "write_yp_config", icswServiceEnum.cluster_server),
         ("monitor_server", "sync_http_users", icswServiceEnum.monitor_server),
     ]:
         _cdict = config_tools.device_with_config(_config)
         for _sc_list in _cdict.itervalues():
             for _sc in _sc_list:
                 if _sc.effective_device:
                     self.log(
                         u"effective device for {} (command {}) is {}".format(
                             _config,
                             _command,
                             unicode(_sc.effective_device),
                         )
                     )
                     srv_com = server_command.srv_command(command=_command)
                     to_run.append(
                         (
                             background_job_run(
                                 background_job=cur_bg,
                                 server=_sc.effective_device,
                                 command_xml=unicode(srv_com),
                                 start=cluster_timezone.localize(datetime.datetime.now()),
                             ),
                             srv_com,
                             _srv_type,
                         )
                     )
         if not _cdict:
             no_device.append(_command)
     if no_device:
         self.log("no device(s) found for {}".format(", ".join(no_device)), logging_tools.LOG_LEVEL_WARN)
     return to_run