@@ -330,6 +330,34 @@ def wait_for_active_cluster_service_commands(active_command):
330330 print ('Exception waiting for active commands: {}' .format (e ))
331331
332332
333+ def wait_for_active_service_commands (active_command , service_name ):
334+ """
335+ Wait until Cloudera Cluster Service finishes running active_command
336+ :param active_command: Descriptive of what should be running - this just waits if any task is detected running
337+ :return:
338+ """
339+ view = 'summary'
340+ wait_status = '[*'
341+ done = '0'
342+
343+ while done == '0' :
344+ sys .stdout .write ('\r %s - Waiting: %s' % (active_command , wait_status ))
345+ try :
346+ api_response = services_api .list_active_commands (cluster_name , service_name , view = view )
347+ if not api_response .items :
348+ if debug == 'True' :
349+ pprint (api_response )
350+ done = '1'
351+ sys .stdout .write (']\n ' )
352+ break
353+ else :
354+ sys .stdout .flush ()
355+ time .sleep (10 )
356+ wait_status = wait_status + '*'
357+ except ApiException as e :
358+ print ('Exception waiting for active service commands: {}' .format (e ))
359+
360+
333361def wait_for_active_mgmt_commands (active_command ):
334362 """
335363 Wait until Cloudera Manager finishes running mgmt active_command
@@ -820,7 +848,7 @@ def monitor_parcel(parcel_product, parcel_version, target_stage):
820848 if parcel .state .errors :
821849 raise Exception (str (parcel .state .errors ))
822850
823- sys .stdout .write ("\r Parcel %s progress %s: %s / %s" % (parcel_product , parcel .stage , parcel .state .progress ,
851+ sys .stdout .write ("\r \t Parcel %s progress %s: %s / %s" % (parcel_product , parcel .stage , parcel .state .progress ,
824852 parcel .state .total_progress ))
825853 time .sleep (5 )
826854 sys .stdout .flush ()
@@ -832,20 +860,21 @@ def monitor_parcel(parcel_product, parcel_version, target_stage):
832860 if parcel .product == parcel_product :
833861 parcel_version = parcel .version
834862
835- print ("Starting Parcel Download for %s - %s" % (parcel_product , parcel_version ))
863+ print ("\t Starting Parcel Download for %s - %s" % (parcel_product , parcel_version ))
836864 parcel_api .start_download_command (cluster_name , parcel_product , parcel_version )
837865 target_stage = 'DOWNLOADED'
838866 monitor_parcel (parcel_product , parcel_version , target_stage )
839- print ("\n %s parcel %s version %s on cluster %s" % (target_stage , parcel_product , parcel_version , cluster_name ))
840- print ("Starting Distribution for %s - %s" % (parcel_product , parcel_version ))
867+ print ("\n \t %s parcel %s version %s on cluster %s" % (target_stage , parcel_product , parcel_version , cluster_name ))
868+ print ("\t Starting Distribution for %s - %s" % (parcel_product , parcel_version ))
841869 parcel_api .start_distribution_command (cluster_name , parcel_product , parcel_version )
842870 target_stage = 'DISTRIBUTED'
843871 monitor_parcel (parcel_product , parcel_version , target_stage )
844- print ("\n %s parcel %s version %s on cluster %s" % (target_stage , parcel_product , parcel_version , cluster_name ))
845- print ("Activating Parcel %s" % parcel_product )
872+ print ("\n \t %s parcel %s version %s on cluster %s" % (target_stage , parcel_product , parcel_version , cluster_name ))
873+ print ("\t Activating Parcel %s" % parcel_product )
846874 parcel_api .activate_command (cluster_name , parcel_product , parcel_version )
847875 target_stage = 'ACTIVATED'
848876 monitor_parcel (parcel_product , parcel_version , target_stage )
877+ print ('\n \n ' )
849878
850879
851880def get_parcel_status (parcel_product ):
@@ -1242,7 +1271,7 @@ def push_rcg_config(config):
12421271 namenode_java_heapsize , namenode_log_dir , dfs_namenode_servicerpc_address ]
12431272 for config in nn_config_list :
12441273 push_rcg_config (config )
1245- create_role (rcg , rcg_roletype , service , snn_host_id , nn_hostname , 1 )
1274+ create_role (rcg , rcg_roletype , service , nn_host_id , nn_hostname , 1 )
12461275
12471276 if rcg == 'HDFS-DATANODE-BASE' :
12481277 print ('-->Updating RCG: %s' % rcg )
@@ -1296,7 +1325,7 @@ def push_rcg_config(config):
12961325 failover_controller_log_dir = [cm_client .ApiConfig (name = 'failover_controller_log_dir' ,
12971326 value = LOG_DIR + '/hadoop-hdfs' )]
12981327 push_rcg_config (failover_controller_log_dir )
1299- create_role (rcg , rcg_roletype , service , cm_host_id , cm_hostname , 1 )
1328+ # create_role(rcg, rcg_roletype, service, snn_host_id, snn_hostname , 1)
13001329
13011330 if rcg == 'HDFS-HTTPFS-BASE' :
13021331 print ('-->Updating RCG: %s' % rcg )
@@ -1326,7 +1355,10 @@ def push_rcg_config(config):
13261355 rcg_roletype = 'JOURNALNODE'
13271356 dfs_journalnode_edits_dir = [cm_client .ApiConfig (name = 'dfs_journalnode_edits_dir' ,
13281357 value = '/data/dfs/jn' )]
1358+ journalnode_log_dir = [cm_client .ApiConfig (name = 'journalnode_log_dir' ,
1359+ value = LOG_DIR + '/hadoop-hdfs' )]
13291360 push_rcg_config (dfs_journalnode_edits_dir )
1361+ push_rcg_config (journalnode_log_dir )
13301362 create_role (rcg , rcg_roletype , service , nn_host_id , nn_hostname , 1 )
13311363 create_role (rcg , rcg_roletype , service , snn_host_id , snn_hostname , 2 )
13321364 create_role (rcg , rcg_roletype , service , cm_host_id , cm_hostname , 3 )
@@ -1954,7 +1986,7 @@ def mgmt_role_commands(action):
19541986 pprint (api_response )
19551987 except ApiException as e :
19561988 print ('Exception running MgmtRoleCommandsResourceApi->restart_command {}\n ' .format (e ))
1957- active_command = action + ' ' + role
1989+ active_command = ' \t ' + action + ' ' + role
19581990 wait_for_active_mgmt_commands (active_command )
19591991
19601992 if action == 'start_command' :
@@ -1967,7 +1999,7 @@ def mgmt_role_commands(action):
19671999 pprint (api_response )
19682000 except ApiException as e :
19692001 print ('Exception running MgmtRoleCommandsResourceApi->start_command {}\n ' .format (e ))
1970- active_command = action + ' ' + role
2002+ active_command = ' \t ' + action + ' ' + role
19712003 wait_for_active_mgmt_commands (active_command )
19722004
19732005 if action == 'stop_command' :
@@ -1980,7 +2012,7 @@ def mgmt_role_commands(action):
19802012 pprint (api_response )
19812013 except ApiException as e :
19822014 print ('Exception running MgmtRoleCommandsResourceApi->stop_command {}\n ' .format (e ))
1983- active_command = action + ' ' + role
2015+ active_command = ' \t ' + action + ' ' + role
19842016 wait_for_active_mgmt_commands (active_command )
19852017
19862018 if action == 'jmap_dump' :
@@ -1993,7 +2025,7 @@ def mgmt_role_commands(action):
19932025 pprint (api_response )
19942026 except ApiException as e :
19952027 print ('Exception running MgmtRoleCommandsResourceApi->jmap_dump {}\n ' .format (e ))
1996- active_command = action + ' ' + role
2028+ active_command = ' \t ' + action + ' ' + role
19972029 wait_for_active_mgmt_commands (active_command )
19982030
19992031 if action == 'jmap_histo' :
@@ -2006,7 +2038,7 @@ def mgmt_role_commands(action):
20062038 pprint (api_response )
20072039 except ApiException as e :
20082040 print ('Exception running MgmtRoleCommandsResourceApi->jmap_history {}\n ' .format (e ))
2009- active_command = action + ' ' + role
2041+ active_command = ' \t ' + action + ' ' + role
20102042 wait_for_active_mgmt_commands (active_command )
20112043
20122044 if action == 'jstack' :
@@ -2019,7 +2051,7 @@ def mgmt_role_commands(action):
20192051 pprint (api_response )
20202052 except ApiException as e :
20212053 print ('Exception running MgmtRoleCommandsResourceApi->jstack {}\n ' .format (e ))
2022- active_command = action + ' ' + role
2054+ active_command = ' \t ' + action + ' ' + role
20232055 wait_for_active_mgmt_commands (active_command )
20242056
20252057 if action == 'lsof' :
@@ -2032,7 +2064,7 @@ def mgmt_role_commands(action):
20322064 pprint (api_response )
20332065 except ApiException as e :
20342066 print ('Exception running MgmtRoleCommandsResourceApi->lsof {}\n ' .format (e ))
2035- active_command = action + ' ' + role
2067+ active_command = ' \t ' + action + ' ' + role
20362068 wait_for_active_mgmt_commands (active_command )
20372069
20382070
@@ -2094,7 +2126,7 @@ def mgmt_service(action):
20942126 pprint (api_response )
20952127 except ApiException as e :
20962128 print ('Exception calling MgmtServiceResourceApi -> start_command {}\n ' .format (e ))
2097- active_command = 'MGMT ' + action
2129+ active_command = '\t MGMT ' + action
20982130 wait_for_active_mgmt_commands (active_command )
20992131
21002132 if action == 'restart_command' :
@@ -2104,7 +2136,7 @@ def mgmt_service(action):
21042136 pprint (api_response )
21052137 except ApiException as e :
21062138 print ('Exception calling MgmtServiceResourceApi -> restart_command {}\n ' .format (e ))
2107- active_command = 'MGMT ' + action
2139+ active_command = '\t MGMT ' + action
21082140 wait_for_active_mgmt_commands (active_command )
21092141
21102142 if action == 'stop_command' :
@@ -2114,7 +2146,7 @@ def mgmt_service(action):
21142146 pprint (api_response )
21152147 except ApiException as e :
21162148 print ('Exception calling MgmtServiceResourceApi -> stop_command {}\n ' .format (e ))
2117- active_command = 'MGMT ' + action
2149+ active_command = '\t MGMT ' + action
21182150 wait_for_active_mgmt_commands (active_command )
21192151
21202152 if action == 'auto_assign_roles' :
@@ -2124,7 +2156,7 @@ def mgmt_service(action):
21242156 pprint (api_response )
21252157 except ApiException as e :
21262158 print ('Exception calling MgmtServiceResourceApi -> auto_assign_roles {}\n ' .format (e ))
2127- active_command = 'MGMT ' + action
2159+ active_command = '\t MGMT ' + action
21282160 wait_for_active_mgmt_commands (active_command )
21292161
21302162 if action == 'auto_configure_roles' :
@@ -2134,7 +2166,7 @@ def mgmt_service(action):
21342166 pprint (api_response )
21352167 except ApiException as e :
21362168 print ('Exception calling MgmtServiceResourceApi -> auto_configure_roles {}\n ' .format (e ))
2137- active_command = 'MGMT ' + action
2169+ active_command = '\t MGMT ' + action
21382170 wait_for_active_mgmt_commands (active_command )
21392171
21402172 if action == 'delete_cms' :
@@ -2144,7 +2176,7 @@ def mgmt_service(action):
21442176 pprint (api_response )
21452177 except ApiException as e :
21462178 print ('Exception calling MgmtServiceResourceApi -> delete_cms {}\n ' .format (e ))
2147- active_command = 'MGMT ' + action
2179+ active_command = '\t MGMT ' + action
21482180 wait_for_active_mgmt_commands (active_command )
21492181
21502182 if action == 'enter_maintenance_mode' :
@@ -2154,7 +2186,7 @@ def mgmt_service(action):
21542186 pprint (api_response )
21552187 except ApiException as e :
21562188 print ('Exception calling MgmtServiceResourceApi -> enter_maintenance_mode {}\n ' .format (e ))
2157- active_command = 'MGMT ' + action
2189+ active_command = '\t MGMT ' + action
21582190 wait_for_active_mgmt_commands (active_command )
21592191
21602192 if action == 'exit_maintenance_mode' :
@@ -2164,7 +2196,7 @@ def mgmt_service(action):
21642196 pprint (api_response )
21652197 except ApiException as e :
21662198 print ('Exception calling MgmtServiceResourceApi -> exit_maintenance_mode {}\n ' .format (e ))
2167- active_command = 'MGMT ' + action
2199+ active_command = '\t MGMT ' + action
21682200 wait_for_active_mgmt_commands (active_command )
21692201
21702202 if action == 'auto_configure_roles' :
@@ -2174,7 +2206,7 @@ def mgmt_service(action):
21742206 pprint (api_response )
21752207 except ApiException as e :
21762208 print ('Exception calling MgmtServiceResourceApi -> auto_configure {}\n ' .format (e ))
2177- active_command = 'MGMT ' + action
2209+ active_command = '\t MGMT ' + action
21782210 wait_for_active_mgmt_commands (active_command )
21792211
21802212
@@ -2379,10 +2411,12 @@ def update_license():
23792411 """
23802412 try :
23812413 with open (license_file ) as l :
2382- body = l .read ()
2414+ license_data = l .read ()
2415+ body = license_file
23832416 try :
23842417 api_response = cloudera_manager_api .update_license (body = body )
23852418 if debug == 'True' :
2419+ print ('License File Content: \n %s' % license_data )
23862420 pprint (api_response )
23872421 except ApiException as e :
23882422 print ('Exception calling Cloudera Manager Resource API -> update_license {}' .format (e ))
@@ -2392,15 +2426,16 @@ def update_license():
23922426 begin_trial ()
23932427
23942428
2395- def hdfs_enable_nn_ha (nn_hostname , snn_hostname , snn_host_id ):
2429+ def hdfs_enable_nn_ha (snn_host_id ):
23962430 """
23972431 Enable High Availability (HA) with Automatic Failover for an HDFS NameNode.
23982432 :return:
23992433 """
2400- body = cm_client .ApiEnableNnHaArguments (active_nn_name = nn_hostname , standby_nn_name = snn_hostname ,
2401- standby_nn_host_id = snn_host_id )
2434+ body = cm_client .ApiEnableNnHaArguments (active_nn_name = 'HDFS-NAMENODE-1' ,
2435+ standby_nn_host_id = snn_host_id ,
2436+ nameservice = 'HDFS-HA-%s' % cluster_name )
24022437 try :
2403- api_response = services_api .hdfs_enable_nn_ha_command (cluster_name , 'HDFS' , body = body )
2438+ api_response = services_api .hdfs_enable_nn_ha_command (cluster_name = cluster_name , service_name = 'HDFS' , body = body )
24042439 if debug == 'True' :
24052440 pprint (api_response )
24062441 except ApiException as e :
@@ -2512,11 +2547,10 @@ def build_cloudera_cluster():
25122547 install_success = 'False'
25132548 while install_success == 'False' :
25142549 install_hosts ()
2515- active_command = 'Host Agents Installing'
2516- wait_for_active_cluster_commands (active_command )
2550+ wait_for_active_cluster_commands ('Host Agents Installing' )
25172551 print ('->Host Installation Complete' )
25182552 add_hosts_to_cluster (cluster_host_list )
2519- active_command = 'Hosts Adding to Cluster ' + cluster_name
2553+ active_command = '\t Hosts Adding to Cluster ' + cluster_name
25202554 wait_for_active_cluster_commands (active_command )
25212555 if host_install_failure == 'True' :
25222556 print ('->Host SCM Agent Install Failure Detected, trying again' )
@@ -2568,10 +2602,15 @@ def build_cloudera_cluster():
25682602 api_response = clusters_api .first_run (cluster_name )
25692603 if debug == 'True' :
25702604 pprint (api_response )
2605+ active_command = '\t First Run on ' + cluster_name
2606+ wait_for_active_cluster_commands (active_command )
2607+ time .sleep (5 )
25712608 except ApiException as e :
25722609 print ('Exception calling ClustersResourceApi -> first_run {}\n ' .format (e ))
2573- active_command = 'First Run on ' + cluster_name
2574- wait_for_active_cluster_commands (active_command )
2610+ sys .exit ()
2611+ print ('->Enabling HDFS HA' )
2612+ hdfs_enable_nn_ha (snn_host_id )
2613+ wait_for_active_service_commands ('\t Enable HDFS HA' , 'HDFS' )
25752614 if secure_cluster == 'True' :
25762615 pass
25772616 else :
@@ -2586,10 +2625,10 @@ def enable_kerberos():
25862625 :return:
25872626 """
25882627 config_mgmt_for_kerberos ()
2589- wait_for_active_mgmt_commands ('Deploying MGMT Kerberos Configuration' )
2628+ wait_for_active_mgmt_commands ('\t Deploying MGMT Kerberos Configuration' )
25902629 print ('-->Import KDC Admin Credentials' )
25912630 import_admin_credentials ()
2592- wait_for_active_cluster_commands ('Importing KDC Account Management Credentials' )
2631+ wait_for_active_cluster_commands ('\t Importing KDC Account Management Credentials' )
25932632 # Set Service Configurations
25942633 # SOLR
25952634 solr_security_authentication = [cm_client .ApiConfig (name = 'solr_security_authentication' , value = 'kerberos' )]
@@ -2620,21 +2659,21 @@ def enable_kerberos():
26202659 update_service_config (service_name = 'ZOOKEEPER' , api_config_items = quorum_auth_enable_sasl )
26212660 print ('-->Stop Cluster Services' )
26222661 cluster_action ('stop_command' )
2623- wait_for_active_cluster_service_commands ('Stopping Cluster Services' )
2662+ wait_for_active_cluster_service_commands ('\t Stopping Cluster Services' )
26242663 mgmt_service ('stop_command' )
26252664 print ('-->Configure Cluster for Kerberos' )
26262665 configure_for_kerberos ()
2627- wait_for_active_cluster_service_commands ('Configuring for Kerberos' )
2666+ wait_for_active_cluster_service_commands ('\t Configuring for Kerberos' )
26282667 print ('-->Deploy Cluster Kerberos Configuration' )
26292668 cluster_action ('deploy_cluster_client_config' )
2630- wait_for_active_cluster_service_commands ('Deploying Cluster Kerberos Client Config' )
2669+ wait_for_active_cluster_service_commands ('\t Deploying Cluster Kerberos Client Config' )
26312670 print ('-->Start Cluster Services' )
26322671 cluster_action ('start_command' )
2633- wait_for_active_cluster_service_commands ('Starting Cluster Services' )
2672+ wait_for_active_cluster_service_commands ('\t Starting Cluster Services' )
26342673 mgmt_service ('start_command' )
26352674 print ('-->Deploy Client Configuration' )
26362675 cluster_action ('deploy_client_config' )
2637- wait_for_active_cluster_commands ('Deploy Cluster Client Config' )
2676+ wait_for_active_cluster_commands ('\t Deploy Cluster Client Config' )
26382677 if debug == 'True' :
26392678 print ('->Listing Kerberos Principals' )
26402679 get_kerberos_principals ()
@@ -2658,7 +2697,7 @@ def enable_kerberos():
26582697 build_api_endpoints (admin_user_name , admin_password )
26592698 print ('-->Stop Cluster Services' )
26602699 cluster_action ('stop_command' )
2661- wait_for_active_cluster_service_commands ('Stopping Cluster Services' )
2700+ wait_for_active_cluster_service_commands ('\t Stopping Cluster Services' )
26622701 delete_cluster ()
26632702 print ('%s Delete issued' % cluster_name )
26642703 exit (0 )
@@ -2714,7 +2753,6 @@ def enable_kerberos():
27142753 pprint (cluster_host_list )
27152754 print ('->Full Deployment Follows' )
27162755 get_deployment_full ()
2717-
27182756 else :
27192757 print ('Cluster Check returned null: %s' % cluster_exists )
27202758 else :
0 commit comments