当前位置: 首页>>代码示例>>Python>>正文


Python ApiResource.get_cluster方法代码示例

本文整理汇总了Python中cm_api.api_client.ApiResource.get_cluster方法的典型用法代码示例。如果您正苦于以下问题:Python ApiResource.get_cluster方法的具体用法?Python ApiResource.get_cluster怎么用?Python ApiResource.get_cluster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cm_api.api_client.ApiResource的用法示例。


在下文中一共展示了ApiResource.get_cluster方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ImpalaCluster

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
class ImpalaCluster(object):
  def __init__(self, cm_host, cm_cluster_name, username, password):
    self.cm_api = ApiResource(cm_host, username=username, password=password)
    self.hosts = dict()
    self.services = list()
    self.cluster = self.cm_api.get_cluster(cm_cluster_name)
    if self.cluster is None:
      raise RuntimeError, 'Cluster name "%s" not found' % cm_cluster_name

    self.__load_hosts()
    self.__impala_service = ImpalaService(self)

  def _get_all_services(self):
    return self.cluster.get_all_services()

  def get_impala_service(self):
    return self.__impala_service

  def __load_hosts(self):
    self.hosts = dict()
    # Search for all hosts that are in the target cluster.
    # There is no API that provides the list of host in a given cluster, so to find them
    # we must loop through all the hosts and check the cluster name matches.
    for host_info in self.cm_api.get_all_hosts():
      # host_info doesn't include a link to the roleRef so need to do another lookup
      # based on the hostId.
      host = self.cm_api.get_host(host_info.hostId)
      for roleRef.get('clusterName') == self.cluster_name:
        self.hosts[host_info.hostId] = Host(host)
          break
开发者ID:digideskio,项目名称:recordservice,代码行数:32,代码来源:impala_cluster_cm.py

示例2: main

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
def main():
    """
    Kerberizes a cluster.

    @rtype:   number
    @returns: A number representing the status of success.
    """
    settings = retrieve_args()

    api = ApiResource(settings.host, settings.port, settings.username,
                      settings.password, settings.use_tls, 8)

    cloudera_manager = api.get_cloudera_manager()
    cluster = api.get_cluster(settings.cluster)
    mgmt_service = cloudera_manager.get_service()

    if verify_cloudera_manager_has_kerberos_principal(cloudera_manager):
        wait_for_command('Stopping the cluster', cluster.stop())
        wait_for_command('Stopping MGMT services', mgmt_service.stop())
        configure_services(cluster)
        wait_for_generate_credentials(cloudera_manager)
        wait_for_command('Deploying client configs.', cluster.deploy_client_config())
        wait_for_command('Deploying cluster client configs', cluster.deploy_cluster_client_config())
        wait_for_command('Starting MGMT services', mgmt_service.start())
        wait_for_command('Starting the cluster', cluster.start())
    else:
        print "Cluster does not have Kerberos admin credentials.  Exiting!"

    return 0
开发者ID:bdclark,项目名称:director-scripts,代码行数:31,代码来源:kerberize-cluster.py

示例3: main

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
def main():
   API = ApiResource(CM_HOST, version=5, username=ADMIN_USER, password=ADMIN_PASS)
   print "Connected to CM host on " + CM_HOST

   CLUSTER = API.get_cluster(CLUSTER_NAME)

   print "About to restart cluster."
   CLUSTER.restart().wait()
   print "Done restarting cluster."
开发者ID:MrTomerLevi,项目名称:cm_api,代码行数:11,代码来源:restartcloudera.py

示例4: do_call

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
def do_call(host, port, version, user, password, cluster_name, parcel_name, parcel_version, parcel_repo, init_pre_dir, init_post_dir):
    api = ApiResource(host, port, user, password, False, version)
    if not parcel_repo.endswith('/'):
        parcel_repo += '/'
    if re.match(REGEX_VERSION, parcel_version) is None or re.match(REGEX_VERSION, parcel_version).group() != parcel_version:
        raise Exception('Parcel [' + parcel_name + '] is qualified by invalid version [' + parcel_version + '] expected to match regular expression [' + REGEX_VERSION + ']')
    if not parcel_repo.endswith(parcel_version + '/'):
        raise Exception('Parcel [' + parcel_name + '] is qualified by invalid version [' + parcel_version + '] when compared with repository [' + parcel_repo + ']')    
    cm_config = api.get_cloudera_manager().get_config(view='full')
    repo_config = cm_config['REMOTE_PARCEL_REPO_URLS']
    repo_list = repo_config.value or repo_config.default
    if parcel_repo not in repo_list:     
        repo_list += ',' + parcel_repo
        api.get_cloudera_manager().update_config({'REMOTE_PARCEL_REPO_URLS': repo_list})
        time.sleep(POLL_SEC)  # The parcel synchronize end-point is not exposed via the API, so sleep instead
    cluster_names = []
    if cluster_name is None:
        for cluster in api.get_all_clusters():
            cluster_names.append(cluster.name)
    else:
        cluster_names.append(cluster_name)
    for cluster_name_itr in cluster_names:
        print 'Cluster [DEPLOYMENT] starting ... '
        cluster = api.get_cluster(cluster_name_itr)
        parcel = cluster.get_parcel(parcel_name, parcel_version)
        print 'Parcel [DEPLOYMENT] starting ... '
        do_parcel_op(cluster, parcel_name, parcel_version, 'DOWNLOAD', 'AVAILABLE_REMOTELY', 'DOWNLOADED', 'start_download')
        do_parcel_op(cluster, parcel_name, parcel_version, 'DISTRIBUTE', 'DOWNLOADED', 'DISTRIBUTED', 'start_distribution')
        do_parcel_op(cluster, parcel_name, parcel_version, 'ACTIVATE', 'DISTRIBUTED', 'ACTIVATED', 'activate')
        parcel = cluster.get_parcel(parcel_name, parcel_version)
        if parcel.stage != 'ACTIVATED':
            raise Exception('Parcel is currently mid-stage [' + parcel.stage + '], please wait for this to complete')
        print 'Parcel [DEPLOYMENT] finished'
        if init_pre_dir is not None and os.path.isdir(init_pre_dir):
            print 'Cluster [PRE_INIT] starting ... '
            for script in glob.glob(init_pre_dir + '/*.sh'):
                subprocess.call([script])
            print 'Cluster [PRE_INIT] finihsed'            
        print 'Cluster [CONFIG_DEPLOYMENT] starting ... '
        cluster.deploy_client_config()
        cmd = cluster.deploy_client_config()
        if not cmd.wait(TIMEOUT_SEC).success:
            raise Exception('Failed to deploy client configs')
        print 'Cluster [CONFIG_DEPLOYMENT] finihsed'
        print 'Cluster [STOP] starting ... '
        cluster.stop().wait()
        print 'Cluster [STOP] finihsed'
        print 'Cluster [START] starting ... '
        cluster.start().wait()
        print 'Cluster [START] finihsed'
        if init_post_dir is not None and os.path.isdir(init_post_dir):
            print 'Cluster [POST_INIT] starting ... '
            for script in glob.glob(init_post_dir + '/*.sh'):
                subprocess.call([script])
            print 'Cluster [POST_INIT] finihsed'            
        print 'Cluster [DEPLOYMENT] finished'
开发者ID:boghbogh,项目名称:cloudera-framework,代码行数:58,代码来源:cloudera-framework-parcel.py

示例5: main

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
def main():
    # connect cm api
    api = ApiResource(CM_HOST, 7180, username=CM_USERNAME, password=CM_PASSWORD)
    manager = api.get_cloudera_manager()
    # no need to update cm config
    #manager.update_config(cm_host)
    print("[INFO] Connected to CM host on " + CM_HOST)

    # create cluster object
    try:
        cluster = api.get_cluster(name=CLUSTER_NAME)
    except:
        cluster = init_cluster(api, CLUSTER_NAME, CLUSTER_VERSION, CLUSTER_NODE_COUNT)
    print("[INFO] Initialized cluster " + CLUSTER_NAME + " which uses CDH version " + CLUSTER_VERSION)

    #
    mgmt_servicename = "MGMT"
    amon_role_name = "ACTIVITYMONITOR"
    apub_role_name = "ALERTPUBLISHER"
    eserv_role_name = "EVENTSERVER"
    hmon_role_name = "HOSTMONITOR"
    smon_role_name = "SERVICEMONITOR"
    nav_role_name = "NAVIGATOR"
    navms_role_name = "NAVIGATORMETADATASERVER"
    rman_role_name = "REPORTMANAGER"
    deploy_management(manager, mgmt_servicename, amon_role_name, apub_role_name, eserv_role_name, hmon_role_name, smon_role_name, nav_role_name, navms_role_name, rman_role_name)
    print("[INFO] Deployed CM management service " + mgmt_servicename + " to run on " + CM_HOST)

    #
    assign_roles(api, cluster)
    print("[INFO] all roles have assigned.")

    #
    # Custom role config groups cannot be automatically configured: Gateway Group 1 (error 400)
    try:
        cluster.auto_configure()
    except:
        pass
    update_custom_config(api, cluster)
    print("[INFO] all servies and roles have configured.")
    #
    cmd = cluster.first_run()
    while cmd.success == None:
        cmd = cmd.fetch()
    if not cmd.success:
        print("[ERROR] The first run command failed: " + cmd.resultMessage())
    else:
        print("[INFO] First run successfully executed. Your cluster has been set up!")
开发者ID:FayeHuang,项目名称:docker-CDH,代码行数:50,代码来源:deployCDH.py

示例6: main

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
def main():
    resource = ApiResource("localhost", 7180, "cloudera", "cloudera", version=19)
    cluster = resource.get_cluster("Cloudera Quickstart")

    cm_manager = resource.get_cloudera_manager()
    cm_manager.update_config({'REMOTE_PARCEL_REPO_URLS': PARCEL_REPO})
    cm_manager.update_all_hosts_config(JDK_CONFIG)
    time.sleep(5)

    for parcel in PARCELS:
        ParcelInstaller(parcel['name'], parcel['version']).install(cluster)

    print "Restarting cluster"
    cluster.stop().wait()
    cluster.start().wait()
    print "Done restarting cluster"
开发者ID:ottogroup,项目名称:schedoscope,代码行数:18,代码来源:parcel-installer.py

示例7: main

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
def main():
    """
    Enables HDFS HA on a cluster.

    @rtype:   number
    @returns: A number representing the status of success.
    """
    settings = retrieve_args()

    api = ApiResource(settings.host, settings.port, settings.username, settings.password,
                      version=6)

    if not validate_cluster(api, settings.cluster):
        write_to_stdout("Cluster does not satisfy preconditions for enabling HDFS HA. Exiting!")
        return 1

    if settings.wait_for_good_health:
        write_to_stdout("Waiting for GOOD health... ")
        if not wait_for_good_health(api, settings.cluster):
            write_to_stdout("Cluster health is not GOOD.  Exiting!\n")
            return 1
    else:
        write_to_stdout("Checking cluster health... ")
        if not check_health(api, settings.cluster):
            write_to_stdout("Cluster health is not GOOD.  Exiting!\n")

    write_to_stdout("Cluster health is GOOD!\n")

    cluster = api.get_cluster(settings.cluster)

    invoke_hdfs_enable_nn_ha(cluster, settings.nameservice)
    update_hive_for_ha_hdfs(cluster)

    # Restarting the MGMT services to make sure the HDFS file browser functions
    # as expected.
    cloudera_manager = api.get_cloudera_manager()
    mgmt_service = cloudera_manager.get_service()
    wait_for_command('Restarting MGMT services', mgmt_service.restart())

    return 0
开发者ID:bdclark,项目名称:director-scripts,代码行数:42,代码来源:enable-hdfs-ha.py

示例8: main

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
def main():
    
    """
    TODO: This probably needs some work.  You get the idea though.  
    An example of how to do a bulk config update to Cloudera Manager.  This is helpful if you have a bunch of changes
    That you want to make but don't want to use the GUI.  
    """
    
    parser = argparse.ArgumentParser(description='Cloudera Manager Bulk Config Update Script')
    parser.add_argument('-H', '--host', '--hostname', action='store', dest='hostname', required=True, help='CM server host')
    parser.add_argument('-p', '--port', action='store', dest='port', type=int, default=7180, help='example: 7180')
    parser.add_argument('-u', '--user', '--username', action='store', dest='username', required=True, help='example: admin')
    parser.add_argument('-c', '--cluster', action='store', dest='cluster', required=True, help='example: hadrian-cluster')
    args = parser.parse_args() 
    password = getpass.getpass('Please enter your Cloudera Manager passsword: ')
    
    # read configuration files:
    for i in os.listdir('./conf/' + args.cluster):
        config.read('./conf/' + args.cluster + '/' + i)
    
    api = ApiResource(args.hostname, args.port, args.username, password)
    cluster = api.get_cluster(args.cluster)
    services = cluster.get_all_services()
   
    # update services based with configuration file parameters   
    for service in services:
        if config_grabber.has_section(service.type):
            service.update_config(svc_config=config_grabber(service.name + '-svc-config'))
            config_groups = config_grabber(service.name)['config_groups']
            for config_group in config_groups.split(','):
                print section
                temp_config_group = service.get_role_config_group(section)
                temp_config_group.update_config(config_grabber(section))
        else:
            print 'unknown service: ' + service.name

    print 'Starting final client configuration deployment for all services.'
    cmd = cluster.deploy_client_config()
    if not cmd.wait(CMD_TIMEOUT).success:
        print 'Failed to deploy client configuration.'
开发者ID:andmarios,项目名称:hadrian,代码行数:42,代码来源:BulkUpdateClouderaManager.py

示例9: main

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
def main():

   """
   This is an example script for printing the default configurations for a CM Service.
   It's rough, but it gets the job done.  This  is how you can see all of the settings
   you've made for service along iwth the defaults.  Helpful if you are just curious
   what things look like.  For a more Hadrian-ish way to export configurations,
   see ExportConfigs.py
   """

   api = ApiResource('<cloudera manager server>', 7180, '<username>', '<password>')
   cluster = api.get_cluster('CM')
   service = cluster.get_service('<service name>')
   
   for i in service.get_all_role_config_groups():
      print '--------------------------------------------------------'
      print i.name
      print '--------------------------------------------------------'
      for k,v in i.get_config('full').iteritems():
          if v.value is None:  
             print k + ' - default - ' + str(v.default)
          else: 
             print k + ' - ' + str(v.value)
开发者ID:andmarios,项目名称:hadrian,代码行数:25,代码来源:PrintServiceConfigs.py

示例10: ApiResource

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
#
#  else :
#   print >>sys.stderr, 'Cannot replicate from that cluster!'
#    return -1

  vm_version = cf['CM_VERSION']
  API = ApiResource(cmHost, cf['CM_PORT'],  version=cf['CM_VERSION'], username=cf['CM_USER'], password=cf['CM_PASSWD'], use_tls=False)
  LOG.debug('Connected to CM host on ' + cmHost)

  procUser = getUsername()
  LOG.debug('Process effective username is ' + procUser)
  procGroup= getGroupname()
  LOG.debug('Process effective group name is ' + procGroup)
  procUserGroups = getUserGroups(procUser)
  LOG.debug('All groups for user:' +  ', '.join(procUserGroups))
  cluster = API.get_cluster(cf['CLUSTER_NAME'])

  if action == 'listRepls':
    print >>sys.stdout,  '\n\tSearching replication schedules for user: ' + procUser + ' group(s): ' + ', '.join(procUserGroups)
    schedules = getAccessableSchedules(cf,cluster,procUser,procUserGroups)
    printReplicationSchedules(cf,schedules)
    return cf['RET_OK']

# get details about the replication the user is interested in
  if service == cf['HIVE_SERVICE']:
    path = getDatabaseLocation(cf,database)
    LOG.debug('DB location is ' + path)
    schedule = getHiveSchedule (cluster,service,database,table)
  else:
    schedule = getHdfsSchedule (cluster,service,path)
    path = schedule.hdfsArguments.sourcePath
开发者ID:jvprosser,项目名称:cm_repl,代码行数:33,代码来源:cm_repl.py

示例11:

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
#hosts.append("master")
#hosts.append("w01")
#hosts.append("w02")
#hosts.append("w03")
hosts.append("ip-10-11-167-80")
hosts.append("ip-10-153-224-197")
hosts.append("ip-10-37-166-245")
hosts.append("ip-10-169-69-118")
cluster.add_hosts(hosts)

# Downloads and distributes parcels

# Had to recreate the cluster object as follows. For some reason doing a cluster.get_parcel was
# failing while the cluster object was api.create_cluster() 

cluster = api.get_cluster("cloudera-pe-test")
#parcel = cluster.get_parcel("CDH", "5.2.0-1.cdh5.2.0.p0.36")
parcel = cluster.get_parcel("CDH", "5.2.0-1.cdh5.2.0.p0.36")
parcel.start_download();
while True:
    parcel = cluster.get_parcel("CDH", "5.2.0-1.cdh5.2.0.p0.36")
    if parcel.stage != "DOWNLOADED":
    	print "Downloading : %s / %s" % ( parcel.state.progress, parcel.state.totalProgress)
    else:
	break

parcel.start_distribution()
while True:
    parcel = cluster.get_parcel("CDH", "5.2.0-1.cdh5.2.0.p0.36")
    if parcel.stage != "DISTRIBUTED":
        print "Distributing: %s / %s" % ( parcel.state.progress, parcel.state.totalProgress)
开发者ID:implicateorder,项目名称:cm_api_automation,代码行数:33,代码来源:create_cluster.py

示例12: ApiResource

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
#!/usr/bin/env python

import socket
import time
from cm_api.api_client import ApiResource
from cm_api.endpoints.services import ApiService
from cm_api.endpoints.services import ApiServiceSetupInfo

cm_host = 'ip-10-136-86-133'
api = ApiResource(cm_host, username='admin', password='admin')

cluster = api.get_cluster('cloudera-pe-test')

### HBase ###
hbase_service_name = "HBASE"
hbase_service_config = {
  'hdfs_service': 'hdfs01',
  'zookeeper_service': 'zookeeper01',
}
hbase_hm_host = "ip-10-136-86-133"
hbase_hm_config = { }
hbase_rs_hosts = [ ]
hbase_rs_hosts.append("ip-10-153-224-197")
hbase_rs_hosts.append("ip-10-169-69-118")
hbase_rs_config = {
  'hbase_hregion_memstore_flush_size': 1024000000,
  'hbase_regionserver_handler_count': 10,
  'hbase_regionserver_java_heapsize': 2048000000,
  'hbase_regionserver_java_opts': '',
}
hbase_thriftserver_service_name = "HBASETHRIFTSERVER"
开发者ID:implicateorder,项目名称:cm_api_automation,代码行数:33,代码来源:hbase_setup.py

示例13: usage

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
      usage()
      return RET_BADOPTS

# check argument compatibility
  if args:
    print >>sys.stderr, '\n\tUnknown trailing argument:', args
    usage()
    return RET_BADOPTS

  if  path == None :
    print >>sys.stderr, '\n\tPlease specify a pathe.'
    usage()
    return RET_BADOPTS

  API = ApiResource(cmHost, CM_PORT,  version=CM_VERSION, username=CM_USER, password=CM_PASSWD, use_tls=True)
  LOG.debug('Connected to CM host on ' + cmHost)

  procUser = getUsername()
  LOG.debug('Process effective username is ' + procUser)

  cluster = API.get_cluster(CLUSTER_NAME)


  return RET_OK

#
# The 'main' entry
#
if __name__ == '__main__':
  sys.exit(main(sys.argv))
开发者ID:jvprosser,项目名称:cm_repl,代码行数:32,代码来源:cm_snapshot.py

示例14: ApiResource

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
	        --- CHECK ROLES HEALTH STATUS START ---\n\n\n"""

	api = ApiResource(cm_host, 7180, user , password)
	# Get a list of all clusters
	cdh = None
	if (api == None):
		print "COnnect error"
	try:
		for c in api.get_all_clusters():
			cdh = c
		print strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))," PRESENT CLUSTER: ",cdh.name
	except:
		print strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()) )," Error get cluster"
		send_alert_mail("CONNECT_ERROR","","","");
	if cdh != None:
		for s in api.get_cluster(cdh.name).get_all_services():
			#print strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))," SERVICES: ",s.name
			cluster = api.get_cluster(cdh.name);
			service_mapred=cluster.get_service(s.name)
			roles=service_mapred.get_all_roles()
			for r in service_mapred.get_all_roles():
				#print strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))," Role ",r.name," is in status [ ",r.healthSummary," ]"
				#check if not GOOD and not BAD
				if (r.healthSummary != "GOOD" and r.roleState == "STARTED" and r.healthSummary != "BAD"):
					send_alert_mail(r.healthSummary,r.name,r.hostRef.hostId,s.name)
					print strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))," SERVICES: ",s.name
					print strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))," Role ",r.name," is in status [ ",r.healthSummary," ]"
	print """\n\n\n		--- CHECK ROLES HEALTH NOT GOOD STATUS END ---
===================================================================================="""	
except:
	print "Can't not connect to CDH API"
开发者ID:kyo88,项目名称:python_script,代码行数:33,代码来源:runtime_check_cdh_role_not_good_health.py

示例15: set_up_cluster

# 需要导入模块: from cm_api.api_client import ApiResource [as 别名]
# 或者: from cm_api.api_client.ApiResource import get_cluster [as 别名]
def set_up_cluster():
    # get a handle on the instance of CM that we have running
    api = ApiResource(cm_host, cm_port, cm_username, cm_password, version=7)

    # get the CM instance
    cm = ClouderaManager(api)

    # activate the CM trial license
    cm.begin_trial()

    # create the management service
    service_setup = ApiServiceSetupInfo(name=cm_service_name, type="MGMT")
    cm.create_mgmt_service(service_setup)

    # install hosts on this CM instance
    cmd = cm.host_install(host_username, host_list, password=host_password, cm_repo_url=cm_repo_url) 
    print "Installing hosts. This might take a while."
    while cmd.success == None:
	sleep(5)
        cmd = cmd.fetch()

    if cmd.success != True:
        print "cm_host_install failed: " + cmd.resultMessage
        exit(0)

    print "cm_host_install succeeded"

    # first auto-assign roles and auto-configure the CM service
    cm.auto_assign_roles()
    cm.auto_configure()

    # create a cluster on that instance
    cluster = create_cluster(api, cluster_name, cdh_version)

    # add all our hosts to the cluster
    cluster.add_hosts(host_list)

    cluster = api.get_cluster("Cluster 1")

    parcels_list = []
    # get and list all available parcels
    print "Available parcels:"
    for p in cluster.get_all_parcels():
        print '\t' + p.product + ' ' + p.version
        if p.version.startswith(cdh_version_number) and p.product == "CDH":
	    parcels_list.append(p)

    if len(parcels_list) == 0:
        print "No " + cdh_version + " parcel found!"
        exit(0)

    cdh_parcel = parcels_list[0]
    for p in parcels_list:
        if p.version > cdh_parcel.version:
	    cdh_parcel = p

    # download the parcel
    print "Starting parcel download. This might take a while."
    cmd = cdh_parcel.start_download()
    if cmd.success != True:
        print "Parcel download failed!"
        exit(0)

    # make sure the download finishes
    while cdh_parcel.stage != 'DOWNLOADED':
	sleep(5)
        cdh_parcel = get_parcel(api, cdh_parcel.product, cdh_parcel.version, cluster_name)

    print cdh_parcel.product + ' ' + cdh_parcel.version + " downloaded"

    # distribute the parcel
    print "Starting parcel distribution. This might take a while."
    cmd = cdh_parcel.start_distribution()
    if cmd.success != True:
        print "Parcel distribution failed!"
        exit(0)


    # make sure the distribution finishes
    while cdh_parcel.stage != "DISTRIBUTED":
	sleep(5)
	cdh_parcel = get_parcel(api, cdh_parcel.product, cdh_parcel.version, cluster_name)

    print cdh_parcel.product + ' ' + cdh_parcel.version + " distributed"

    # activate the parcel
    cmd = cdh_parcel.activate()
    if cmd.success != True:
        print "Parcel activation failed!"
        exit(0)

    # make sure the activation finishes
    while cdh_parcel.stage != "ACTIVATED":
	cdh_parcel = get_parcel(api, cdh_parcel.product, cdh_parcel.version, cluster_name)

    print cdh_parcel.product + ' ' + cdh_parcel.version + " activated"

    # inspect hosts and print the result
    print "Inspecting hosts. This might take a few minutes."

#.........这里部分代码省略.........
开发者ID:MrTomerLevi,项目名称:cm_api,代码行数:103,代码来源:cluster_set_up.py


注:本文中的cm_api.api_client.ApiResource.get_cluster方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。