예제 #1
0
    def __hack_maven_settings(fs: FileUtils = FileUtils()):
        # attempt to locate maven by running atlas-version
        oneliner = OneLiner(None, 'atlas-version | grep "ATLAS Maven"')
        oneliner(LOG)
        if oneliner.returncode != Callable.success:
            return None
        maven_home = oneliner.line[oneliner.line.find(':') + 2:]

        target_dir = fs.existing_dir(os.sep.join(['.', 'jmake_src', 'target']))
        if not fs.file_exists(os.sep.join([target_dir, 'Decipher.class'])):
            oneliner = OneLiner(
                None,
                '$JAVA_HOME/bin/javac -cp %s:. -d %s Decipher.java' %
                (os.sep.join([maven_home, 'lib', '*']), target_dir),
                cwd=os.sep.join(['.', 'jmake_src', 'jbac', 'java']))
            oneliner(LOG)

        oneliner = OneLiner(
            None, '$JAVA_HOME/bin/java -cp %s:%s Decipher' %
            (os.sep.join([maven_home, 'lib', '*']), target_dir))
        oneliner(LOG)
        if oneliner.returncode != Callable.success:
            return None
        credentials = oneliner.line.split(':')
        return JbacAuthentication(credentials[0], credentials[1])
예제 #2
0
class MockLayout:
    def __init__(self, ondemand: bool):
        self.temp_dir = tempfile.mkdtemp()
        self.utils = FileUtils()
        self.ondemand = ondemand

    def tomcat_conf_src(self):
        return self.utils.existing_dir(os.path.join(self.temp_dir, 'src'))

    def tomcat_conf_dest(self):
        return self.utils.existing_dir(os.path.join(self.temp_dir, 'dest'))

    def jira_webapp_dir(self):
        return os.path.join(self.temp_dir, 'jira_webapp_dir')

    def tomcat_work_dir(self):
        return os.path.join(self.temp_dir, 'tomcat_work_dir')

    def tomcat_temp_dir(self):
        return os.path.join(self.temp_dir, 'tomcat_temp_dir')

    def tomcat_dir(self, create):
        return os.path.join(self.temp_dir, 'tomcat_dir')

    def jira_home(self):
        return os.path.join(self.temp_dir, 'jira_home')

    def studio_ititial_data(self):
        return os.path.join(self.temp_dir, 'jira_home', 'some-data.xml')

    def tomcat_executable(self):
        return os.path.join(self.tomcat_dir(False), 'some-runnable.sh')

    def tomcat_download_dir(self):
        return os.path.join(self.temp_dir, 'jira_home')

    def remove(self):
        shutil.rmtree(self.temp_dir)

    def studio_initial_data(self):
        return os.path.join(self.temp_dir, 'jira_home',
                            'some-initial-data.xml')

    def webdav_dir(self):
        return os.path.join(self.temp_dir, 'jira_home', 'webdav')
예제 #3
0
class MockLayout:
    def __init__(self, ondemand: bool):
        self.temp_dir = tempfile.mkdtemp()
        self.utils = FileUtils()
        self.ondemand = ondemand

    def tomcat_conf_src(self):
        return self.utils.existing_dir(os.path.join(self.temp_dir, 'src'))

    def tomcat_conf_dest(self):
        return self.utils.existing_dir(os.path.join(self.temp_dir, 'dest'))

    def jira_webapp_dir(self):
        return os.path.join(self.temp_dir, 'jira_webapp_dir')

    def tomcat_work_dir(self):
        return os.path.join(self.temp_dir, 'tomcat_work_dir')

    def tomcat_temp_dir(self):
        return os.path.join(self.temp_dir, 'tomcat_temp_dir')

    def tomcat_dir(self, create):
        return os.path.join(self.temp_dir, 'tomcat_dir')

    def jira_home(self):
        return os.path.join(self.temp_dir, 'jira_home')

    def studio_ititial_data(self):
        return os.path.join(self.temp_dir, 'jira_home', 'some-data.xml')

    def tomcat_executable(self):
        return os.path.join(self.tomcat_dir(False), 'some-runnable.sh')

    def tomcat_download_dir(self):
        return os.path.join(self.temp_dir, 'jira_home')

    def remove(self):
        shutil.rmtree(self.temp_dir)

    def studio_initial_data(self):
        return os.path.join(self.temp_dir, 'jira_home', 'some-initial-data.xml')

    def webdav_dir(self):
        return os.path.join(self.temp_dir, 'jira_home', 'webdav')
예제 #4
0
    def __hack_maven_settings(fs: FileUtils=FileUtils()):
        # attempt to locate maven by running atlas-version
        oneliner = OneLiner(None, 'atlas-version | grep "ATLAS Maven"')
        oneliner(LOG)
        if oneliner.returncode != Callable.success:
            return None
        maven_home = oneliner.line[oneliner.line.find(':') + 2:]

        target_dir = fs.existing_dir(os.sep.join(['.', 'jmake_src', 'target']))
        if not fs.file_exists(os.sep.join([target_dir, 'Decipher.class'])):
            oneliner = OneLiner(None, '$JAVA_HOME/bin/javac -cp %s:. -d %s Decipher.java'
                        % (os.sep.join([maven_home, 'lib', '*']),
                           target_dir), cwd=os.sep.join(['.', 'jmake_src', 'jbac', 'java']))
            oneliner(LOG)

        oneliner = OneLiner(None, '$JAVA_HOME/bin/java -cp %s:%s Decipher'
                            % (os.sep.join([maven_home, 'lib', '*']), target_dir))
        oneliner(LOG)
        if oneliner.returncode != Callable.success:
            return None
        credentials = oneliner.line.split(':')
        return JbacAuthentication(credentials[0], credentials[1])
예제 #5
0
        def clustered_info(_, fs: FileUtils=FileUtils()):
            files = fs.listdir(fs.existing_dir(ClusterContext.CLUSTERED_INFO_DIR))
            clusters = {}

            for file in files:
                if file.startswith('instance-'):

                    with open(os.sep.join([ClusterContext.CLUSTERED_INFO_DIR, file]), 'r') as f:
                        status = JSONDecoder().decode(f.read())

                    key = (status['cluster-name'], status['cluster-hash'])

                    if not key in clusters:
                        clusters[key] = [status]
                    else:
                        clusters[key].append(status)

            if clusters:

                checker = AllPortsChecker()
                checker(Logger().set_none())

                red_ports =  []

                def portprint(port):
                    try:
                        p = int(port)
                        if p in checker.get_open_ports():
                            return Logger.color_text(port, Logger.L_ONLINE)
                        else:
                            red_ports.append(p)
                            return Logger.color_text(port, Logger.L_OFFLINE)
                    except Exception as _:
                        return port

                def homeprint(home:str):
                    return home.replace(fs.abs_path('.'), '.')

                def serverstatus(url:str):
                    try:
                        response = urlopen(Request(url + '/status', headers = {
                            'Accept': 'application/json'
                        }))
                        jsonResponse = json.loads(response.read().decode())
                        return jsonResponse['state']
                    except Exception as _:
                        return 'NOT RUNNING'


                for cluster_info in sorted(clusters.keys(), key=lambda tpl: tpl[0]):
                    cluster_name, cluster_hash = cluster_info
                    print('Cluster %s "%s" (%d instances):' % (cluster_hash, cluster_name, len(clusters[cluster_info])))

                    for instance in sorted(clusters[cluster_info], key=lambda instance: instance['start-time']):
                        print(' -> %s %s ' % (instance['instance-hash'], instance['url']))
                        print('     http: %s ctrl: %s debug: %s mcast: %s peer: %s' %
                              (portprint(instance['http-port']), portprint(instance['shutdown-port']), portprint(instance['debug-port'] if 'debug-port' in instance else 'n/a'),
                               instance['cluster-multicast-port'], portprint(instance['cluster-peer-cache-port'])))
                        print('     home: %s shared: %s' % (homeprint(instance['jira-home']), homeprint(instance['shared-home'])))
                        print('     shutdown: ./jmake run shutdown --instance-name %s' % instance['instance-hash'])
                        print('     status %s' % (serverstatus(instance['url'])))

                    print('')

                if red_ports:
                    print('Wait until all ports are %s before running more instances to avoid port clashes.' % Logger.color_text('green', Logger.L_ONLINE))
                else:
                    print('You can now run more instances with %s' % Logger.color_text('./jmake clustered run', Logger.L_INFO))

            else:
                print('There are no clustered instances running. Run some with %s' % Logger.color_text('./jmake clustered run', Logger.L_INFO))

            return Callable.success