/*************************************************************************** * Copyright (c) 2012-2015 VMware, Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ***************************************************************************/ package com.vmware.bdd.service.job; import org.apache.log4j.Logger; import org.springframework.batch.core.scope.context.ChunkContext; import org.springframework.batch.repeat.RepeatStatus; import com.vmware.bdd.entity.NodeEntity; import com.vmware.bdd.exception.TaskException; import com.vmware.bdd.manager.ClusterConfigManager; import com.vmware.bdd.service.impl.ClusterLdapUserMgmtCfgService; public class EnableLdapForDiskFixStep extends TrackableTasklet { private static final Logger logger = Logger.getLogger(EnableLdapForDiskFixStep.class); private ClusterLdapUserMgmtCfgService clusterLdapUserMgmtCfgService; private ClusterConfigManager configMgr; @Override public RepeatStatus executeStep(ChunkContext chunkContext, JobExecutionStatusHolder jobExecutionStatusHolder) { logger.info("Enable LDAP for disk fix"); String clusterName = getJobParameters(chunkContext).getString(JobConstants.CLUSTER_NAME_JOB_PARAM); String targetNode = getJobParameters(chunkContext).getString(JobConstants.SUB_JOB_NODE_NAME); NodeEntity nodeEntity = clusterEntityMgr.findNodeByName(targetNode); if (nodeEntity == null) { throw TaskException.EXECUTION_FAILED("No fixed node need to enable password."); } clusterLdapUserMgmtCfgService.configureUserMgmt(clusterName, nodeEntity); putIntoJobExecutionContext(chunkContext, "Enable LDAP successfully", true); return RepeatStatus.FINISHED; } public ClusterConfigManager getConfigMgr() { return configMgr; } public void setConfigMgr(ClusterConfigManager configMgr) { this.configMgr = configMgr; } public void setClusterLdapUserMgmtCfgService(ClusterLdapUserMgmtCfgService clusterLdapUserMgmtCfgService) { this.clusterLdapUserMgmtCfgService = clusterLdapUserMgmtCfgService; } }