예제 #1
0
    def download_profile(self, args):
        """ Run just one RTC """
        self.parser.add_option(
            '-w',
            '--wakeuptimeout',
            help=
            'Timeout of Sleep Function when waiting for the wakeup of RTC-Daemons',
            default=5,
            dest='wakeuptimeout',
            action='store',
            type='float')
        options, argv = self.parse_args(args[:], self._print_rtcs)
        verbose = options.verbose_flag
        wakeuptimeout = options.wakeuptimeout

        package = admin.package.get_package_from_path(os.getcwd())
        rtc = admin.rtc.get_rtc_from_package(package, argv[3], verbose=verbose)
        if self.run_rtc_in_package(
                package, rtc, verbose=verbose, background=True) != 0:
            return -1
        wasanbon.sleep(wakeuptimeout)
        rtcp = admin.rtcprofile.create_rtcprofile(rtc, verbose=verbose)
        print admin.rtcprofile.tostring(rtcp)
        self.terminate_rtcd(package, verbose=verbose)
        return 0
예제 #2
0
    def update_profile(self, args):
        """ Run just one RTC and compare the profile between the existing RTC.xml and launched RTC, then save RTC.xml """
        self.parser.add_option('-f', '--file', help='RTCProfile filename (default="RTC.xml")', default='RTC.xml', dest='filename', action='store', type='string')
        self.parser.add_option('-d', '--dryrun', help='Just output on console', default=False, dest='dry_flag', action='store_true')
        self.parser.add_option('-w', '--wakeuptimeout', help='Timeout of Sleep Function when waiting for the wakeup of RTC-Daemons', default=5, dest='wakeuptimeout', action='store', type='float')
        options, argv = self.parse_args(args[:], self._print_rtcs)
        verbose = options.verbose_flag
        dry = options.dry_flag
        filename = options.filename
        wakeuptimeout = options.wakeuptimeout

        wasanbon.arg_check(argv, 4)
        rtc_name = argv[3]

        package = admin.package.get_package_from_path(os.getcwd())
        sys.stdout.write('# Starting RTC.\n')
        rtc = admin.rtc.get_rtc_from_package(package, rtc_name, verbose=verbose)
        standalone = admin.systeminstaller.is_installed(package, rtc, standalone=True, verbose=verbose)
        if standalone:
            admin.systemlauncher.launch_standalone_rtc(package, rtc, stdout=True, verbose=verbose)
            pass
        else:
            if self.run_rtc_in_package(package, rtc, verbose=verbose, background=True) != 0:
                return -1
        wasanbon.sleep(wakeuptimeout)
        sys.stdout.write('# Acquiring RTCProfile from Inactive RTC\n')
        rtcp = admin.rtcprofile.create_rtcprofile(rtc, verbose=verbose)

        if standalone:

            pass
        else:
            self.terminate_rtcd(package, verbose=verbose)
        sys.stdout.write('# Comparing Acquired RTCProfile and Existing RTCProfile.\n')
        retval = admin.rtcprofile.compare_rtcprofile(rtc.rtcprofile, rtcp, verbose=verbose)
        if retval:
            filepath = os.path.join(rtc.path, filename)

            if not dry:
                outstr = admin.rtcprofile.tostring(retval, pretty_print=True)
                if outstr == None:
                    sys.stdout.write('# RTC Profile save failed.\n')
                    return -1
                if os.path.isfile(filepath):
                    f = filepath + wasanbon.timestampstr()
                    os.rename(filepath, f)
                    pass

                fout = open(filepath, 'w')
                fout.write(outstr)
                fout.close()
            else:
                sys.stdout.write(admin.rtcprofile.tostring(retval, pretty_print=True))

            sys.stdout.write('Succeed.\n')
            
            return 0
        sys.stdout.write('Succeed.\n')
        return 0
예제 #3
0
    def download_profile(self, args):
        """ Run just one RTC """
        self.parser.add_option('-w', '--wakeuptimeout', help='Timeout of Sleep Function when waiting for the wakeup of RTC-Daemons', default=5, dest='wakeuptimeout', action='store', type='float')
        options, argv = self.parse_args(args[:], self._print_rtcs)
        verbose = options.verbose_flag
        wakeuptimeout = options.wakeuptimeout

        package = admin.package.get_package_from_path(os.getcwd())
        rtc = admin.rtc.get_rtc_from_package(package, argv[3], verbose=verbose)
        if self.run_rtc_in_package(package, rtc, verbose=verbose, background=True) != 0:
            return -1
        wasanbon.sleep(wakeuptimeout)        
        rtcp = admin.rtcprofile.create_rtcprofile(rtc, verbose=verbose)
        print admin.rtcprofile.tostring(rtcp)
        self.terminate_rtcd(package, verbose=verbose)
        return 0
예제 #4
0
    def verify_profile(self, args):
        """ Run just one RTC """
        self.parser.add_option('-w', '--wakeuptimeout', help='Timeout of Sleep Function when waiting for the wakeup of RTC-Daemons', default=5, dest='wakeuptimeout', action='store', type='float')
        options, argv = self.parse_args(args[:], self._print_rtcs)
        verbose = options.verbose_flag
        wakeuptimeout = options.wakeuptimeout

        package = admin.package.get_package_from_path(os.getcwd())
        sys.stdout.write('# Starting RTC.\n')
        rtc = admin.rtc.get_rtc_from_package(package, argv[3], verbose=verbose)
        if self.run_rtc_in_package(package, rtc, verbose=verbose, background=True) != 0:
            return -1
        wasanbon.sleep(wakeuptimeout)
        sys.stdout.write('# Acquiring RTCProfile from Inactive RTC\n')
        rtcp = admin.rtcprofile.create_rtcprofile(rtc, verbose=verbose)
        self.terminate_rtcd(package, verbose=verbose)
        sys.stdout.write('# Comparing Acquired RTCProfile and Existing RTCProfile.\n')
        retval = admin.rtcprofile.compare_rtcprofile(rtc.rtcprofile, rtcp, verbose=verbose)
        if retval:
            sys.stdout.write('Failed.\n# RTCProfile must be updated.\n')
            return -1
        sys.stdout.write('Succeeded.\n# RTCProfile is currently matches to binary.\n')
        return 0
예제 #5
0
    def verify_profile(self, args):
        """ Run just one RTC """
        self.parser.add_option(
            '-w',
            '--wakeuptimeout',
            help=
            'Timeout of Sleep Function when waiting for the wakeup of RTC-Daemons',
            default=5,
            dest='wakeuptimeout',
            action='store',
            type='float')
        options, argv = self.parse_args(args[:], self._print_rtcs)
        verbose = options.verbose_flag
        wakeuptimeout = options.wakeuptimeout

        package = admin.package.get_package_from_path(os.getcwd())
        sys.stdout.write('# Starting RTC.\n')
        rtc = admin.rtc.get_rtc_from_package(package, argv[3], verbose=verbose)
        if self.run_rtc_in_package(
                package, rtc, verbose=verbose, background=True) != 0:
            return -1
        wasanbon.sleep(wakeuptimeout)
        sys.stdout.write('# Acquiring RTCProfile from Inactive RTC\n')
        rtcp = admin.rtcprofile.create_rtcprofile(rtc, verbose=verbose)
        self.terminate_rtcd(package, verbose=verbose)
        sys.stdout.write(
            '# Comparing Acquired RTCProfile and Existing RTCProfile.\n')
        retval = admin.rtcprofile.compare_rtcprofile(rtc.rtcprofile,
                                                     rtcp,
                                                     verbose=verbose)
        if retval:
            sys.stdout.write('Failed.\n# RTCProfile must be updated.\n')
            return -1
        sys.stdout.write(
            'Succeeded.\n# RTCProfile is currently matches to binary.\n')
        return 0
예제 #6
0
    def run(self, args):
        """ Launch System 
        $ mgr.py system run """
        #self.parser.add_option('-f', '--force', help='Force option (default=True)', default=True, action='store_true', dest='force_flag')
        #self.parser.add_option('-s', '--standalone', help='Install Standalone RTC(default=False)', default=False, action='store_true', dest='standalone_flag')
        self.parser.add_option('-b', '--background', help='Launch in background(default=False)', default=False, action='store_true', dest='background_flag')
        self.parser.add_option('-w', '--wakeuptimeout', help='Timeout of Sleep Function when waiting for the wakeup of RTC-Daemons', default=5, dest='wakeuptimeout', action='store', type='float')
        self.parser.add_option('-f', '--file', help='Build System with Specific RTSProfile (must be placed in system_dir', default=None, dest='systemfile', action='store', type='string')
        self.parser.add_option('-p', '--plain', help='Plain Launch. Without building/activating system.', default=False, dest='plain_flag', action='store_true')
        self.parser.add_option('-q', '--quiet', help='Build system but do not activate RTCs.', default=False, dest='quiet_flag', action='store_true')
        options, argv = self.parse_args(args[:])
        verbose = options.verbose_flag
        background = options.background_flag
        wakeuptimeout = options.wakeuptimeout
        systemfile = options.systemfile
        plain = options.plain_flag
        quiet = options.quiet_flag

        if plain:
            quiet = True
            
        #force  = options.force_flag
        #standalone = options.standalone_flag
            
        package = admin.package.get_package_from_path(os.getcwd(), verbose=verbose)

        if systemfile:
            systemfile = os.path.join(package.get_systempath(), systemfile)

        started_nss = []
        nss = admin.nameserver.get_nameservers_from_package(package, verbose=verbose)
        for ns in nss:
            if not admin.nameserver.is_running(ns, verbose=verbose, try_count=5, interval=5.0):
                sys.stdout.write('## Nameserver %s is not running.\n' % ns.path)
                if ns.address == 'localhost' or ns.address == '127.0.0.1':
                    if verbose: '# Start Nameserver %s\n' % ns.path
                    admin.nameserver.launch(ns, verbose=verbose)
                    started_nss.append(ns)
                    wasanbon.sleep(5.0)

        global endflag
        endflag = False
        try:
            processes = admin.systemlauncher.launch_system(package, verbose=verbose)
            wasanbon.sleep(wakeuptimeout)
            if not plain:

                admin.systembuilder.build_system(package, 
                                                 verbose=verbose, 
                                                 system_file=systemfile)

                if not quiet:
                    admin.systembuilder.activate_system(package, 
                                                        verbose=verbose,
                                                        system_file=systemfile)

            if background:
                return 0

            def signal_action(num, frame):
                print ' - SIGINT captured'
                ev.set()
                global endflag
                endflag = True
                pass

            signal.signal(signal.SIGINT, signal_action)
            if sys.platform == 'win32':
                sys.stdout.write(' - Escaping SIGBREAK...\n')
                signal.signal(signal.SIGBREAK, signal_action)
                pass

            endflag = False
            while not endflag:
                try:
                    time.sleep(0.1)
                    languages = ['Java', 'Python', 'C++']
                    stopped = []
                    for l in languages:
                        stopped.append(not admin.systemlauncher.is_rtcd_launched(package, l, verbose=verbose))
                    stopped.append(not admin.systemlauncher.is_standalone_rtcs_launched(package, verbose=verbose))
                    if all(stopped):
                        endflag = True
                except IOError, e:
                    print e
                    pass
                pass

            if not plain:
                admin.systembuilder.deactivate_system(package, 
                                                      verbose=verbose, 
                                                      system_file=systemfile)
예제 #7
0
    def update_profile(self, args):
        """ Run just one RTC and compare the profile between the existing RTC.xml and launched RTC, then save RTC.xml """
        self.parser.add_option('-f',
                               '--file',
                               help='RTCProfile filename (default="RTC.xml")',
                               default='RTC.xml',
                               dest='filename',
                               action='store',
                               type='string')
        self.parser.add_option('-d',
                               '--dryrun',
                               help='Just output on console',
                               default=False,
                               dest='dry_flag',
                               action='store_true')
        self.parser.add_option(
            '-w',
            '--wakeuptimeout',
            help=
            'Timeout of Sleep Function when waiting for the wakeup of RTC-Daemons',
            default=5,
            dest='wakeuptimeout',
            action='store',
            type='float')
        options, argv = self.parse_args(args[:], self._print_rtcs)
        verbose = options.verbose_flag
        dry = options.dry_flag
        filename = options.filename
        wakeuptimeout = options.wakeuptimeout

        wasanbon.arg_check(argv, 4)
        rtc_name = argv[3]

        package = admin.package.get_package_from_path(os.getcwd())
        sys.stdout.write('# Starting RTC.\n')
        rtc = admin.rtc.get_rtc_from_package(package,
                                             rtc_name,
                                             verbose=verbose)
        standalone = admin.systeminstaller.is_installed(package,
                                                        rtc,
                                                        standalone=True,
                                                        verbose=verbose)
        if standalone:
            admin.systemlauncher.launch_standalone_rtc(package,
                                                       rtc,
                                                       stdout=True,
                                                       verbose=verbose)
            pass
        else:
            if self.run_rtc_in_package(
                    package, rtc, verbose=verbose, background=True) != 0:
                return -1
        wasanbon.sleep(wakeuptimeout)
        sys.stdout.write('# Acquiring RTCProfile from Inactive RTC\n')
        rtcp = admin.rtcprofile.create_rtcprofile(rtc, verbose=verbose)

        if standalone:

            pass
        else:
            self.terminate_rtcd(package, verbose=verbose)
        sys.stdout.write(
            '# Comparing Acquired RTCProfile and Existing RTCProfile.\n')
        retval = admin.rtcprofile.compare_rtcprofile(rtc.rtcprofile,
                                                     rtcp,
                                                     verbose=verbose)
        if retval:
            filepath = os.path.join(rtc.path, filename)

            if not dry:
                outstr = admin.rtcprofile.tostring(retval, pretty_print=True)
                if outstr == None:
                    sys.stdout.write('# RTC Profile save failed.\n')
                    return -1
                if os.path.isfile(filepath):
                    f = filepath + wasanbon.timestampstr()
                    os.rename(filepath, f)
                    pass

                fout = open(filepath, 'w')
                fout.write(outstr)
                fout.close()
            else:
                sys.stdout.write(
                    admin.rtcprofile.tostring(retval, pretty_print=True))

            sys.stdout.write('Succeed.\n')

            return 0
        sys.stdout.write('Succeed.\n')
        return 0
예제 #8
0
    def run(self, args):
        """ Launch System 
        $ mgr.py system run """
        #self.parser.add_option('-f', '--force', help='Force option (default=True)', default=True, action='store_true', dest='force_flag')
        #self.parser.add_option('-s', '--standalone', help='Install Standalone RTC(default=False)', default=False, action='store_true', dest='standalone_flag')
        self.parser.add_option('-b',
                               '--background',
                               help='Launch in background(default=False)',
                               default=False,
                               action='store_true',
                               dest='background_flag')
        self.parser.add_option(
            '-w',
            '--wakeuptimeout',
            help=
            'Timeout of Sleep Function when waiting for the wakeup of RTC-Daemons',
            default=5,
            dest='wakeuptimeout',
            action='store',
            type='float')
        self.parser.add_option(
            '-f',
            '--file',
            help=
            'Build System with Specific RTSProfile (must be placed in system_dir',
            default=None,
            dest='systemfile',
            action='store',
            type='string')
        self.parser.add_option(
            '-p',
            '--plain',
            help='Plain Launch. Without building/activating system.',
            default=False,
            dest='plain_flag',
            action='store_true')
        self.parser.add_option('-q',
                               '--quiet',
                               help='Build system but do not activate RTCs.',
                               default=False,
                               dest='quiet_flag',
                               action='store_true')
        options, argv = self.parse_args(args[:])
        verbose = options.verbose_flag
        background = options.background_flag
        wakeuptimeout = options.wakeuptimeout
        systemfile = options.systemfile
        plain = options.plain_flag
        quiet = options.quiet_flag

        if plain:
            quiet = True

        #force  = options.force_flag
        #standalone = options.standalone_flag

        package = admin.package.get_package_from_path(os.getcwd(),
                                                      verbose=verbose)

        if systemfile:
            systemfile = os.path.join(package.get_systempath(), systemfile)

        started_nss = []
        nss = admin.nameserver.get_nameservers_from_package(package,
                                                            verbose=verbose)
        for ns in nss:
            if not admin.nameserver.is_running(
                    ns, verbose=verbose, try_count=5, interval=5.0):
                sys.stdout.write('## Nameserver %s is not running.\n' %
                                 ns.path)
                if ns.address == 'localhost' or ns.address == '127.0.0.1':
                    if verbose: '# Start Nameserver %s\n' % ns.path
                    admin.nameserver.launch(ns, verbose=verbose)
                    started_nss.append(ns)
                    wasanbon.sleep(5.0)

        global endflag
        endflag = False
        try:
            processes = admin.systemlauncher.launch_system(package,
                                                           verbose=verbose)
            wasanbon.sleep(wakeuptimeout)
            if not plain:

                admin.systembuilder.build_system(package,
                                                 verbose=verbose,
                                                 system_file=systemfile)

                if not quiet:
                    admin.systembuilder.activate_system(package,
                                                        verbose=verbose,
                                                        system_file=systemfile)

            if background:
                return 0

            def signal_action(num, frame):
                print ' - SIGINT captured'
                ev.set()
                global endflag
                endflag = True
                pass

            signal.signal(signal.SIGINT, signal_action)
            if sys.platform == 'win32':
                sys.stdout.write(' - Escaping SIGBREAK...\n')
                signal.signal(signal.SIGBREAK, signal_action)
                pass

            endflag = False
            while not endflag:
                try:
                    time.sleep(0.1)
                    languages = ['Java', 'Python', 'C++']
                    stopped = []
                    for l in languages:
                        stopped.append(
                            not admin.systemlauncher.is_rtcd_launched(
                                package, l, verbose=verbose))
                    stopped.append(
                        not admin.systemlauncher.is_standalone_rtcs_launched(
                            package, verbose=verbose))
                    if all(stopped):
                        endflag = True
                except IOError, e:
                    print e
                    pass
                pass

            if not plain:
                admin.systembuilder.deactivate_system(package,
                                                      verbose=verbose,
                                                      system_file=systemfile)