def _GET(self, *param, **params): if not validates_query(self): self.logger.debug( "Failed to get tags. The value of query is invalid.") return web.badrequest(self.view.alert) if not validates_page(self): self.logger.debug( "Failed to get tags. The value of page is invalid.") return web.badrequest(self.view.alert) if is_param(self.input, 'q') is True: tags = findbyand(self.orm, self.input.q) if not tags: self.logger.debug( "Failed to get tags. No such tag - query=%s" % self.input.q) return web.nocontent() self.view.search_value = self.input.q else: tags = findbyall(self.orm) self.view.search_value = "" if not tags: self.logger.debug("Failed to get tag. No tags found.") return web.notfound() if is_param(self.input, 'p') is True: start = int(self.input.p) else: start = 0 pager = Pager(tags, start, TAG_LIST_RANGE) if not pager.exist_now_page(): self.logger.debug( "Failed to get tag. Could not find page - page=%s" % self.input.p) return web.nocontent() self.view.pager = pager if self.is_mode_input(): self.view.tag = new('') self.view.input = self.input return True
def _GET(self, *param, **params): if not validates_query(self): self.logger.debug("Failed to get account. the value of query is invalid. - query=%s" % self.input.q) return web.badrequest(self.view.alert) if not validates_page(self): self.logger.debug("Failed to get account. the value of page is invalid. - page=%s" % self.input.p) return web.badrequest(self.view.alert) if is_param(self.input, "q"): users = findbyand(self.orm, self.input.q) if not users: self.logger.debug("Failed to get account. No such account. - query=%s" % self.input.q) return web.nocontent() self.view.search_value = self.input.q else: users = findbyall(self.orm) self.view.search_value = "" if not users: self.logger.debug("Failed to get account. No accounts found.") return web.notfound() if is_param(self.input, "p"): start = int(self.input.p) else: start = 0 pager = Pager(users, start, USER_LIST_RANGE) if not pager.exist_now_page(): self.logger.debug("Failed to get account. Could not find page - page=%s" % self.input.p) return web.nocontent() self.view.pager = pager if self.is_mode_input(): locales = DEFAULT_LANGS.keys() self.view.locales = locales self.view.user = new('', '', '', '', '') self.view.input = self.input return True
def _GET(self, *param, **params): if not validates_query(self): self.logger.debug("Failed to get tags. The value of query is invalid.") return web.badrequest(self.view.alert) if not validates_page(self): self.logger.debug("Failed to get tags. The value of page is invalid.") return web.badrequest(self.view.alert) if is_param(self.input, 'q') is True: tags = findbyand(self.orm, self.input.q) if not tags: self.logger.debug("Failed to get tags. No such tag - query=%s" % self.input.q) return web.nocontent() self.view.search_value = self.input.q else: tags = findbyall(self.orm) self.view.search_value = "" if not tags: self.logger.debug("Failed to get tag. No tags found.") return web.notfound() if is_param(self.input, 'p') is True: start = int(self.input.p) else: start = 0 pager = Pager(tags, start, TAG_LIST_RANGE) if not pager.exist_now_page(): self.logger.debug("Failed to get tag. Could not find page - page=%s" % self.input.p) return web.nocontent() self.view.pager = pager if self.is_mode_input(): self.view.tag = new('') self.view.input = self.input return True
def _GET(self, *param, **params): host_id = self.chk_hostby1(param) if host_id is None: return web.notfound() if self.is_mode_input() is True: self.view.plugins = WATCH_PLUGINS self.view.cpu_type_instance = COLLECTD_CPU_TYPE_INSTANCE self.view.memory_type_instance = COLLECTD_MEMORY_TYPE_INSTANCE self.view.df_ds = COLLECTD_DF_DS self.view.interface_type = COLLECTD_INTERFACE_TYPE self.view.interface_ds = COLLECTD_INTERFACE_DS self.view.load_ds = COLLECTD_LOAD_DS cpu_logical_number = len(get_proc_cpuinfo()) self.view.cpu_logical_number = range(1, cpu_logical_number+1) self.view.memory_size = string.atol(get_proc_meminfo()["MemTotal"][0]) / 1024 self.view.df_list = get_fs_info() self.view.interface_list = get_ifconfig_info().keys() ## guest os list from karesansui.lib.utils import get_dom_list from karesansui.lib.virt.virt import KaresansuiVirtConnection from karesansui.lib.merge import MergeGuest self.view.dom_list = get_dom_list() dom_info = {} for domname in get_dom_list(): kvc = KaresansuiVirtConnection() virt = kvc.search_kvg_guests(domname)[0] dom_info[domname] = {} dom_info[domname]['network'] = [] dom_info[domname]['disk'] = [] dom_info[domname]['disk_size'] = {} for net_dev in virt.get_interface_info(): dom_info[domname]['network'].append(net_dev['target']['dev']) for disk in virt.get_disk_info(): dom_info[domname]['disk'].append(disk['target']['dev']) dom_info[domname]['disk_size'][disk['target']['dev']] = disk['source']['size'] dom_info[domname]['vcpu'] = virt.get_vcpus_info()['max_vcpus'] kvc.close() self.view.dom_info = dom_info ## disk info self.view.disk_size_info = {} for disk_data in get_fs_info(): self.view.disk_size_info[disk_data['Filesystem']] = disk_data['1048576-blocks'] self.view.processer_num = len(get_proc_cpuinfo().keys()) self.view.supported_langs = DEFAULT_LANGS.keys() self.view.myaddress = self.me.email self.view.mta = "%s:%s" % (karesansui.config['application.mail.server'], karesansui.config['application.mail.port']) self.view.alert_trigger_count = DEFAULT_ALERT_TRIGGER_COUNT; self.view.slient_period = DEFAULT_SLIENT_PERIOD; return True if not validates_query(self): self.logger.debug("Show watch is failed, " "Invalid query value " "- query=%s" % self.input.q) return web.badrequest(self.view.alert) if not validates_page(self): self.logger.debug("Show watch is failed, " "Invalid page value - page=%s" % self.input.p) return web.badrequest(self.view.alert) if is_param(self.input, 'q') is True: watchs = w_findbyname_or_plugin(self.orm, self.input.q) if not watchs: self.logger.debug("Show watch is failed, " "Could not find watch " "- query=%s" % self.input.q) return web.nocontent() self.view.search_value = self.input.q else: watchs = w_findbyall(self.orm) self.view.search_value = "" if is_param(self.input, 'p') is True: start = int(self.input.p) else: start = 0 pager = Pager(watchs, start, WATCH_LIST_RANGE) if not pager.exist_now_page() and is_param(self.input, 'p') is True: self.logger.debug("Show watch is failed, " "Could not find page - page=%s" % self.input.p) return web.nocontent() self.view.pager = pager self.view.input = self.input return True
def _GET(self, *param, **params): host_id = self.chk_hostby1(param) if host_id is None: return web.notfound() (check, edit) = validates_jobsearch(self) if check is False: return web.badrequest(self.view.alert) if edit is True: users = findbyname_BM(self.orm, self.input.user) users_id = [] for user in users: users_id.append(user.id) machine_name = self.input.name.strip() if is_empty(machine_name): machine_name = None if is_empty(self.input.start): start = None else: start = str2datetime( self.input.start, DEFAULT_LANGS[self.me.languages]['DATE_FORMAT'][0]) if is_empty(self.input.end): end = None else: end = str2datetime( self.input.end, DEFAULT_LANGS[self.me.languages]['DATE_FORMAT'][0], True) m_m2js = m2mj_findbyall(self.orm, machine_name, start, end, users_id, True) if not m_m2js: self.logger.debug( "Search m_m2js failed. " "Did not exist m_m2js that in accord with these query. " "name %s, user_id %s, start %s, end %s" % (machine_name, users_id, start, end)) return web.nocontent() self.view.m_m2js = m_m2js self.view.name = self.input.name self.view.user = self.input.user self.view.status = self.input.status self.view.start = self.input.start self.view.end = self.input.end jobgroup_ids = [] for m_m2j in m_m2js: jobgroup_ids.append(m_m2j[1].jobgroup_id) jobgroup_status = self.input.status if is_empty(jobgroup_status): jobgroup_status = None jobgroups = jg_findbyalltype(self.pysilhouette.orm, JOBGROUP_TYPE["SERIAL"], jobgroup_ids, jobgroup_status, desc=True) if not jobgroups: self.logger.debug( "Search jobgroups failed. " "Did not exist jobgroups that in accord with these query. " "jobgroup_ids %s, jobgroup_status %s" % (jobgroup_ids, jobgroup_status)) return web.nocontent() else: m_m2js = m2mj_findbyhost(self.orm, host_id) self.view.m_m2js = m_m2js self.view.name = '' self.view.user = '' self.view.status = '' self.view.start = '' self.view.end = '' jobgroup_ids = [] for m_m2j in m_m2js: jobgroup_ids.append(m_m2j[1].jobgroup_id) jobgroups = jg_findbyalltype(self.pysilhouette.orm, JOBGROUP_TYPE["SERIAL"], jobgroup_ids, desc=True) self.view.JOBGROUP_STATUS = JOBGROUP_STATUS self.view.HYPERVISOR = MACHINE_HYPERVISOR if self.input.has_key('p') is True: if validates_page(self) is True: start = int(self.input.p) else: return web.badrequest(self.view.alert) else: start = 0 self.view.date_format = DEFAULT_LANGS[ self.me.languages]['DATE_FORMAT'][1] self.view.pager = Pager(jobgroups, start, JOB_LIST_RANGE) return True
def _GET(self, *param, **params): host_id = self.chk_hostby1(param) if host_id is None: return web.notfound() if self.is_mode_input() is True: self.view.plugins = WATCH_PLUGINS self.view.cpu_type_instance = COLLECTD_CPU_TYPE_INSTANCE self.view.memory_type_instance = COLLECTD_MEMORY_TYPE_INSTANCE self.view.df_ds = COLLECTD_DF_DS self.view.interface_type = COLLECTD_INTERFACE_TYPE self.view.interface_ds = COLLECTD_INTERFACE_DS self.view.load_ds = COLLECTD_LOAD_DS cpu_logical_number = len(get_proc_cpuinfo()) self.view.cpu_logical_number = range(1, cpu_logical_number + 1) self.view.memory_size = string.atol( get_proc_meminfo()["MemTotal"][0]) / 1024 self.view.df_list = get_fs_info() self.view.interface_list = get_ifconfig_info().keys() ## guest os list from karesansui.lib.utils import get_dom_list from karesansui.lib.virt.virt import KaresansuiVirtConnection from karesansui.lib.merge import MergeGuest self.view.dom_list = get_dom_list() dom_info = {} for domname in get_dom_list(): kvc = KaresansuiVirtConnection() virt = kvc.search_kvg_guests(domname)[0] dom_info[domname] = {} dom_info[domname]['network'] = [] dom_info[domname]['disk'] = [] dom_info[domname]['disk_size'] = {} for net_dev in virt.get_interface_info(): dom_info[domname]['network'].append( net_dev['target']['dev']) for disk in virt.get_disk_info(): dom_info[domname]['disk'].append(disk['target']['dev']) dom_info[domname]['disk_size'][ disk['target']['dev']] = disk['source']['size'] dom_info[domname]['vcpu'] = virt.get_vcpus_info()['max_vcpus'] kvc.close() self.view.dom_info = dom_info ## disk info self.view.disk_size_info = {} for disk_data in get_fs_info(): self.view.disk_size_info[ disk_data['Filesystem']] = disk_data['1048576-blocks'] self.view.processer_num = len(get_proc_cpuinfo().keys()) self.view.supported_langs = DEFAULT_LANGS.keys() self.view.myaddress = self.me.email self.view.mta = "%s:%s" % ( karesansui.config['application.mail.server'], karesansui.config['application.mail.port']) self.view.alert_trigger_count = DEFAULT_ALERT_TRIGGER_COUNT self.view.slient_period = DEFAULT_SLIENT_PERIOD return True if not validates_query(self): self.logger.debug("Show watch is failed, " "Invalid query value " "- query=%s" % self.input.q) return web.badrequest(self.view.alert) if not validates_page(self): self.logger.debug("Show watch is failed, " "Invalid page value - page=%s" % self.input.p) return web.badrequest(self.view.alert) if is_param(self.input, 'q') is True: watchs = w_findbyname_or_plugin(self.orm, self.input.q) if not watchs: self.logger.debug("Show watch is failed, " "Could not find watch " "- query=%s" % self.input.q) return web.nocontent() self.view.search_value = self.input.q else: watchs = w_findbyall(self.orm) self.view.search_value = "" if is_param(self.input, 'p') is True: start = int(self.input.p) else: start = 0 pager = Pager(watchs, start, WATCH_LIST_RANGE) if not pager.exist_now_page() and is_param(self.input, 'p') is True: self.logger.debug("Show watch is failed, " "Could not find page - page=%s" % self.input.p) return web.nocontent() self.view.pager = pager self.view.input = self.input return True