Exemplo n.º 1
0
    def modify_service_configs(self, serviceName, config_type, configs_dict, restart_service=True):
        # apicorelib.modify_service_configs(serviceName, config_type, configs_dict)
        # if restart_service == True:
        #     self.restart_service(serviceName)
        Ambari.modify_service_configs_and_restart(serviceName, config_type, configs_dict)
        baseurl = self.getClusterNameUrl()
        tag = self.getLatestVersionTag(baseurl + '/configurations?type=' + config_type)
        url = baseurl + '/configurations?type=' + config_type + '&tag=' + str(tag)
        response = Ambari.http_get_request(url, "")
        json_data = json.loads(response._content)
        if self.backupDataJson.get(serviceName) is None:
            self.backupDataJson[serviceName] = {}
            self.backupDataJson[serviceName][config_type] = copy.deepcopy(json_data)
        elif self.backupDataJson.get(serviceName).get(config_type) is None:

            self.backupDataJson[serviceName][config_type] = copy.deepcopy(json_data)
Exemplo n.º 2
0
 def getLatestVersionTag(self, url):
     #hres,resVer=self.callPyCurlRequest(url=url, data=None, method='get', usernamepassword=self.username_password)
     response = Ambari.http_get_request(url, "")
     d = json.loads(response._content)
     versions = list()
     tagVersions = list()
     for value in d['items']:
         versions.append(value['version'])
         tagVersions.append(str(value['version']) + ':' + value['tag'])
     versions.sort()
     len = versions.__len__()
     val = versions.pop(len - 1)
     tagVer = [s for s in tagVersions if str(val) + ':' in s]
     itms = list()
     itms = tagVer[0].split(':')
     itmLen = itms.__len__()
     latestTag = itms.pop(itmLen - 1)
     return latestTag
Exemplo n.º 3
0
 def getServiceStateOnHost(self, host, component):
     url = self.getClusterNameUrl() + '/hosts/' + host + '/host_components/' + component
     #response = self.http_put_post_request(url,data=None, method='get')
     response = Ambari.http_get_request(url, "")
     json_data = json.loads(response._content)
     return json_data['HostRoles']['state']