示例#1
0
    def install_java(self):
        """
        Run the java-installer resource to install Java and determine
        the JAVA_HOME and Java version.

        The java-installer must be idempotent and its only output (on stdout)
        should be two lines: the JAVA_HOME path, and the Java version, respectively.

        If there is an error installing Java, the installer should exit
        with a non-zero exit code.
        """
        env = utils.read_etc_env()
        java_installer = Path(jujuresources.resource_path('java-installer'))
        java_installer.chmod(0o755)
        output = check_output([java_installer], env=env).decode('utf8')
        lines = output.strip().splitlines()
        if len(lines) != 2:
            raise ValueError('Unexpected output from java-installer: %s' %
                             output)
        java_home, java_version = lines
        if '_' in java_version:
            java_major, java_release = java_version.split("_")
        else:
            java_major, java_release = java_version, ''
        unitdata.kv().set('java.home', java_home)
        unitdata.kv().set('java.version', java_major)
        unitdata.kv().set('java.version.release', java_release)
示例#2
0
    def install(self, force=False):
        jujuresources.install(self.resources['oozie'],
                              destination=self.dist_config.path('oozie'),
                              skip_top_level=True)
        self.dist_config.add_users()
        self.dist_config.add_dirs()
        self.dist_config.add_packages()

        # ExtJS v2.2 should go under self.dist_config.path('ext22')
        jujuresources.fetch('ext22')
        src = jujuresources.resource_path('ext22')
        dest = self.dist_config.path('ext22')
        shutil.copy(src, dest)

        # self.dist_config.path('ext22') should also contain all files under
        # self.dist_config.path('oozie') / 'libtools'
        src = self.dist_config.path('oozie') / 'libtools'
        src_files = os.listdir(src)
        for file_name in src_files:
            full_file_name = os.path.join(src, file_name)
            if (os.path.isfile(full_file_name)):
                shutil.copy(full_file_name, dest)

        self.setup_oozie_config()
        self.configure_oozie_hdfs()
        self.set_oozie_env()
        self.build_oozie_sharelib()
        self.build_oozie_war_file()
        self.build_oozie_db()
示例#3
0
def install_java():
    """Install java just like we do for Hadoop Base.

    This is the same method used to install java in HadoopBase:
    https://github.com/juju-solutions/jujubigdata/blob/master/jujubigdata/handlers.py#L134

    This allows us to run Pig in local mode (which requires Java) without
    any Hadoop. If Hadoop comes along later, we'll already have java installed
    in a way that is compatible with the plugin.

    NOTE: this will go away if/when we support the java interface.
    """
    env = utils.read_etc_env()
    java_installer = Path(jujuresources.resource_path('java-installer'))
    java_installer.chmod(0o755)
    output = check_output([java_installer], env=env).decode('utf8')
    lines = output.strip().splitlines()
    if len(lines) != 2:
        raise ValueError('Unexpected output from java-installer: %s' % output)
    java_home, java_version = lines
    if '_' in java_version:
        java_major, java_release = java_version.split("_")
    else:
        java_major, java_release = java_version, ''
    unitdata.kv().set('java.home', java_home)
    unitdata.kv().set('java.version', java_major)
    unitdata.kv().set('java.version.release', java_release)
示例#4
0
    def install_java(self):
        """
        Run the java-installer resource to install Java and determine
        the JAVA_HOME and Java version.

        The java-installer must be idempotent and its only output (on stdout)
        should be two lines: the JAVA_HOME path, and the Java version, respectively.

        If there is an error installing Java, the installer should exit
        with a non-zero exit code.
        """
        env = utils.read_etc_env()
        java_installer = Path(jujuresources.resource_path('java-installer'))
        java_installer.chmod(0o755)
        output = check_output([java_installer], env=env).decode('utf8')
        lines = output.strip().splitlines()
        if len(lines) != 2:
            raise ValueError('Unexpected output from java-installer: %s' % output)
        java_home, java_version = lines
        if '_' in java_version:
            java_major, java_release = java_version.split("_")
        else:
            java_major, java_release = java_version, ''
        unitdata.kv().set('java.home', java_home)
        unitdata.kv().set('java.version', java_major)
        unitdata.kv().set('java.version.release', java_release)
示例#5
0
def install_java():
    """Install java just like we do for Hadoop Base.

    This is the same method used to install java in HadoopBase:
    https://github.com/juju-solutions/jujubigdata/blob/master/jujubigdata/handlers.py#L134

    This allows us to run Pig in local mode (which requires Java) without
    any Hadoop. If Hadoop comes along later, we'll already have java installed
    in a way that is compatible with the plugin.

    NOTE: this will go away if/when we support the java interface.
    """
    env = utils.read_etc_env()
    java_installer = Path(jujuresources.resource_path('java-installer'))
    java_installer.chmod(0o755)
    output = check_output([java_installer], env=env).decode('utf8')
    lines = output.strip().splitlines()
    if len(lines) != 2:
        raise ValueError('Unexpected output from java-installer: %s' % output)
    java_home, java_version = lines
    if '_' in java_version:
        java_major, java_release = java_version.split("_")
    else:
        java_major, java_release = java_version, ''
    unitdata.kv().set('java.home', java_home)
    unitdata.kv().set('java.version', java_major)
    unitdata.kv().set('java.version.release', java_release)
示例#6
0
    def __init__(self, dist_config):
        self.dist_config = dist_config
        self.charm_config = hookenv.config()
        self.cpu_arch = host.cpu_arch()
        self.client_spec = {
            'hadoop': self.dist_config.hadoop_version,
        }

        # dist_config will have simple validation done on primary keys in the
        # dist.yaml, but we need to ensure deeper values are present.
        required_dirs = ['hadoop', 'hadoop_conf', 'hdfs_log_dir',
                         'yarn_log_dir']
        missing_dirs = set(required_dirs) - set(self.dist_config.dirs.keys())
        if missing_dirs:
            raise ValueError('dirs option in {} is missing required entr{}: {}'.format(
                self.dist_config.yaml_file,
                'ies' if len(missing_dirs) > 1 else 'y',
                ', '.join(missing_dirs)))

        # Build a list of hadoop resources needed from resources.yaml
        hadoop_resources = []
        hadoop_version = self.dist_config.hadoop_version
        try:
            jujuresources.resource_path('hadoop-%s-%s' % (hadoop_version, self.cpu_arch))
            hadoop_resources.append('hadoop-%s-%s' % (hadoop_version, self.cpu_arch))
        except KeyError:
            hadoop_resources.append('hadoop-%s' % (self.cpu_arch))

        # LZO compression for hadoop is distributed separately. Add it to the
        # list of reqs if defined in resources.yaml
        try:
            jujuresources.resource_path('hadoop-lzo-%s' % self.cpu_arch)
            hadoop_resources.append('hadoop-lzo-%s' % (self.cpu_arch))
        except KeyError:
            pass

        # Verify and fetch the required hadoop resources
        self.verify_conditional_resources = utils.verify_resources(*hadoop_resources)
示例#7
0
 def test_resource_path(self, mload):
     mload.return_value = self.resources
     self.assertEqual(jujuresources.resource_path('valid'),
                      'res-defaults.yaml')
示例#8
0
 def test_resource_path(self, m_load_resources):
     dest = os.path.join(self.test_data, 'res-defaults.yaml')
     m_load_resources.return_value = self.resdefs
     self.assertEqual(jujuresources.resource_path('valid'), dest)
示例#9
0
 def test_resource_path(self, mload):
     mload.return_value = self.resources
     self.assertEqual(jujuresources.resource_path('valid'), 'res-defaults.yaml')