Exemple #1
0
 def test_import_cluster_v12(self):
     resource = utils.MockResource(self, version=12)
     cms = ClouderaManager(resource)
     data = ApiClusterTemplate(resource).to_json_dict()
     resource.expect(method="POST",
                     reqpath="/cm/importClusterTemplate",
                     params=dict(addRepositories=True),
                     data=data,
                     retdata=ApiCommand(resource).to_json_dict())
     cms.import_cluster_template(data, True)
Exemple #2
0
 def test_import_cluster_v12(self):
   resource = utils.MockResource(self, version=12)
   cms = ClouderaManager(resource)
   data = ApiClusterTemplate(resource).to_json_dict()
   resource.expect(
     method="POST",
     reqpath="/cm/importClusterTemplate",
     params=dict(addRepositories=True),
     data = data,
     retdata=ApiCommand(resource).to_json_dict())
   cms.import_cluster_template(data, True)
def main():
        try:
                print '###############################\n\n'
                print 'STAGE 0. Services Prerequisite'
#               api_prerequisite()
                template = ApiClusterTemplate(resource).from_json_dict(data, resource)
                cms = ClouderaManager(resource)
                print 'STAGE 1. Installing Hosts'
                # Union of all Hosts
                CLUSTER_HOSTS = list(set(MGMT_1.split()) | set(MGMT_2.split()) | set(MGMT_3.split()) | set(HOST_DATA))
                print CLUSTER_HOSTS
                logger('info','Cluster Hosts part of this install' )
                logger('info','Adding hosts to Cloudera Manager')
                cm_install_hosts(logger,cms,HOST_USER,CLUSTER_HOSTS,HOST_PASS)
				
                print 'STAGE 2. CM API importing cluster template'
                logger('info','CM API importing cluster template' + OUTPUT_TEMPLATE )
                command = cms.import_cluster_template(template)
                command = command.wait()

                print "Active: %s. Success: %s" % (command.active, command.success)
                print "Cluster installation triggered !!!"
                logger('info',"Cluster template " + CLUSTER_NM + " import finished !!!");
        except Exception,err:
                logger('error',"Getting below exceptions, unable to install cluster " + CLUSTER_NM);
                logger('error',str(err));
                print "Failed to import cluster\n\n";
                print "Getting exceptions... check log file: "+LOG_FILE;
                sys.exit(1)
Exemple #4
0
 def import_cluster_template(self, template_filename, cluster_name):
     """
     To import cluster template configuration into given cluster
     :param template_filename:
     :param cluster_name:
     :return:
     """
     cluster = self._cloudera_manager_oconnect.get_cluster(cluster_name)
     with open(template_filename) as data_file:
         data = json.load(data_file)
     template = ApiClusterTemplate(cluster).from_json_dict(data, cluster)
     cms = ClouderaManager(cluster)
     command = cms.import_cluster_template(template)
     print(command)