Exemplo n.º 1
0
    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
Exemplo n.º 2
0
def validates_guest_add(obj):
    checker = Checker()
    check = True

    _ = obj._
    checker.errors = []

    if not is_param(obj.input, 'm_name'):
        check = False
        checker.add_error(_('Parameter m_name does not exist.'))
    else:
        check = checker.check_string(
                    _('Machine Name'),
                    obj.input.m_name,
                    CHECK_EMPTY | CHECK_LENGTH | CHECK_ONLYSPACE,
                    None,
                    min = MACHINE_NAME_MIN_LENGTH,
                    max = MACHINE_NAME_MAX_LENGTH,
            ) and check

    if is_param(obj.input, 'note_title'):
        check = checker.check_string(
                    _('Title'),
                    obj.input.note_title,
                    CHECK_LENGTH | CHECK_ONLYSPACE,
                    None,
                    min = NOTE_TITLE_MIN_LENGTH,
                    max = NOTE_TITLE_MAX_LENGTH,
                ) and check

    if is_param(obj.input, 'note_value'):
        check = checker.check_string(
                    _('Note'),
                    obj.input.note_value,
                    CHECK_ONLYSPACE,
                    None,
                    None,
                    None,
                ) and check

    if is_param(obj.input, 'tags'):
        for tag in comma_split(obj.input.tags):
            check = checker.check_string(
                        _('Tag'),
                        tag,
                        CHECK_LENGTH | CHECK_ONLYSPACE,
                        None,
                        min = TAG_MIN_LENGTH,
                        max = TAG_MAX_LENGTH,
                    ) and check


    if not is_param(obj.input, 'm_hypervisor'):
        check = False
        checker.add_error(_('Parameter m_hypervisor does not exist.'))
    else:
        check = checker.check_hypervisor(
                _('Hypervisor'),
                obj.input.m_hypervisor,
                CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
                HYPERVISOR_MIN_SIZE,
                HYPERVISOR_MAX_SIZE,
            ) and check

    if not is_param(obj.input, 'domain_name'):
        check = False
        checker.add_error(_('Parameter domain_name does not exist.'))
    else:
        check = checker.check_string(
                _('Domain Name'),
                obj.input.domain_name,
                CHECK_EMPTY | CHECK_VALID | CHECK_LENGTH | CHECK_ONLYSPACE,
                '[^-a-zA-Z0-9_\.]+',
                DOMAIN_NAME_MIN_LENGTH,
                DOMAIN_NAME_MAX_LENGTH,
            ) and check

        if obj.input.domain_name in get_dom_list():
            dom_type = get_dom_type(obj.input.domain_name)
            checker.add_error(_("The same domain name already exists for hypervisor '%s'.") % dom_type.upper())
            check = False

    if is_param(obj.input, 'vm_mem_size'):
        check = checker.check_number(
                _('Memory Size (MB)'),
                obj.input.vm_mem_size,
                CHECK_VALID | CHECK_MIN | CHECK_EMPTY,
                MEMORY_MIN_SIZE,
                None,
            ) and check

    if is_param(obj.input, 'pool_type'):
        if obj.input.pool_type != "block":
            if is_param(obj.input, 'vm_disk_size'):
                check = checker.check_number(
                        _('Disk Size (MB)'),
                        obj.input.vm_disk_size,
                        CHECK_VALID | CHECK_MIN | CHECK_EMPTY,
                        DISK_MIN_SIZE,
                        None,
                ) and check

    if not is_param(obj.input, 'boot_image'):
        check = False
        checker.add_error(_('Parameter boot_image does not exist.'))
    else:
        if obj.input.boot_image == "kernel":
            if not is_param(obj.input, 'vm_kernel'):
                check = False
                checker.add_error(_('Parameter vm_kernel does not exist.'))
            else:
                check = checker.check_startfile(
                        _('Kernel Image'),
                        obj.input.vm_kernel,
                        CHECK_EMPTY | CHECK_VALID | CHECK_EXIST,
                    ) and check

            if not is_param(obj.input, 'vm_initrd'):
                check = False
                checker.add_error(_('Parameter vm_initrd does not exist.'))
            else:
                check = checker.check_startfile(
                        _('Initrd Image'),
                        obj.input.vm_initrd,
                        CHECK_EMPTY | CHECK_VALID | CHECK_EXIST,
                    ) and check

        if obj.input.boot_image == "iso":
            if not is_param(obj.input, 'vm_iso'):
                check = False
                checker.add_error(_('Parameter vm_iso does not exist.'))
            else:
                check = checker.check_startfile(
                        _('ISO Image'),
                        obj.input.vm_iso,
                        CHECK_EMPTY | CHECK_VALID | CHECK_EXIST,
                    ) and check
                if check:
                    check = is_iso9660_filesystem_format(obj.input.vm_iso)
                    checker.add_error(_('"%s" is not valid ISO 9660 CD-ROM filesystem data.') % obj.input.vm_iso)

    if not is_param(obj.input, 'keymap'):
        check = False
        checker.add_error(_('"%s" is required.') % _('Graphics Keymap'))
    else:
        hypervisor = "KVM"
        if int(obj.input.m_hypervisor) == MACHINE_HYPERVISOR['XEN']:
            hypervisor = "XEN"
        elif int(obj.input.m_hypervisor) == MACHINE_HYPERVISOR['KVM']:
            hypervisor = "KVM"
        check = checker.check_keymap(
                _('Graphics Keymap'),
                obj.input.keymap,
                CHECK_EMPTY | CHECK_EXIST,
                hypervisor
                ) and check

    if not is_param(obj.input, 'vm_graphics_port'):
        check = False
        checker.add_error(_('Parameter vm_graphics_port does not exist.'))
    else:
        check = checker.check_number(
                _('Graphics Port Number'),
                obj.input.vm_graphics_port,
                CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
                GRAPHICS_PORT_MIN_NUMBER,
                GRAPHICS_PORT_MAX_NUMBER,
            ) and check

    if not is_param(obj.input, 'vm_mac'):
        check = False
        checker.add_error(_('Parameter vm_mac does not exist.'))
    else:
        check = checker.check_macaddr(
                _('MAC Address'),
                obj.input.vm_mac,
                CHECK_EMPTY | CHECK_VALID,
            ) and check

    obj.view.alert = checker.errors
    return check
Exemplo n.º 3
0
    def _GET(self, *param, **params):
        host_id = self.chk_hostby1(param)
        if host_id is None: return web.notfound()
        self.view.host_id = host_id

        target = param[1]
        if target is None: return web.notfound()
        self.view.target = target

        group_display = False
        dev_list = []
        graph_type = []
        rrd = RRD()
        if target == "cpu":
            for dev in range(0, len(get_proc_cpuinfo())):
                if rrd.check_rrd_file_exist("cpu", dev):
                    dev_list.append(dev)
            graph_type = ['default']
        elif target == "memory":
            dev_list = ['default']
            graph_type = ['default']
        elif target == "df":
            df_list = get_fs_info()
            for fs in df_list:
                if COLLECTD_DF_RRPORT_BY_DEVICE is True:
                    dev = fs['Filesystem']
                    dev = re.sub(r'^/dev/', '', dev)
                    dev = re.sub(r'/', '_', dev)
                else:
                    dev = fs['Mounted']
                    if dev == "/":
                        dev = "root"
                    else:
                        dev = re.sub(r'^/', '', dev)
                        dev = re.sub(r'/', '_', dev)
                if rrd.check_rrd_file_exist("df", dev):
                    dev_list.append(dev)
            graph_type = ['default']

        elif target == "disk":
            group_display = True
            disk_list = get_hdd_list()
            for disk in disk_list:
                dev = disk
                dev = re.sub(r'^/dev/', '', dev)
                if rrd.check_rrd_file_exist("disk", dev):
                    dev_list.append(dev)
            graph_type = ['merged', 'octets', 'ops', 'time']

        elif target == "interface":
            group_display = True
            if_list = get_ifconfig_info().keys()
            for dev in if_list:
                if rrd.check_rrd_file_exist("interface", dev):
                    dev_list.append(dev)
            graph_type = ['packets', 'octets', 'errors']

        elif target == "load":
            dev_list = ['default']
            graph_type = ['default']
        elif target == "uptime":
            dev_list = ['default']
            graph_type = ['default']
        elif target == "users":
            dev_list = ['default']
            graph_type = ['default']
        elif target == "libvirt":
            virt_cpu_type = ['default']
            virt_disk_type = ['octets', 'ops']
            virt_interface_type = ['packets', 'octets', 'errors', 'dropped']
            virt_list = {}
            virt_file_exist = {}

            try:
                kvc = KaresansuiVirtConnection()

                for domname in get_dom_list():
                    virt_list[domname] = {}

                    if rrd.set_rrd_dir_host(domname) is False:
                        virt_file_exist[domname] = False
                        continue

                    try:
                        virt = kvc.search_kvg_guests(domname)[0]
                    except:
                        virt_file_exist[domname] = False
                        continue

                    virt_list[domname]['vcpu'] = {}
                    if rrd.check_rrd_file_exist("libvirt", "total", "vcpu"):
                        virt_list[domname]['vcpu']['total'] = virt_cpu_type
                    for i in range(virt.get_vcpus_info()['max_vcpus']):
                        if rrd.check_rrd_file_exist("libvirt", i, "vcpu"):
                            virt_list[domname]['vcpu'][i] = virt_cpu_type

                    virt_list[domname]['disk'] = {}
                    for disk in virt.get_disk_info():
                        if rrd.check_rrd_file_exist("libvirt",
                                                    disk['target']['dev'],
                                                    "disk"):
                            virt_list[domname]['disk'][
                                disk['target']['dev']] = virt_disk_type

                    virt_list[domname]['interface'] = {}
                    for net_dev in virt.get_interface_info():
                        if rrd.check_rrd_file_exist("libvirt",
                                                    net_dev['target']['dev'],
                                                    "interface"):
                            virt_list[domname]['interface'][
                                net_dev['target']['dev']] = virt_interface_type

                    if virt_list[domname]['vcpu'] == {} and \
                            virt_list[domname]['disk'] == {} and \
                            virt_list[domname]['interface'] == {}:
                        virt_list[domname] = {}
                        virt_file_exist[domname] = False
                    else:
                        virt_file_exist[domname] = True

            finally:
                kvc.close()

            self.view.virt_list = virt_list
            self.view.virt_file_exist = virt_file_exist

        self.view.group_display = group_display
        dev_list.sort()
        self.view.dev_list = dev_list
        self.view.graph_type = graph_type

        return True
Exemplo n.º 4
0
    def _GET(self, *param, **params):
        host_id = self.chk_hostby1(param)
        if host_id is None: return web.notfound()
        self.view.host_id = host_id

        target = param[1]
        if target is None: return web.notfound()
        self.view.target = target

        group_display = False
        dev_list = []
        graph_type = []
        rrd = RRD()
        if target == "cpu":
            for dev in range(0, len(get_proc_cpuinfo())):
                if rrd.check_rrd_file_exist("cpu", dev):
                    dev_list.append(dev)
            graph_type = ['default']
        elif target == "memory":
            dev_list = ['default']
            graph_type = ['default']
        elif target == "df":
            df_list = get_fs_info()
            for fs in df_list:
                if COLLECTD_DF_RRPORT_BY_DEVICE is True:
                    dev = fs['Filesystem']
                    dev = re.sub(r'^/dev/', '', dev)
                    dev = re.sub(r'/', '_', dev)
                else:
                    dev = fs['Mounted']
                    if dev == "/":
                        dev = "root"
                    else:
                        dev = re.sub(r'^/', '', dev)
                        dev = re.sub(r'/', '_', dev)
                if rrd.check_rrd_file_exist("df", dev):
                    dev_list.append(dev)
            graph_type = ['default']

        elif target == "disk":
            group_display = True
            disk_list = get_hdd_list()
            for disk in disk_list:
                dev = disk
                dev = re.sub(r'^/dev/', '', dev)
                if rrd.check_rrd_file_exist("disk", dev):
                    dev_list.append(dev)
            graph_type = ['merged', 'octets', 'ops', 'time']

        elif target == "interface":
            group_display = True
            if_list = get_ifconfig_info().keys()
            for dev in if_list:
                if rrd.check_rrd_file_exist("interface", dev):
                    dev_list.append(dev)
            graph_type = ['packets', 'octets', 'errors']

        elif target == "load":
            dev_list = ['default']
            graph_type = ['default']
        elif target == "uptime":
            dev_list = ['default']
            graph_type = ['default']
        elif target == "users":
            dev_list = ['default']
            graph_type = ['default']
        elif target == "libvirt":
            virt_cpu_type = ['default']
            virt_disk_type = ['octets', 'ops']
            virt_interface_type = ['packets', 'octets', 'errors', 'dropped']
            virt_list = {}
            virt_file_exist = {}

            try:
                kvc = KaresansuiVirtConnection()

                for domname in get_dom_list():
                    virt_list[domname] = {}

                    if rrd.set_rrd_dir_host(domname) is False:
                        virt_file_exist[domname] = False
                        continue

                    try:
                        virt = kvc.search_kvg_guests(domname)[0]
                    except:
                        virt_file_exist[domname] = False
                        continue

                    virt_list[domname]['vcpu'] = {}
                    if rrd.check_rrd_file_exist("libvirt", "total", "vcpu"):
                        virt_list[domname]['vcpu']['total'] = virt_cpu_type
                    for i in range(virt.get_vcpus_info()['max_vcpus']):
                        if rrd.check_rrd_file_exist("libvirt", i, "vcpu"):
                            virt_list[domname]['vcpu'][i] = virt_cpu_type

                    virt_list[domname]['disk'] = {}
                    for disk in virt.get_disk_info():
                        if rrd.check_rrd_file_exist("libvirt", disk['target']['dev'], "disk"):
                            virt_list[domname]['disk'][disk['target']['dev']] = virt_disk_type

                    virt_list[domname]['interface'] = {}
                    for net_dev in virt.get_interface_info():
                        if rrd.check_rrd_file_exist("libvirt", net_dev['target']['dev'], "interface"):
                            virt_list[domname]['interface'][net_dev['target']['dev']] = virt_interface_type

                    if virt_list[domname]['vcpu'] == {} and \
                            virt_list[domname]['disk'] == {} and \
                            virt_list[domname]['interface'] == {}:
                        virt_list[domname] = {}
                        virt_file_exist[domname] = False
                    else:
                        virt_file_exist[domname] = True

            finally:
                kvc.close()

            self.view.virt_list = virt_list
            self.view.virt_file_exist = virt_file_exist

        self.view.group_display = group_display
        dev_list.sort()
        self.view.dev_list = dev_list
        self.view.graph_type = graph_type

        return True
Exemplo n.º 5
0
def validates_guest_add(obj):
    checker = Checker()
    check = True

    _ = obj._
    checker.errors = []

    if not is_param(obj.input, 'm_name'):
        check = False
        checker.add_error(_('Parameter m_name does not exist.'))
    else:
        check = checker.check_string(
            _('Machine Name'),
            obj.input.m_name,
            CHECK_EMPTY | CHECK_LENGTH | CHECK_ONLYSPACE,
            None,
            min=MACHINE_NAME_MIN_LENGTH,
            max=MACHINE_NAME_MAX_LENGTH,
        ) and check

    if is_param(obj.input, 'note_title'):
        check = checker.check_string(
            _('Title'),
            obj.input.note_title,
            CHECK_LENGTH | CHECK_ONLYSPACE,
            None,
            min=NOTE_TITLE_MIN_LENGTH,
            max=NOTE_TITLE_MAX_LENGTH,
        ) and check

    if is_param(obj.input, 'note_value'):
        check = checker.check_string(
            _('Note'),
            obj.input.note_value,
            CHECK_ONLYSPACE,
            None,
            None,
            None,
        ) and check

    if is_param(obj.input, 'tags'):
        for tag in comma_split(obj.input.tags):
            check = checker.check_string(
                _('Tag'),
                tag,
                CHECK_LENGTH | CHECK_ONLYSPACE,
                None,
                min=TAG_MIN_LENGTH,
                max=TAG_MAX_LENGTH,
            ) and check

    if not is_param(obj.input, 'm_hypervisor'):
        check = False
        checker.add_error(_('Parameter m_hypervisor does not exist.'))
    else:
        check = checker.check_hypervisor(
            _('Hypervisor'),
            obj.input.m_hypervisor,
            CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
            HYPERVISOR_MIN_SIZE,
            HYPERVISOR_MAX_SIZE,
        ) and check

    if not is_param(obj.input, 'domain_name'):
        check = False
        checker.add_error(_('Parameter domain_name does not exist.'))
    else:
        check = checker.check_string(
            _('Domain Name'),
            obj.input.domain_name,
            CHECK_EMPTY | CHECK_VALID | CHECK_LENGTH | CHECK_ONLYSPACE,
            '[^-a-zA-Z0-9_\.]+',
            DOMAIN_NAME_MIN_LENGTH,
            DOMAIN_NAME_MAX_LENGTH,
        ) and check

        if obj.input.domain_name in get_dom_list():
            dom_type = get_dom_type(obj.input.domain_name)
            checker.add_error(
                _("The same domain name already exists for hypervisor '%s'.") %
                dom_type.upper())
            check = False

    if is_param(obj.input, 'vm_mem_size'):
        check = checker.check_number(
            _('Memory Size (MB)'),
            obj.input.vm_mem_size,
            CHECK_VALID | CHECK_MIN | CHECK_EMPTY,
            MEMORY_MIN_SIZE,
            None,
        ) and check

    if is_param(obj.input, 'pool_type'):
        if obj.input.pool_type != "block":
            if is_param(obj.input, 'vm_disk_size'):
                check = checker.check_number(
                    _('Disk Size (MB)'),
                    obj.input.vm_disk_size,
                    CHECK_VALID | CHECK_MIN | CHECK_EMPTY,
                    DISK_MIN_SIZE,
                    None,
                ) and check

    if not is_param(obj.input, 'boot_image'):
        check = False
        checker.add_error(_('Parameter boot_image does not exist.'))
    else:
        if obj.input.boot_image == "kernel":
            if not is_param(obj.input, 'vm_kernel'):
                check = False
                checker.add_error(_('Parameter vm_kernel does not exist.'))
            else:
                check = checker.check_startfile(
                    _('Kernel Image'),
                    obj.input.vm_kernel,
                    CHECK_EMPTY | CHECK_VALID | CHECK_EXIST,
                ) and check

            if not is_param(obj.input, 'vm_initrd'):
                check = False
                checker.add_error(_('Parameter vm_initrd does not exist.'))
            else:
                check = checker.check_startfile(
                    _('Initrd Image'),
                    obj.input.vm_initrd,
                    CHECK_EMPTY | CHECK_VALID | CHECK_EXIST,
                ) and check

        if obj.input.boot_image == "iso":
            if not is_param(obj.input, 'vm_iso'):
                check = False
                checker.add_error(_('Parameter vm_iso does not exist.'))
            else:
                check = checker.check_startfile(
                    _('ISO Image'),
                    obj.input.vm_iso,
                    CHECK_EMPTY | CHECK_VALID | CHECK_EXIST,
                ) and check
                if check:
                    check = is_iso9660_filesystem_format(obj.input.vm_iso)
                    checker.add_error(
                        _('"%s" is not valid ISO 9660 CD-ROM filesystem data.')
                        % obj.input.vm_iso)

    if not is_param(obj.input, 'keymap'):
        check = False
        checker.add_error(_('"%s" is required.') % _('Graphics Keymap'))
    else:
        hypervisor = "KVM"
        if int(obj.input.m_hypervisor) == MACHINE_HYPERVISOR['XEN']:
            hypervisor = "XEN"
        elif int(obj.input.m_hypervisor) == MACHINE_HYPERVISOR['KVM']:
            hypervisor = "KVM"
        check = checker.check_keymap(_('Graphics Keymap'), obj.input.keymap,
                                     CHECK_EMPTY | CHECK_EXIST,
                                     hypervisor) and check

    if not is_param(obj.input, 'vm_graphics_port'):
        check = False
        checker.add_error(_('Parameter vm_graphics_port does not exist.'))
    else:
        check = checker.check_number(
            _('Graphics Port Number'),
            obj.input.vm_graphics_port,
            CHECK_EMPTY | CHECK_VALID | CHECK_MIN | CHECK_MAX,
            GRAPHICS_PORT_MIN_NUMBER,
            GRAPHICS_PORT_MAX_NUMBER,
        ) and check

    if not is_param(obj.input, 'vm_mac'):
        check = False
        checker.add_error(_('Parameter vm_mac does not exist.'))
    else:
        check = checker.check_macaddr(
            _('MAC Address'),
            obj.input.vm_mac,
            CHECK_EMPTY | CHECK_VALID,
        ) and check

    obj.view.alert = checker.errors
    return check
Exemplo n.º 6
0
    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