def delete_directory (self, name=EMPTY): """ delete a directory :param name: directory name :return: """ if name != EMPTY: self.tenant=name resp = http_utils.request(http_utils.DELETE, url=self.__create_url(DELETE_DIR), headers=self.__create_headers()) http_utils.assert_status_code(http_utils.status_codes[http_utils.OK], resp, "ERROR- deleting directory %s ..." % (name)) return resp
def open_file (self, directory, file_name): """ open file in hadoop :param directory: /tenant/service_path/resource/ :param file: resource.txt :return: """ self.file_name = file_name self.directory= directory resp = http_utils.request(http_utils.GET, url=self.__create_url(OPEN_FILE), headers=self.__create_headers()) return resp
def open_file(self, directory, file_name): """ open file in hadoop :param directory: /tenant/service_path/resource/ :param file: resource.txt :return: """ self.file_name = file_name self.directory = directory resp = http_utils.request(http_utils.GET, url=self.__create_url(OPEN_FILE), headers=self.__create_headers()) return resp
def delete_directory(self, name=EMPTY): """ delete a directory :param name: directory name :return: """ if name != EMPTY: self.tenant = name resp = http_utils.request(http_utils.DELETE, url=self.__create_url(DELETE_DIR), headers=self.__create_headers()) http_utils.assert_status_code( http_utils.status_codes[http_utils.OK], resp, "ERROR- deleting directory %s ..." % (name)) return resp
def manager_version(self): """ Verify if hadoop is installed and that version is the expected """ if str(self.verify_version).lower().find("true") >= 0: resp = http_utils.request(http_utils.GET, url=self.__create_url(VERSION), headers=self.__create_headers()) http_utils.assert_status_code(http_utils.status_codes[http_utils.OK], resp, "ERROR - in version request... ") bodyDict = general_utils.convert_to_str_to_dict(resp.text, general_utils.JSON) assert STARTED == str (bodyDict[CLUSTER_INFO][HADOOP_STATE]), \ "hadoop is not started...\nverified: %s. Expected: %s. \n\nBody content: %s" \ % (str (bodyDict[CLUSTER_INFO][HADOOP_STATE]), STARTED, str(resp.text)) assert str(self.version) == str (bodyDict[CLUSTER_INFO][HADOOP_VERSION]), \ "Wrong hadoop version \nverified: %s. Expected: %s. \n\nBody content: %s" \ % (str (bodyDict[CLUSTER_INFO][HADOOP_VERSION]), str(self.version), str(resp.text))
def manager_version(self): """ Verify if hadoop is installed and that version is the expected """ if str(self.verify_version).lower().find("true") >= 0: resp = http_utils.request(http_utils.GET, url=self.__create_url(VERSION), headers=self.__create_headers()) http_utils.assert_status_code( http_utils.status_codes[http_utils.OK], resp, "ERROR - in version request... ") bodyDict = general_utils.convert_to_str_to_dict( resp.text, general_utils.JSON) assert STARTED == str (bodyDict[CLUSTER_INFO][HADOOP_STATE]), \ "hadoop is not started...\nverified: %s. Expected: %s. \n\nBody content: %s" \ % (str (bodyDict[CLUSTER_INFO][HADOOP_STATE]), STARTED, str(resp.text)) assert str(self.version) == str (bodyDict[CLUSTER_INFO][HADOOP_VERSION]), \ "Wrong hadoop version \nverified: %s. Expected: %s. \n\nBody content: %s" \ % (str (bodyDict[CLUSTER_INFO][HADOOP_VERSION]), str(self.version), str(resp.text))