예제 #1
0
 def restartLLAP(cls):
     cluster = Ambari.getClusterName()
     data = '{"RequestInfo":{"context":"Restart LLAP","command":"RESTART_LLAP"},"Requests/resource_filters":[{"service_name":"HIVE","component_name":"HIVE_SERVER_INTERACTIVE","hosts":"%s"}]}' % (
         cls.getHiveHost()
     )
     url = '/api/v1/clusters/' + cluster + '/requests'
     r = Ambari.http_put_post_request(url, data, 'POST')
     assert (r.status_code == 200 or r.status_code == 201 or r.status_code == 202
             ), "Failed to restart LLAP  on host %s, status=%d" % (cls.getHiveHost(), r.status_code)
     time.sleep(240)
예제 #2
0
 def restoreConf(self, config_type, serviceName, restart_service=True):
     baseurl = self.getClusterNameUrl()
     #tag =  self.getLatestVersionTag(baseurl + '/configurations?type=' + config_type)
     new_tag = "version" + str(uuid.uuid4())
     json_data = '{"Clusters":{"desired_config":{"tag":"' + new_tag + '", "type":"' + config_type + '", "properties":' + str(
         json.dumps(self.backupDataJson[serviceName][config_type]['items'][0]['properties'])
     ) + '}}}'
     response = Ambari.http_put_post_request(baseurl, json_data, 'PUT', "")
     print("resonse for conf change after restore conf:" + str(response))
     if restart_service == True:
         self.restart_service(serviceName)
예제 #3
0
 def refreshYarnQueues(cls, host_ip, weburl=source_weburl, cluster=None):
     hostname = Machine.runas('root', 'hostname', host_ip)
     if cluster == None:
         cluster = Ambari.getClusterName()
     if weburl == None:
         weburl = Ambari.getWebUrl()
     else:
         cluster = Ambari.getClusterName(weburl=weburl)
     uri = "/api/v1/clusters/%s/requests" % (cluster)
     data = '{"RequestInfo":{"context":"Refresh YARN Capacity Scheduler","command":"REFRESHQUEUES","parameters/forceRefreshConfigTags":"capacity-scheduler"},' \
            '"Requests/resource_filters":[{"service_name":"YARN","component_name":"RESOURCEMANAGER","hosts":"' + hostname[1] + '"}]}'
     response = Ambari.http_put_post_request(uri=uri,
                                             data=data,
                                             requestType="POST",
                                             weburl=target_weburl)
     assert response.status_code == 202, "Failed To refresh Yarn Queue: Response Code: " + str(
         response.status_code) + "Response body: " + response._content
예제 #4
0
 def start_stop_service_on_host(self, host, component, state):
     url = self.getClusterNameUrl() + '/hosts/' + host + '/host_components/' + component
     data = '{"HostRoles": {"state": "' + state + '"}}'
     #response = self.http_put_post_request(url, data, method='put')
     response = Ambari.http_put_post_request(url, data, "PUT", "")
     print('response for the component: ' + component + ' state: ' + state + ' is: ' + str(response))
     if response.status_code is 202:
         json_data = json.loads(response._content)
         request_id = json_data['Requests']['id']
         print("Waiting for the component: " + component + " to be:" + state)
         counter = 0
         while not self.get_request_current_state(request_id) == 'COMPLETED':
             if self.get_request_current_state(request_id) == 'ABORTED':
                 print('service status change aborted!')
                 break
             elif self.get_request_current_state(request_id) == 'FAILED':
                 print('service status change failed!')
                 break
             elif counter > 100:
                 print('operation exceeded the timeout')
                 break
             counter = counter + 1
             time.sleep(5)
     return response