package com.bocloud.ims.service.resource;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.bocloud.cmp.entity.enums.YumRepoOperate;
import com.bocloud.cmp.entity.enums.YumRepoType;
import com.bocloud.cmp.model.NotifyMessage;
import com.bocloud.common.encrypt.AESEncrptor;
import com.bocloud.common.enums.BoCloudMethod;
import com.bocloud.common.enums.BoCloudService;
import com.bocloud.common.enums.OSCategory;
import com.bocloud.common.enums.PostDataFormat;
import com.bocloud.common.model.BocloudResult;
import com.bocloud.common.model.BocloudToken;
import com.bocloud.common.model.OperateResult;
import com.bocloud.common.model.OperateResult.OperateCategory;
import com.bocloud.common.model.RequestContext;
import com.bocloud.common.model.RequestContext.Catalog;
import com.bocloud.common.utils.IDFactory;
import com.bocloud.common.utils.JSONTools;
import com.bocloud.common.utils.MapTools;
import com.bocloud.ims.common.config.ImageServiceConfig;
import com.bocloud.ims.common.config.YumRepoConfig;
import com.bocloud.ims.common.utils.constant.Constant;
import com.bocloud.ims.entity.resource.CloudServer;
import com.bocloud.ims.entity.resource.Resource;
import com.bocloud.ims.entity.resource.Server;
import com.bocloud.ims.entity.resource.YumRepo;
import com.bocloud.ims.interfaces.resource.YumRepoService;
import com.bocloud.ims.repository.resource.ResourceRepository;
import com.bocloud.ims.repository.resource.YumRepoRepository;
import com.bocloud.ims.service.internal.worker.HostResult;
import com.bocloud.ims.service.internal.worker.Module;
import com.bocloud.ims.service.internal.worker.RemoteWorker;
import com.bocloud.ims.service.internal.worker.WorkerHost;
import com.bocloud.ims.service.utils.ResourceEventPublisher;
import com.bocloud.service.core.CurrentService;
import com.bocloud.service.http.core.ServiceFactory;
import com.bocloud.service.http.model.RemoteService;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;

import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * yum源管理实现
 *
 * @author lkx007
 */
@Service("yumRepoService")
public class YumRepoServiceImpl implements YumRepoService {

	private static final String JOB_SUBMIT_URL = "/v1/tasks/execute";
	private Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private RabbitAdmin rabbitAdmin;
	@Autowired
	private AmqpTemplate amqpTemplate;
	@Autowired
	private ServiceFactory serviceFactory;
	@Autowired
	private CurrentService currentService;
	@Autowired
	private YumRepoRepository yumRepoRepository;
	@Autowired
	private YumRepoConfig yumRepoConfig;
	@Autowired
	private ImageServiceConfig imageServiceConfig;
	@Autowired
	private ResourceEventPublisher resourceEventPublisher;
	@Autowired
	private ResourceRepository resourceRepository;
	@Autowired
	private ThreadPoolTaskExecutor taskExecutor;

	/**
	 * 根据操作类型组装请求worker的参数，并请求worker
	 *
	 * @param operate
	 * @param repo
	 * @param userId
	 * @throws Exception
	 */
	private void requestWorker(YumRepoOperate operate, YumRepo repo, Long userId) throws Exception {
		Map<String, Object> headers = MapTools.simpleMap("Content-Type", "application/json");
		headers.put(BocloudToken.INTERNAL_TOKEN, currentService.getToken());
		RemoteService remoteService = serviceFactory.build(BoCloudService.COP, JOB_SUBMIT_URL, BoCloudMethod.OPERATE,
				headers, null);

		Module<JSONObject> module = new Module<JSONObject>();
		JSONObject args = new JSONObject();
		List<JSONObject> targets = Lists.newArrayList();
		switch (operate) {
		case CREATE:
			// 使用cmp的源进行private源的配置,所以baseurl为cmp默认源的地址
			args.put("baseurl", yumRepoConfig.getCmpRepo());
			args.put("repoPath", repo.getRepoPath());
			args.put("server", true);
			args.put("name", repo.getName());
			args.put("file", repo.getFile());
			module.setArgs(args);
			module.setName("install_yum");
			targets.add(repo.getTarget());
			break;
		case UPDATE:
			// 使用cmp的源进行private源的更新,所以baseurl为cmp默认源的地址
			args.put("baseurl", yumRepoConfig.getCmpRepo());
			args.put("repoPath", repo.getRepoPath());
			args.put("server", true);
			args.put("name", repo.getName());
			module.setArgs(args);
			module.setName("install_yum");
			targets.add(JSONObject.parseObject(repo.getServerInfo(), JSONObject.class));
			break;
		case DELETE:
			args.put("repoPath", repo.getRepoPath());
			args.put("server", true);
			args.put("name", repo.getName());
			args.put("file", repo.getFile());
			module.setArgs(args);
			module.setName("remove_yum");
			targets.add(JSONObject.parseObject(repo.getServerInfo(), JSONObject.class));
			break;
		case CONFIGURE:
			// baseurl为前端传的指定的yum源的地址
			// baseurl,mirrorlist,metalink三选一设置
			if (null != repo.getBaseurl()) {
				args.put("baseurl", repo.getBaseurl());
			}
			if (null != repo.getMirrorlist()) {
				args.put("mirrorlist", repo.getMirrorlist());
			}
			if (null != repo.getMetalink()) {
				args.put("metalink", repo.getMetalink());
			}
			if (null != repo.getGpgcheck()) {
				if (1 == repo.getGpgcheck()) {
					args.put("gpgcheck", true);
					args.put("gpgkey", repo.getGpgkey());
				} else if (0 == repo.getGpgcheck()) {
					args.put("gpgcheck", false);
				}
			}
			args.put("failovermethod", repo.getFailovermethod());
			args.put("clean", repo.getClean());
			args.put("server", false);
			args.put("name", repo.getName());
			args.put("description", repo.getDescription());
			args.put("file", repo.getFile());
			module.setArgs(args);
			module.setName("install_yum");
			targets.addAll(repo.getTargets());
			break;
		default:
			logger.error("不支持的操作类型" + operate.name());
			return;
		}

		
		JSONObject paramObject = new JSONObject();
		paramObject.put("targets", targets);
		paramObject.put("queue", IDFactory.instance().uuid());
		paramObject.put("timeout", 10000);
		paramObject.put("module", module);
		JSONObject oldParams = null;
        if(null == remoteService.getParam().getParams()) {
        	oldParams = new JSONObject();
        }else {
        	oldParams = JSONObject.parseObject(JSONObject.toJSONString(remoteService.getParam().getParams()));
        }
		if (oldParams.keySet().size() > 0) {
			paramObject.putAll(oldParams);
		}
		remoteService.getParam().setParams(paramObject );
		remoteService.setDataFormat(PostDataFormat.RAW);

		RemoteWorker remoteWorker = new RemoteWorker(remoteService, rabbitAdmin, 1000 * 5, "", false);

		Future<BocloudResult> workerTask = taskExecutor.submit(remoteWorker);

		taskExecutor.submit(() -> {
			try {
				BocloudResult workerResult = workerTask.get();
				logger.info("worker result:{}", JSON.toJSONString(workerResult));

				String subject = "yum源任务执行结果";
				StringBuilder sb = new StringBuilder();

				if (workerResult.isSuccess()) {
					// send message to web
					switch (operate) {
					case CREATE:
						// 创建成功,保存到数据库
						repo.setType(YumRepoType.PRIVATE.name());
						File file = new File(repo.getRepoPath());
						repo.setBaseurl("http://" + repo.getTarget().getString("host") + "/" + file.getName());
						repo.setServerInfo(JSON.toJSONString(repo.getTarget()));
						yumRepoRepository.baseSave(repo);
						sb.append("创建yum源[").append(repo.getName()).append("]任务执行成功");
						break;
					case DELETE:
						yumRepoRepository.delete(YumRepo.class, repo.getId());
						sb.append("删除私有yum源[").append(repo.getName()).append("]任务执行成功");
						break;
					case UPDATE:
						// 更新数据库信息
						File updateFile = new File(repo.getRepoPath());
						repo.setBaseurl("http://" + repo.getTarget().getString("host") + "/" + updateFile.getName());
						repo.setServerInfo(JSON.toJSONString(repo.getTarget()));
						yumRepoRepository.baseUpdate(repo);
						sb.append("更新私有yum源[").append(repo.getName()).append("]任务执行成功");
						break;
					case CONFIGURE:
						sb.append("为目标机器[");
						for (JSONObject target : repo.getTargets()) {
							sb.append("名称: ").append(target.getString("name")).append(", ").append("ip: ")
									.append(target.getString("host")).append("; ");
						}
						sb.append("]").append("添加yum源[").append(repo.getName()).append("]任务执行成功");
						break;
					default:
						logger.error("不支持的操作类型" + operate.name());
						return;
					}
				} else {
					sb.append("worker任务执行失败:").append(getError(workerResult, operate));
				}

				// 发送站内信
				RequestContext context = new RequestContext(Catalog.Manager, userId, null, null, null);
				NotifyMessage message = new NotifyMessage(context, subject, sb.toString(), true, false);
				amqpTemplate.convertAndSend(Constant.MESSAGE_QUEUE_ROUTINGKEY, message);
				// 发送界面消息
				OperateResult result = new OperateResult(workerResult.isSuccess(), sb.toString(), "yum.operate", null,
						OperateCategory.TaskResult, context);
				resourceEventPublisher.send(result);
			} catch (InterruptedException e) {
				logger.error("InterruptedException:", e);
				Thread.currentThread().interrupt();
			} catch (ExecutionException e) {
				logger.error("ExecutionException:", e);
			} catch (Exception e) {
				logger.error("Exception:", e);
			}
		});
	}

	private String getError(BocloudResult workerResult, YumRepoOperate operate) {
		try {
			String prefix;
			switch (operate) {
			case CREATE:
				prefix = "为目标机器%s新增私有yum源";
				break;
			case DELETE:
				prefix = "为目标机器%s删除私有yum源";
				break;
			case UPDATE:
				prefix = "为目标机器%s更新私有yum源";
				break;
			case CONFIGURE:
				prefix = "为目标机器%s配置yum源";
				break;
			default:
				return "不支持的操作类型" + operate.name();
			}
			if (workerResult.getData() instanceof String) {
				// {"data":"Exceed the max try times 3, Failure the job","failed":true,
				// "message":"Failed operate job
				// 1d0b3adf1ca9482d9d1135aa25eca224","success":false}
				return "worker执行异常";
			}
			StringBuilder sb = new StringBuilder();
			List<HostResult> results = JSONObject.parseArray(JSON.toJSONString(workerResult.getData()),
					HostResult.class);
			for (HostResult result : results) {
				if (result.isSuccess()) {
					sb.append(String.format(prefix, result.getHost())).append("成功.\n");
				} else {
					sb.append(String.format(prefix, result.getHost())).append("失败: ");
					sb.append("task [").append(result.getTask()).append("] execute fail!");
					JSONObject object = JSONTools.isJSONObj(result.getMessage());
					if (object != null) {
						// worker执行失败，优先返回stderr
						String stderr = object.getString("stderr");
						if (null != stderr) {
							sb.append(stderr);
						} else {
							// worker执行失败，stderr里面没有信息才去获取msg返回
							if (null != object.getString("msg")) {
								sb.append(object.getString("msg"));
							}
						}
						sb.append("\n");
					} else {
						sb.append(result.getMessage()).append("\n");
					}
				}
			}
			return sb.toString();
		} catch (Exception e) {
			logger.error("worker返回数据{}格式错误:", workerResult, e);
			return "worker返回数据格式错误";
		}
	}
	
	public static void main(String[] args) {
		System.out.println(new AESEncrptor().decrypt("Dr9x8l+EEceLwCvSaT2QWg==", null));
	}

	@Override
	public BocloudResult create(YumRepo repo, Long userId) {
		try {
			// ISO的源保存数据到数据库
			if (YumRepoType.ISO.name().equalsIgnoreCase(repo.getType())) {
				repo.setBaseurl("http://" + imageServiceConfig.getIp() + ":" + imageServiceConfig.getSouthPort() + "/"
						+ repo.getOsType() + "/" + repo.getOsVersion());
			}

			// 私有源调用worker创建
			if (YumRepoType.PRIVATE.name().equalsIgnoreCase(repo.getType())) {
				BocloudResult check = check(repo.getTarget(), YumRepoOperate.CREATE);
				if (check.isFailed()) {
					logger.warn("创建私有yum源[{}]任务下发失败: {}", repo.getName(), check.getMessage());
					return new BocloudResult(false, "创建私有yum源[" + repo.getName() + "]任务下发失败: " + check.getMessage());
				}
				repo.setTarget((JSONObject) check.getData());
				requestWorker(YumRepoOperate.CREATE, repo, userId);
				return new BocloudResult(true, "创建私有yum源[" + repo.getName() + "]任务下发成功，正在执行");
			}
			// 公有源保存到数据库即可
			repo.setServerInfo(JSON.toJSONString(repo.getTarget()));
			repo.setType(repo.getType().toUpperCase());
			yumRepoRepository.baseSave(repo);
			return new BocloudResult(true, "创建yum源[" + repo.getName() + "]成功");
		} catch (Exception e) {
			logger.error("创建yum源失败：", e);
			return new BocloudResult(false, "创建yum源异常");
		}
	}

	@Override
	public BocloudResult list(String name, String type) {
		try {
			// 私有源、共有源、ISO源查询数据库
			List<YumRepo> repos = yumRepoRepository.list();

			// 处理公有源源地址不显示的问题
			repos.stream().filter(repo -> YumRepoType.PUBLIC.name().equalsIgnoreCase(repo.getType()) && (repo.getBaseurl() == null || "".equals(repo.getBaseurl())))
					.forEach(yumRepo -> yumRepo.setBaseurl(yumRepo.getMetalink() == null || "".equals(yumRepo.getMetalink()) ? yumRepo.getMirrorlist() : yumRepo.getMetalink()));

			// CMP自带默认yum源
			YumRepo defaultRepo = new YumRepo();
			defaultRepo.setBaseurl(yumRepoConfig.getCmpRepo());
			defaultRepo.setDescription("this is cmp default yum repo");
			defaultRepo.setName("cmp");
			defaultRepo.setFile("cmp");
			defaultRepo.setType(YumRepoType.PRIVATE.name());
			WorkerHost defaultHost = new WorkerHost(new URL(yumRepoConfig.getCmpRepo()).getHost(), "root", null, 22,
					OSCategory.LINUX);
			defaultRepo.setServerInfo(JSONObject.toJSONString(defaultHost));
			repos.add(defaultRepo);

			// 根据name和type过滤
			List<YumRepo> newRepo = Lists.newArrayList();
			if (name != null) {
				if (type != null) {
					for (YumRepo repo : repos) {
						if (repo.getName().contains(name) && repo.getType().equalsIgnoreCase(type)) {
							newRepo.add(repo);
						}
					}
					return new BocloudResult(true, newRepo, "查询yum源成功");
				} else {
					for (YumRepo repo : repos) {
						if (repo.getName().contains(name)) {
							newRepo.add(repo);
						}
					}
					return new BocloudResult(true, newRepo, "查询yum源成功");
				}
			} else {
				if (type != null) {
					for (YumRepo repo : repos) {
						if (repo.getType().equalsIgnoreCase(type)) {
							newRepo.add(repo);
						}
					}
					return new BocloudResult(true, newRepo, "查询yum源成功");
				} else {
					return new BocloudResult(true, repos, "查询yum源成功");
				}
			}
		} catch (Exception e) {
			logger.error("查询yum源失败：", e);
			return new BocloudResult(false, "查询yum源异常");
		}
	}

	@Override
	public BocloudResult delete(String name, Long userId) {
		try {
			// 默认cmp源不让删除
			if ("cmp".equalsIgnoreCase(name)) {
				logger.warn("cmp默认yum源不让删除");
				return new BocloudResult(false, "cmp默认yum源不让删除");
			}
			YumRepo repo = yumRepoRepository.query(name);
			if (repo == null) {
				logger.warn("yum源{}不存在", name);
				return new BocloudResult(true, "yum源[" + name + "]已经不存在");
			}

			// 调用worker删除私有yum源
			if (YumRepoType.PRIVATE.name().equalsIgnoreCase(repo.getType())) {
				BocloudResult check = check(JSON.parseObject(repo.getServerInfo()), YumRepoOperate.DELETE);
				if (check.isFailed()) {
					logger.warn("删除私有yum源[{}]任务下发失败: {}", repo.getName(), check.getMessage());
					return new BocloudResult(false, "删除私有yum源[" + repo.getName() + "]任务下发失败: " + check.getMessage());
				}
				requestWorker(YumRepoOperate.DELETE, repo, userId);
				return new BocloudResult(true, "删除私有yum源[" + name + "]任务下发成功，正在执行");
			}
			// 删除数据库中的yum源
			yumRepoRepository.delete(YumRepo.class, repo.getId());
			return new BocloudResult(true, "删除yum源[" + name + "]成功");
		} catch (Exception e) {
			logger.error("删除yum源失败：", e);
			return new BocloudResult(false, "删除yum源异常");
		}
	}

	@Override
	public BocloudResult modify(YumRepo repo, Long userId) {
		try {
			YumRepo dbRepo = yumRepoRepository.query(repo.getName());
			if (dbRepo == null) {
				logger.warn("修改失败，yum源[{}]已经被删除", repo.getName());
				return new BocloudResult(false, "yum源[" + repo.getName() + "]已经被删除");
			}
			dbRepo.setBaseurl(repo.getBaseurl());
			dbRepo.setDescription(repo.getDescription());
			dbRepo.setMirrorlist(repo.getMirrorlist());
			dbRepo.setGpgcheck(repo.getGpgcheck());
			dbRepo.setMetalink(repo.getMetalink());
			dbRepo.setGpgkey(repo.getGpgkey());
			dbRepo.setFailovermethod(repo.getFailovermethod());
			dbRepo.setRepoPath(repo.getRepoPath());
			dbRepo.setFile(repo.getFile());
			dbRepo.setTarget(null == repo.getTarget() ? JSONObject.parseObject(dbRepo.getServerInfo(), JSONObject.class)
					: repo.getTarget());
			// 私有yum调用worker去更新
			if (YumRepoType.PRIVATE.name().equalsIgnoreCase(dbRepo.getType())) {
				BocloudResult check = check(repo.getTarget(), YumRepoOperate.UPDATE);
				if (check.isFailed()) {
					logger.warn("更新私有yum源[{}]任务下发失败:{}", repo.getName(), check.getMessage());
					return new BocloudResult(false, "更新9 私有yum源[" + repo.getName() + "]任务下发失败: " + check.getMessage());
				}
				// 调用worker更新私有repo
				// 不支持修改源的文件名称
				requestWorker(YumRepoOperate.UPDATE, dbRepo, userId);
				return new BocloudResult(true, "更新私有yum源[" + dbRepo.getName() + "]任务下发成功，正在执行");
			}
			// ISO的源更新数据到数据库
			if (YumRepoType.ISO.name().equalsIgnoreCase(dbRepo.getType())) {
				dbRepo.setBaseurl("http://" + imageServiceConfig.getIp() + ":" + imageServiceConfig.getSouthPort() + "/"
						+ repo.getOsType() + "/" + repo.getOsVersion());
				dbRepo.setImageId(repo.getImageId());
			}
			// 更新数据库信息
			yumRepoRepository.baseUpdate(dbRepo);
			return new BocloudResult(true, "更新yum源[" + repo.getName() + "]成功");
		} catch (Exception e) {
			logger.error("修改yum源失败：", e);
			return new BocloudResult(false, "修改yum源异常");
		}
	}

	private BocloudResult check(JSONObject target, YumRepoOperate operate) {
		String suffix;
		switch (operate) {
		case CREATE:
			suffix = ", 不支持新增yum源\n";
			break;
		case DELETE:
			suffix = ", 不支持删除yum源\n";
			break;
		case UPDATE:
			suffix = ", 不支持更新yum源\n";
			break;
		case CONFIGURE:
			suffix = ", 不支持配置yum源\n";
			break;
		default:
			return new BocloudResult(false, "不支持的操作类型" + operate.name());
		}
		StringBuilder sb = new StringBuilder();
		Resource resource = resourceRepository.query(target.getLongValue("resourceId"));
		if (null == resource) {
			sb.append("获取所选机器[").append(target.getString("name")).append("]资源详情失败:数据为空").append(suffix);
		} else {
			logger.info(JSON.toJSONString(target, SerializerFeature.PrettyFormat));
			String name = target.getString("name") == null ? resource.getName() : target.getString("name");
			if ("linux".equalsIgnoreCase(resource.getOsCategory())
					&& "RUNNING".equalsIgnoreCase(resource.getStatus())) {
				if ("PHYSICAL".equalsIgnoreCase(resource.getCatalog())) {
					Server server = JSONObject.parseObject(resource.getInventory(), Server.class);
					if (server.getConfig().getOsName().trim().replaceAll(" ", "").toLowerCase().contains("centos")
							|| server.getConfig().getOsName().trim().replaceAll(" ", "").toLowerCase()
									.contains("redhat")) {
						if ("RUNNING".equalsIgnoreCase(server.getPowerState())) {
							return new BocloudResult(true, target, "check ok");
						} else {
							sb.append("所选机器[").append(name).append("]系统状态为").append(server.getPowerState())
									.append(suffix);
						}
					} else {
						sb.append("所选机器[").append(name).append("]系统类型为").append(server.getConfig().getOsName())
								.append(suffix);
					}
				} else if ("LOGICAL".equalsIgnoreCase(resource.getCatalog())) {
					CloudServer cloudServer = JSONObject.parseObject(resource.getInventory(), CloudServer.class);
					if (cloudServer.getOsName().toLowerCase().trim().replaceAll(" ", "").contains("centos")
							|| cloudServer.getOsName().toLowerCase().trim().replaceAll(" ", "").contains("redhat")) {
						if ("RUNNING".equalsIgnoreCase(cloudServer.getStatus())) {
							return new BocloudResult(true, target, "check ok");
						} else {
							sb.append("所选机器[").append(name).append("]系统状态为").append(cloudServer.getStatus())
									.append(suffix);
						}
					} else {
						sb.append("所选机器[").append(name).append("]系统类型为").append(cloudServer.getOsName()).append(suffix);
					}
				} else {
					sb.append("所选机器[").append(name).append("]catalog类型为").append(resource.getCatalog()).append(suffix);
				}
			} else {
				sb.append("所选机器[").append(name).append("]系统类型为").append(resource.getOsCategory()).append(suffix);
			}
		}
		return new BocloudResult(false, sb.toString());
	}

	@Override
	public BocloudResult configure(YumRepo repo, RequestContext context) {
		try {
			List<JSONObject> hosts = new ArrayList<>();
			StringBuffer sb = new StringBuffer();
			for (JSONObject target : repo.getTargets()) {
				BocloudResult result = check(target, YumRepoOperate.CONFIGURE);
				if (result.isFailed()) {
					sb.append(result.getMessage());
				} else {
					hosts.add((JSONObject) result.getData());
				}
			}
			if (StringUtils.isNotEmpty(sb.toString())) {
				new Thread(() -> {
					// 发送站内信
					NotifyMessage message = new NotifyMessage(context, "配置yum源任务执行结果", sb.toString(), true, false);
					amqpTemplate.convertAndSend(Constant.MESSAGE_QUEUE_ROUTINGKEY, message);
					// 发送界面消息
					OperateResult operateResult = new OperateResult(false, sb.toString(), "yum.operate", null,
							OperateCategory.TaskResult, context);
					resourceEventPublisher.send(operateResult);
				}).start();
			}
			if (hosts.isEmpty()) {
				return new BocloudResult(false, "为目标机器添加yum源[" + repo.getName() + "]任务下发失败，所选机器都不能支持配置yum源.");
			}
			repo.setTargets(hosts);
			requestWorker(YumRepoOperate.CONFIGURE, repo, context.getTarget());
			return new BocloudResult(true, "为目标机器添加yum源[" + repo.getName() + "]任务下发成功，正在执行...");
		} catch (Exception e) {
			logger.error("配置yum源客户端失败：", e);
			return new BocloudResult(false, "配置yum源客户端失败");
		}
	}

}