public ResourcePoolRead get(String id) { id = CommonUtil.encode(id); final String path = Constants.REST_PATH_RESOURCEPOOL; final HttpMethod httpverb = HttpMethod.GET; return restClient.getObject(id, ResourcePoolRead.class, path, httpverb, false); }
private List<NodeEntity> getNodesToBeSetLocalRepo(ChunkContext chunkContext, String clusterName) throws TaskException { List<NodeEntity> toBeSetLocalRepo = null; if ((managementOperation == ManagementOperation.CREATE) || (managementOperation == ManagementOperation.RESUME)) { toBeSetLocalRepo = getClusterEntityMgr().findAllNodes(clusterName); return toBeSetLocalRepo; } else if (managementOperation == ManagementOperation.RESIZE) { String groupName = getJobParameters(chunkContext).getString(JobConstants.GROUP_NAME_JOB_PARAM); List<NodeEntity> nodesInGroup = clusterEntityMgr.findAllNodes(clusterName, groupName); long oldInstanceNum = getJobParameters(chunkContext).getLong(JobConstants.GROUP_INSTANCE_OLD_NUMBER_JOB_PARAM); for (NodeEntity node : nodesInGroup) { long index = CommonUtil.getVmIndex(node.getVmName()); if (index < oldInstanceNum) { // do not verify existing nodes from last successful deployment continue; } if (node.getStatus().ordinal() >= NodeStatus.VM_READY.ordinal()) { if (toBeSetLocalRepo == null) { toBeSetLocalRepo = new ArrayList<NodeEntity>(); } toBeSetLocalRepo.add(node); } } return toBeSetLocalRepo; } else { throw TaskException.EXECUTION_FAILED("Unknown operation type."); } }
public void delete(String id) { id = CommonUtil.encode(id); final String path = Constants.REST_PATH_RESOURCEPOOL; final HttpMethod httpverb = HttpMethod.DELETE; restClient.deleteObject(id, path, httpverb); }
@Override public RepeatStatus executeStep( ChunkContext chunkContext, JobExecutionStatusHolder jobExecutionStatusHolder) throws Exception { // This step is only for app manager like ClouderaMgr and Ambari String clusterName = getJobParameters(chunkContext).getString(JobConstants.CLUSTER_NAME_JOB_PARAM); SoftwareManager softwareMgr = softwareMgrs.getSoftwareManagerByClusterName(clusterName); String appMgrName = softwareMgr.getName(); if (Constants.IRONFAN.equals(appMgrName)) { // we do not config any local repo for Ironfan return RepeatStatus.FINISHED; } ClusterCreate clusterConfig = clusterManager.getClusterConfigMgr().getClusterConfig(clusterName); String localRepoURL = clusterConfig.getLocalRepoURL(); logger.info("Use the following URL as the local yum server:" + localRepoURL); if (!CommonUtil.isBlank(localRepoURL)) { // Setup local repo file on each node for ClouderaMgr/Ambari. logger.info( "ConfigLocalRepoStep: start to setup local repo on each node for ClouderaMgr/Ambari."); List<NodeEntity> nodes = getNodesToBeSetLocalRepo(chunkContext, clusterName); String appMgrRepoID = Configuration.getString( Constants.SERENGETI_NODE_YUM_CLOUDERA_MANAGER_REPO_ID, Constants.NODE_APPMANAGER_YUM_CLOUDERA_MANAGER_REPO_ID); if (appMgrName.equals(Constants.AMBARI_PLUGIN_TYPE)) { appMgrRepoID = Configuration.getString( Constants.SERENGETI_NODE_YUM_AMBARI_REPO_ID, Constants.NODE_APPMANAGER_YUM_AMBARI_REPO_ID); } setLocalRepoService.setLocalRepoForNodes(clusterName, nodes, appMgrRepoID, localRepoURL); } return RepeatStatus.FINISHED; }