cm_api = cm_client.ClouderaManagerResourceApi(api_client) # accept trial licence cm_api.begin_trial() # Install CM Agent on host with open("/root/myRSAkey", "r") as f: key = f.read() instargs = cm_client.ApiHostInstallArguments( host_names=[ '10.3.0.4', '10.3.0.5', '10.3.0.6', '10.3.0.7', '10.3.0.9', '10.3.0.10', '10.3.0.11', '10.3.0.12', '10.3.0.13', '10.3.0.14' ], user_name='utilisateur', password='******', cm_repo_url='https://archive.cloudera.com/cm6/6.3.1', java_install_strategy='NONE', ssh_port=22, passphrase='') cmd = cm_api.host_install_command(body=instargs) wait(cmd) # create MGMT/CMS mgmt_api = cm_client.MgmtServiceResourceApi(api_client) api_service = cm_client.ApiService() api_service.roles = [ cm_client.ApiRole(type='SERVICEMONITOR'),
cm_client.configuration.password = '******' api_client = cm_client.ApiClient("http://localhost:7180/api/v32") cm_api = cm_client.ClouderaManagerResourceApi(api_client) # accept trial licence cm_api.begin_trial() # Install CM Agent on host with open("/root/myRSAkey", "r") as f: key = f.read() instargs = cm_client.ApiHostInstallArguments( host_names=['YourHostname'], user_name='root', private_key=key, cm_repo_url='https://archive.cloudera.com/cm6/6.3.0', java_install_strategy='NONE', ssh_port=22, passphrase='') cmd = cm_api.host_install_command(body=instargs) wait(cmd) # Configure Hosts with property needed by SMM host_api = cm_client.AllHostsResourceApi(api_client) message = 'updating CM Agent safety valve for SMM' body = cm_client.ApiConfigList( ) # ApiConfigList | Configuration changes. (optional) body.items = [ cm_client.ApiConfig(
def create_cluster(self): # accept trial licence try: self.cm_api.begin_trial() except ApiException as exc: if exc.status == 400 and 'Trial has been used' in exc.body: pass # This can be ignored else: raise # Install CM Agent on host with open(self.key_file, "r") as f: key = f.read() self._import_paywall_credentials() instargs = cm_client.ApiHostInstallArguments( host_names=[self.host], user_name='root', private_key=key, cm_repo_url=self.cm_repo_url, java_install_strategy='NONE', ssh_port=22, passphrase='') cmd = self.cm_api.host_install_command(body=instargs) cmd = self.wait(cmd) if not cmd.success: raise RuntimeError('Failed to add host to the cluster') # create MGMT/CMS api_service = cm_client.ApiService() api_service.roles = [ cm_client.ApiRole(type='SERVICEMONITOR'), cm_client.ApiRole(type='HOSTMONITOR'), cm_client.ApiRole(type='EVENTSERVER'), cm_client.ApiRole(type='ALERTPUBLISHER') ] self.mgmt_api.auto_assign_roles() # needed? self.mgmt_api.auto_configure() # needed? self.mgmt_api.setup_cms(body=api_service) cmd = self.mgmt_api.start_command() cmd = self.wait(cmd) if not cmd.success: raise RuntimeError('Failed to start Management Services') # Update host-level parameter required by SMM self.all_hosts_api.update_config( message='Updating parameter for SMM', body=cm_client.ApiConfigList([ cm_client.ApiConfig( name='host_agent_safety_valve', value= 'kafka_broker_topic_partition_metrics_for_smm_enabled=true' ) ])) # create the cluster using the template with open(self.template) as f: json_str = f.read() Response = namedtuple("Response", "data") dst_cluster_template = self.api_client.deserialize( response=Response(json_str), response_type=cm_client.ApiClusterTemplate) cmd = self.cm_api.import_cluster_template(add_repositories=True, body=dst_cluster_template) cmd = self.wait(cmd) if not cmd.success: raise RuntimeError('Failed to deploy cluster template') # All parcel downloads should've already been done at this point, so we can safely remove the paywall credentials self._reset_paywall_credentials() if self.use_kerberos: self._enable_kerberos()
api_client = cm_client.ApiClient("http://*****:*****@archive.cloudera.com/p/cm7/7.x.0/' % (sys.argv[2], sys.argv[3])), java_install_strategy='NONE', ssh_port=22, passphrase='') cmd = cm_api.host_install_command(body=instargs) wait(cmd) # create MGMT/CMS mgmt_api = cm_client.MgmtServiceResourceApi(api_client) api_service = cm_client.ApiService() api_service.roles = [ cm_client.ApiRole(type='SERVICEMONITOR'), cm_client.ApiRole(type='HOSTMONITOR'),
cm_client.configuration.password = '******' api_client = cm_client.ApiClient("http://localhost:7180/api/v40") cm_api = cm_client.ClouderaManagerResourceApi(api_client) # accept trial licence cm_api.begin_trial() # Install CM Agent on host with open("/root/myRSAkey", "r") as f: key = f.read() instargs = cm_client.ApiHostInstallArguments( host_names=['ip-10-0-1-248.ap-southeast-1.compute.internal'], user_name='root', private_key=key, cm_repo_url='https://archive.cloudera.com/cm7/7.1.1/', java_install_strategy='NONE', ssh_port=22, passphrase='') cmd = cm_api.host_install_command(body=instargs) wait(cmd) # create MGMT/CMS mgmt_api = cm_client.MgmtServiceResourceApi(api_client) api_service = cm_client.ApiService() api_service.roles = [ cm_client.ApiRole(type='SERVICEMONITOR'), cm_client.ApiRole(type='HOSTMONITOR'), cm_client.ApiRole(type='EVENTSERVER'),
api_client = cm_client.ApiClient("http://localhost:7180/api/v32") cm_api = cm_client.ClouderaManagerResourceApi(api_client) # accept trial licence cm_api.begin_trial() # Install CM Agent on host with open (KEY_FILE, "r") as f: key = f.read() instargs = cm_client.ApiHostInstallArguments(host_names=[HOST], user_name='root', private_key=key, cm_repo_url=CM_REPO_URL, java_install_strategy='NONE', ssh_port=22, passphrase='') cmd = cm_api.host_install_command(body=instargs) cmd = wait(cmd) if not cmd.success: raise RuntimeError('Failed to add host to the cluster') # create MGMT/CMS mgmt_api = cm_client.MgmtServiceResourceApi(api_client) api_service = cm_client.ApiService() api_service.roles = [cm_client.ApiRole(type='SERVICEMONITOR'), cm_client.ApiRole(type='HOSTMONITOR'),
def setup_cm(self, key_file, cm_repo_url, use_kerberos, use_tls, kerberos_type, ipa_host): # Accept trial licence try: self.cm_api.begin_trial() except ApiException as exc: if exc.status == 400 and 'Trial has been used' in exc.body: pass # This can be ignored else: raise # Install CM Agent on host with open(key_file, "r") as f: key = f.read() if self.host not in [ h.hostname for h in self.hosts_api.read_hosts().items ]: instargs = cm_client.ApiHostInstallArguments( host_names=[self.host], user_name='root', private_key=key, cm_repo_url=cm_repo_url, java_install_strategy='NONE', ssh_port=22, passphrase='') cmd = self.cm_api.host_install_command(body=instargs) cmd = self.wait(cmd) if not cmd.success: raise RuntimeError('Failed to add host to the cluster') # Create MGMT/CMS try: self.mgmt_api.read_service() print("Cloudera Management Services already installed") cms_exists = True except cm_client.rest.ApiException as e: cms_exists = False if not cms_exists: print("Installing Cloudera Management Services") api_service = cm_client.ApiService() api_service.roles = [ cm_client.ApiRole(type='SERVICEMONITOR'), cm_client.ApiRole(type='HOSTMONITOR'), cm_client.ApiRole(type='EVENTSERVER'), cm_client.ApiRole(type='ALERTPUBLISHER') ] self.mgmt_api.setup_cms(body=api_service) cmd = self.mgmt_api.start_command() cmd = self.wait(cmd) if not cmd.success: raise RuntimeError('Failed to start Management Services') # Update cluster banner c_id = cluster_id() banner = 'Cluster ID: {}, Host: {}'.format(c_id, socket.gethostname()) header_color = HEADER_COLORS[c_id % len(HEADER_COLORS)] self.cm_api.update_config( message='Customizing CM header and banner', body=cm_client.ApiConfigList([ cm_client.ApiConfig(name='CUSTOM_BANNER_HTML', value=banner), cm_client.ApiConfig(name='CUSTOM_HEADER_COLOR', value=header_color), ])) # Update host-level parameter required by SMM self.all_hosts_api.update_config( message='Updating parameter for SMM', body=cm_client.ApiConfigList([ cm_client.ApiConfig( name='host_agent_safety_valve', value= 'kafka_broker_topic_partition_metrics_for_smm_enabled=true' ) ])) # Enable kerberos if use_kerberos: self._enable_kerberos(kerberos_type, ipa_host) # Enable TLS if use_tls: self._enable_tls() # Restart Mgmt Services cmd = self.mgmt_api.restart_command() cmd = self.wait(cmd)