Beispiel #1
0
    def tree(self, argv):
        self.parser.add_option('-p', '--port', help='Set TCP Port number for web server', type='int', default=2809, dest='port')
        self.parser.add_option('-l', '--long', help='long format', default=False, action="store_true", dest='long_flag')
        self.parser.add_option('-d', '--detail', help='detail format', default=False, action="store_true", dest='detail_flag')
        self.parser.add_option('-u', '--url', help='Host Address', default='localhost', action="store", dest='url')
        options, argv = self.parse_args(argv[:])
        verbose = options.verbose_flag # This is default option
        long = options.long_flag
        detail = options.detail_flag
        port = options.port
        url = options.url
        nss = []
        def func(args):
            ns = NameServer(url + ':%s' % port, pidFilePath='.')
            if not self.check_global_running():
                sys.stdout.write('## Nameserver is not running.\n')
                sys.stdout.write('\n')
                return 0
            
            ns.yaml_dump(long=long, detail=detail)
            nss.append(ns)

        from wasanbon.util import task
        interval = 10
        task.task_with_wdt(func, [], interval)
        if len(nss) == 0:
            sys.stdout.write('Timeout\n')
            return -1

        return 0
Beispiel #2
0
    def is_running(self, ns, verbose=False, try_count=3, interval=5.0):
        """ Check NameServer (specified by NameServer class object) is running or not.
        :param NameServer ns: NameServer class object.
        :param bool verbose: Verbosity.
        :param int try_count: Retry in this count if connecting nameserver failed.
        :param float interval: Interval between retry.
        :rtype bool:
        :return: True if success
        """
        for i in range(0, try_count):
            if verbose: sys.stdout.write('## Checking Nameservice(%s) is running\n' % ns.path)
            from rtctree import path as rtctree_path
            import rtctree, omniORB
            try:
                if not ns.tree:
                    if verbose: sys.stdout.write('### Parsing path....\n')

                    path, port = rtctree_path.parse_path('/' + ns.path)
                    if verbose: sys.stdout.write('### Initializing rtctree...\n')


                    ns.tree = None
                    from wasanbon.util import task
                    from rtctree import tree as rtctree_tree
                    def task_func(args):
                        try:
                            if verbose: sys.stdout.write('#### Checking RTCTree.....\n')
                            ns.tree = rtctree_tree.RTCTree(paths=path, filter=[path])
                            if verbose: sys.stdout.write('#### Done.\n')
                        except:
                            if verbose: sys.stdout.write('#### Exception.\n')
                            pass

                    args = None
                    task.task_with_wdt(task_func, args, interval)
                    if not ns.tree:
                        if verbose: sys.stdout.write('### RTCTree Failed.\n')
                        continue
                    else:
                        if verbose: sys.stdout.write('### RTCTree Success.\n')

                if verbose: sys.stdout.write('### Getting Node...\n')
                self. dir_node = ns.tree.get_node(path)
                if verbose: sys.stdout.write('### Success.\n')
                if verbose: sys.stdout.write('### Nameservice(%s) is found.\n' % ns.path)
                return True
            except rtctree.exceptions.InvalidServiceError, e:
                continue
            except omniORB.CORBA.OBJECT_NOT_EXIST, e:
                continue
Beispiel #3
0
    def configure(self, argv):
        self.parser.add_option('-s', '--set', help='Configuration Set Name (default=default)', type='string', default='default', dest='set_name')
        options, argv = self.parse_args(argv[:])
        verbose = options.verbose_flag # This is default option
        wasanbon.arg_check(argv, 6)
        set_name = options.set_name
        rtc_full_path = argv[3]
        conf_name = argv[4]
        conf_value = argv[5]
        found_conf = False
        def func(comp):
            for cs in comp.conf_sets:
                if cs == set_name:
                    cset = comp.conf_sets[set_name]
                    for key, value in cset.data.items():
                        if key == conf_name:
                            comp.set_conf_set_value(set_name, conf_name, conf_value)
                            found_conf = True
        
        comps = []
        def taskfunc(args):
            try:
                comp = self.component(rtc_full_path, func, verbose=verbose)
            except:
                sys.stdout.write('Failed. Exception occured.\n');
                traceback.print_exc()
                return

            if found_conf:
                sys.stdout.write('Success.\n')
            else:
                sys.stdout.write('Failed.\n');

            comps.append(comp)

        from wasanbon.util import task
        interval = 10
        task.task_with_wdt(taskfunc, [], interval)
        if len(comps) == 0:
            sys.stdout.write('Timeout\n')
            return -1

        return 0