def expand_jce_zip_file(jce_zip_path, jdk_security_path): f = None import zipfile if os.path.exists(jdk_security_path) and os.path.exists(jce_zip_path): try: f = zipfile.ZipFile(jce_zip_path, "r") zip_members = f.namelist() for member in zip_members: if member.endswith(os.sep): os.makedirs(os.path.join(jdk_security_path, member)) else: f.extract(member, jdk_security_path) unziped_jce_path = os.path.split(zip_members[len(zip_members) - 1])[0] finally: try: f.close() except Exception as e: err = "Fail during the extraction of {0}.".format(jce_zip_path) raise FatalException(1, err) else: err = "The path {0} or {1} is invalid.".format(jdk_security_path, jce_zip_path) raise FatalException(1, err) if unziped_jce_path: from_path = os.path.join(jdk_security_path, unziped_jce_path) jce_files = os.listdir(from_path) for i in range(len(jce_files)): jce_files[i] = os.path.join(from_path, jce_files[i]) copy_files(jce_files, jdk_security_path) dir_to_delete = os.path.join(jdk_security_path, unziped_jce_path.split(os.sep)[0]) shutil.rmtree(dir_to_delete)
def _install_jdbc_driver(self, properties, files_list): if type(files_list) is not int: print 'Copying JDBC drivers to server resources...' resources_dir = get_resources_location(properties) db_name = self.dbms_full_name.lower() symlink_name = db_name + "-jdbc-driver.jar" jdbc_symlink = os.path.join(resources_dir, symlink_name) db_default_driver_path = self._get_default_driver_path(properties) if os.path.lexists(jdbc_symlink): os.remove(jdbc_symlink) copy_status = copy_files(files_list, resources_dir) if not copy_status == 0: raise FatalException( -1, "Failed to copy JDBC drivers to server resources") if db_default_driver_path in files_list: os.symlink(os.path.join(resources_dir, self.driver_file_name), jdbc_symlink) else: if files_list == -1: return False return True
def _install_jdbc_driver(self, properties, files_list): if type(files_list) is not int: print 'Copying JDBC drivers to server resources...' try: resources_dir = properties[RESOURCES_DIR_PROPERTY] except KeyError: print_error_msg("There is no value for " + RESOURCES_DIR_PROPERTY + "in " + AMBARI_PROPERTIES_FILE) return False db_name = self.dbms_full_name.lower() symlink_name = db_name + "-jdbc-driver.jar" jdbc_symlink = os.path.join(resources_dir, symlink_name) db_default_driver_path = os.path.join(configDefaults.JAVA_SHARE_PATH, self.driver_file_name) if os.path.lexists(jdbc_symlink): os.remove(jdbc_symlink) copy_status = copy_files(files_list, resources_dir) if not copy_status == 0: raise FatalException(-1, "Failed to copy JDBC drivers to server resources") if db_default_driver_path in files_list: os.symlink(os.path.join(resources_dir, self.driver_file_name), jdbc_symlink) else: if files_list == -1: return False return True
def _install_jdbc_driver(self, properties, files_list): if type(files_list) is not int: print 'Copying JDBC drivers to server resources...' try: resources_dir = properties[RESOURCES_DIR_PROPERTY] except KeyError: print_error_msg("There is no value for " + RESOURCES_DIR_PROPERTY + "in " + AMBARI_PROPERTIES_FILE) return False db_name = self.dbms_full_name.lower() symlink_name = db_name + "-jdbc-driver.jar" jdbc_symlink = os.path.join(resources_dir, symlink_name) db_default_driver_path = os.path.join( configDefaults.JAVA_SHARE_PATH, self.driver_file_name) if os.path.lexists(jdbc_symlink): os.remove(jdbc_symlink) copy_status = copy_files(files_list, resources_dir) if not copy_status == 0: raise FatalException( -1, "Failed to copy JDBC drivers to server resources") if db_default_driver_path in files_list: os.symlink(os.path.join(resources_dir, self.driver_file_name), jdbc_symlink) else: if files_list == -1: return False return True
def _install_jdbc_driver(self, properties, files_list): if type(files_list) is not int: print 'Copying JDBC drivers to server resources...' resources_dir = get_resources_location(properties) db_name = self.dbms_full_name.lower() symlink_name = db_name + "-jdbc-driver.jar" jdbc_symlink = os.path.join(resources_dir, symlink_name) db_default_driver_path = self._get_default_driver_path(properties) if os.path.lexists(jdbc_symlink): os.remove(jdbc_symlink) copy_status = copy_files(files_list, resources_dir) if not copy_status == 0: raise FatalException(-1, "Failed to copy JDBC drivers to server resources") if db_default_driver_path in files_list: os.symlink(os.path.join(resources_dir, self.driver_file_name), jdbc_symlink) else: if files_list == -1: return False return True