Java Code Examples for org.apache.commons.lang.BooleanUtils#isTrue()
The following examples show how to use
org.apache.commons.lang.BooleanUtils#isTrue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StopAllComponent.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
/** * サービス停止(ALL) * @param farmNo ファーム番号 * @param isStopInstance サーバ停止有無 true:サーバも停止、false:サービスのみ停止 * @return StopComponentResponse */ @GET @Produces(MediaType.APPLICATION_JSON) public StopAllComponentResponse stopComponent(@QueryParam(PARAM_NAME_FARM_NO) String farmNo, @QueryParam(PARAM_NAME_IS_STOP_INSTANCE) String isStopInstance) { // 入力チェック // FarmNo ApiValidate.validateFarmNo(farmNo); // IsStopInstance ApiValidate.validateIsStopInstance(isStopInstance); // ファーム取得 Farm farm = getFarm(Long.parseLong(farmNo)); // 権限チェック checkAndGetUser(farm); // コンポーネント取得 List<Component> components = componentDao.readByFarmNo(Long.parseLong(farmNo)); List<Long> componentNos = new ArrayList<Long>(); for (Component component : components) { if (BooleanUtils.isTrue(component.getLoadBalancer())) { //ロードバランサコンポーネントは対象外 continue; } componentNos.add(component.getComponentNo()); } // サービス停止設定 if (StringUtils.isEmpty(isStopInstance)) { processService.stopComponents(Long.parseLong(farmNo), componentNos); } else { processService.stopComponents(Long.parseLong(farmNo), componentNos, Boolean.parseBoolean(isStopInstance)); } StopAllComponentResponse response = new StopAllComponentResponse(); return response; }
Example 2
Source File: BuildDataServiceHandler.java From tesb-studio-se with Apache License 2.0 | 5 votes |
protected boolean isOptionChoosed(Object key) { if (key != null) { final Object object = exportChoice.get(key); if (object instanceof Boolean) { return BooleanUtils.isTrue((Boolean) object); } } return false; }
Example 3
Source File: IaasGatewayLoadBalancerProcess.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
public void start(Long loadBalancerNo) { LoadBalancer loadBalancer = loadBalancerDao.read(loadBalancerNo); if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-200226", loadBalancerNo, loadBalancer.getLoadBalancerName())); } //IaasGatewayWrapper作成 Farm farm = farmDao.read(loadBalancer.getFarmNo()); IaasGatewayWrapper gateway = iaasGatewayFactory.createIaasGateway(farm.getUserNo(), loadBalancer.getPlatformNo()); // ELBの起動 gateway.startLoadBalancer(loadBalancer.getLoadBalancerNo()); //Zabbixへの登録 Boolean useZabbix = BooleanUtils.toBooleanObject(Config.getProperty("zabbix.useZabbix")); if (BooleanUtils.isTrue(useZabbix)) { zabbixLoadBalancerProcess.startHost(loadBalancerNo); } // DNSサーバへの追加 addDns(loadBalancer.getLoadBalancerNo()); if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-200227", loadBalancerNo, loadBalancer.getLoadBalancerName())); } }
Example 4
Source File: IaasGatewayLoadBalancerProcess.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
public void stop(Long loadBalancerNo) { LoadBalancer loadBalancer = loadBalancerDao.read(loadBalancerNo); if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-200228", loadBalancerNo, loadBalancer.getLoadBalancerName())); } // DNSサーバからの削除 deleteDns(loadBalancerNo); //Zabbixからの削除 Boolean useZabbix = BooleanUtils.toBooleanObject(Config.getProperty("zabbix.useZabbix")); if (BooleanUtils.isTrue(useZabbix)) { zabbixLoadBalancerProcess.stopHost(loadBalancerNo); } //IaasGatewayWrapper作成 Farm farm = farmDao.read(loadBalancer.getFarmNo()); IaasGatewayWrapper gateway = iaasGatewayFactory.createIaasGateway(farm.getUserNo(), loadBalancer.getPlatformNo()); // ELBの停止 gateway.stopLoadBalancer(loadBalancer.getLoadBalancerNo()); if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-200229", loadBalancerNo, loadBalancer.getLoadBalancerName())); } }
Example 5
Source File: StopAllInstance.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
/** * サーバ停止(ALL) ファーム内のすべてのサーバを起動 * * @param farmNo ファーム番号 * @return StopAllInstanceResponse */ @GET @Produces(MediaType.APPLICATION_JSON) public StopAllInstanceResponse stoptAllInstance(@QueryParam(PARAM_NAME_FARM_NO) String farmNo) { // 入力チェック // FarmNo ApiValidate.validateFarmNo(farmNo); // ファーム取得 Farm farm = getFarm(Long.parseLong(farmNo)); // 権限チェック checkAndGetUser(farm); // インスタンス取得 List<Long> instanceNos = new ArrayList<Long>(); List<Instance> instances = instanceDao.readByFarmNo(Long.parseLong(farmNo)); for (Instance instance : instances) { if (BooleanUtils.isTrue(instance.getLoadBalancer())) { //ロードバランサ以外 continue; } InstanceStatus status = InstanceStatus.fromStatus(instance.getStatus()); if (InstanceStatus.RUNNING == status) { //ファーム内の起動済みのインスタンスが停止対象 instanceNos.add(instance.getInstanceNo()); } } // サーバ停止設定処理 processService.stopInstances(Long.parseLong(farmNo), instanceNos); StopAllInstanceResponse response = new StopAllInstanceResponse(); return response; }
Example 6
Source File: ToDoEditPage.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
@Override public AbstractSecuredBasePage afterSaveOrUpdate() { // Save to-do as recent to-do final ToDoDO pref = getToDoPrefData(true); copyPrefValues(getData(), pref); // Does the user want to store this to-do as template? boolean sendNotification = false; if (form.sendNotification == true) { sendNotification = true; } else if (oldToDo == null) { // Send notification on new to-do's. sendNotification = true; } else { if (ObjectUtils.equals(oldToDo.getAssigneeId(), getData().getAssigneeId()) == false) { // Assignee was changed. sendNotification = true; } else if (oldToDo.getStatus() != getData().getStatus()) { // Status was changed. sendNotification = true; } else if (oldToDo.isDeleted() != getData().isDeleted()) { // Deletion status was changed. sendNotification = true; } } if (sendNotification == true) { sendNotification(); } // if (form.sendShortMessage == true) { // final PFUserDO assignee = getData().getAssignee(); // final String mobileNumber = assignee != null ? assignee.getPersonalMebMobileNumbers() : null; // } if (BooleanUtils.isTrue(form.saveAsTemplate) == true) { final UserPrefEditPage userPrefEditPage = new UserPrefEditPage(ToDoPlugin.USER_PREF_AREA, getData()); userPrefEditPage.setReturnToPage(this.returnToPage); return userPrefEditPage; } return null; }
Example 7
Source File: LoadBalancerListenerResponse.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
public LoadBalancerListenerResponse(LoadBalancerListener listener) { this.loadBalancerNo = listener.getLoadBalancerNo(); this.loadBalancerPort = listener.getLoadBalancerPort(); this.servicePort = listener.getServicePort(); this.protocol = listener.getProtocol(); this.enabled = BooleanUtils.isTrue(listener.getEnabled()); this.status = listener.getStatus(); }
Example 8
Source File: EmrServiceImpl.java From herd with Apache License 2.0 | 5 votes |
/** * <p> Creates a new EMR cluster based on the given request if the cluster with the given name does not already exist. If the cluster already exist, returns * the information about the existing cluster. </p> <p> The request must contain: </p> <ul> <li>A namespace and definition name which refer to an existing * EMR cluster definition.</li> <li>A valid cluster name to create.</li> </ul> <p> The request may optionally contain: </p> <ul> <li>A "dry run" flag, which * when set to {@code true}, no calls to AWS will occur, but validations and override will. Defaults to {@code false}.</li> <li>An override parameter, which * when set, overrides the given parameters in the cluster definition before creating the cluster. Defaults to no override. </li> </ul> <p> A successful * response will contain: </p> <ul> <li>The ID of the cluster that was created, or if the cluster already exists, the ID of the cluster that exists. This * field will be {@code null} when dry run flag is {@code true}.</li> <li>The status of the cluster that was created or already exists. The status will * normally be "Starting" on successful creations. This field will be {@code null} when dry run flag is {@code true}</li> <li>The namespace, definition * name, and cluster name of the cluster.</li> <li>The dry run flag, if given in the request.</li> <li>An indicator whether the cluster was created or not. * If the cluster already exists, the cluster will not be created and this flag will be set to {@code false}.</li> <li>The definition which was used to * create the cluster. If any overrides were given, this definition's values will be the values after the override. This field will be {@code null} if the * cluster was not created.</li> </ul> <p> Notes: </p> <ul> <li>At any point of the execution, if there are validation errors, the method will immediately * throw an exception.</li> <li>Even if the validations pass, AWS may still reject the request, which will cause this method to throw an exception.</li> * <li>Dry runs do not make any calls to AWS, therefore AWS may still reject the creation request even when a dry run succeeds.</li> </ul> * * @param request - {@link EmrClusterCreateRequest} The EMR cluster create request * * @return {@link EmrCluster} the created EMR cluster object * @throws Exception when the original EMR cluster definition XML is malformed */ protected EmrCluster createClusterImpl(EmrClusterCreateRequest request) throws Exception { // Extract EMR cluster alternate key from the create request. EmrClusterAlternateKeyDto emrClusterAlternateKeyDto = getEmrClusterAlternateKey(request); // Perform the request validation. validateEmrClusterKey(emrClusterAlternateKeyDto); EmrClusterDefinition emrClusterDefinition = emrHelperServiceImpl.emrPreCreateClusterSteps(emrClusterAlternateKeyDto, request); String accountId = emrClusterDefinition.getAccountId(); EmrClusterCreateDto emrClusterCreateDto = emrHelperServiceImpl.emrCreateClusterAwsSpecificSteps(request, emrClusterDefinition, emrClusterAlternateKeyDto); if (emrClusterCreateDto.isEmrClusterCreated()) { emrHelperServiceImpl.logEmrClusterCreation(emrClusterAlternateKeyDto, emrClusterDefinition, emrClusterCreateDto.getClusterId()); } if (BooleanUtils.isTrue(emrClusterCreateDto.isEmrClusterAlreadyExists())) { // Do not include cluster definition in response emrClusterDefinition = null; } return createEmrClusterFromRequest(emrClusterCreateDto.getClusterId(), emrClusterAlternateKeyDto.getNamespace(), emrClusterAlternateKeyDto.getEmrClusterDefinitionName(), emrClusterAlternateKeyDto.getEmrClusterName(), accountId, emrClusterCreateDto.getEmrClusterStatus(), emrClusterCreateDto.isEmrClusterCreated(), request.isDryRun(), emrClusterDefinition); }
Example 9
Source File: WinServerEdit.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
private void loadData() { // VCloud情報を取得 IaasDescribeService describeService = BeanContext.getBean(IaasDescribeService.class); //StorageType List<StorageTypeDto> storageTypes = describeService.getStorageTypes(ViewContext.getUserNo(), platform.getPlatform().getPlatformNo()); this.storageTypes = storageTypes; //KeyPair List<KeyPairDto> vcloudKeyPairs = describeService.getKeyPairs(ViewContext.getUserNo(), platform.getPlatform().getPlatformNo()); this.vcloudKeyPairs = vcloudKeyPairs; //InstanceType List<String> instanceTypes = new ArrayList<String>(); for (String instanceType : image.getImageVcloud().getInstanceTypes().split(",")) { instanceTypes.add(instanceType.trim()); } this.instanceTypes = instanceTypes; //DataDisk List<DataDiskDto> dataDisks = new ArrayList<DataDiskDto>(); List<VcloudDisk> vcloudDisks = instance.getVcloudDisks(); for (VcloudDisk vcloudDisk : vcloudDisks) { if (BooleanUtils.isTrue(vcloudDisk.getDataDisk())) { DataDiskDto diskDto = new DataDiskDto(); diskDto.setDiskNo(vcloudDisk.getDiskNo()); diskDto.setDiskSize(vcloudDisk.getSize()); diskDto.setUnitNo(vcloudDisk.getUnitNo()); dataDisks.add(diskDto); } } this.dataDisks = dataDisks; }
Example 10
Source File: ListRoutersCmd.java From cloudstack with Apache License 2.0 | 4 votes |
public boolean shouldFetchHealthCheckResults() { return BooleanUtils.isTrue(fetchHealthCheckResults); }
Example 11
Source File: WinLoadBalancerEdit.java From primecloud-controller with GNU General Public License v2.0 | 4 votes |
private void loadData() { Long userNo = ViewContext.getUserNo(); Long farmNo = ViewContext.getFarmNo(); // ロードバランサ情報を取得 LoadBalancerService loadBalancerService = BeanContext.getBean(LoadBalancerService.class); List<LoadBalancerDto> loadBalancers = loadBalancerService.getLoadBalancers(farmNo); for (LoadBalancerDto loadBalancer : loadBalancers) { if (loadBalancerNo.equals(loadBalancer.getLoadBalancer().getLoadBalancerNo())) { this.loadBalancer = loadBalancer; break; } } // ロードバランサのプラットフォーム情報を取得 Long platformNo = loadBalancer.getLoadBalancer().getPlatformNo(); List<LoadBalancerPlatformDto> platforms = loadBalancerService.getPlatforms(userNo); for (LoadBalancerPlatformDto platform : platforms) { if (platformNo.equals(platform.getPlatform().getPlatformNo())) { this.platform = platform; break; } } // コンポーネント情報を取得 ComponentService componentService = BeanContext.getBean(ComponentService.class); components = componentService.getComponents(farmNo); // UltraMonkeyロードバランサの場合 if (PCCConstant.LOAD_BALANCER_ULTRAMONKEY.equals(loadBalancer.getLoadBalancer().getType())) { // インスタンスを特定する this.loadBalancerInstanceNo = loadBalancerService.getLoadBalancerInstance(loadBalancerNo); } // AWSロードバランサの場合 if (PCCConstant.LOAD_BALANCER_ELB.equals(loadBalancer.getLoadBalancer().getType())) { // VPCの場合 if (BooleanUtils.isTrue(platform.getPlatformAws().getVpc())) { AwsDescribeService awsDescribeService = BeanContext.getBean(AwsDescribeService.class); // サブネットを取得 this.subnets = new ArrayList<Subnet>(); List<Subnet> subnets = awsDescribeService.getSubnets(userNo, platformNo); for (Subnet subnet : subnets) { this.subnets.add(subnet); } // セキュリティグループを取得 this.securityGroups = new ArrayList<String>(); List<SecurityGroup> groups = awsDescribeService.getSecurityGroups(userNo, platformNo); for (SecurityGroup group : groups) { this.securityGroups.add(group.getGroupName()); } } } }
Example 12
Source File: Person.java From fenixedu-academic with GNU Lesser General Public License v3.0 | 4 votes |
public boolean isOptOutAvailable() { return BooleanUtils.isTrue(getDisableSendEmails()) || MessagingSystem.getInstance().isOptOutAvailable(this.getUser()); }
Example 13
Source File: CreateLoadBalancer.java From primecloud-controller with GNU General Public License v2.0 | 4 votes |
/** * ロードバランサリスナ作成 * * @param farmNo ファーム番号 * @param loadBalancerName ロードバランサ番号 * @param platformNo プラットフォーム番号 * @param loadBalancerType ロードバランサー種別(aws or ultramonkey) * @param componentNo コンポーネント番号 * @param comment コメント * @return CreateLoadBalancerResponse */ @GET @Produces(MediaType.APPLICATION_JSON) public CreateLoadBalancerResponse createLoadBalancer(@QueryParam(PARAM_NAME_FARM_NO) String farmNo, @QueryParam(PARAM_NAME_LOAD_BALANCER_NAME) String loadBalancerName, @QueryParam(PARAM_NAME_PLATFORM_NO) String platformNo, @QueryParam(PARAM_NAME_LOAD_BALANCER_TYPE) String loadBalancerType, @QueryParam(PARAM_NAME_COMPONENT_NO) String componentNo, @QueryParam(PARAM_NAME_COMMENT) String comment, @QueryParam(PARAM_NAME_IS_INTERNAL) String isInternal) { // 入力チェック // FarmNo ApiValidate.validateFarmNo(farmNo); // ファーム取得 Farm farm = farmDao.read(Long.parseLong(farmNo)); // 権限チェック User user = checkAndGetUser(farm); // LoadBalancerName ApiValidate.validateLoadBalancerName(loadBalancerName); // PlatformNo ApiValidate.validatePlatformNo(platformNo); Platform platform = platformDao.read(Long.parseLong(platformNo)); if (platform == null) { //プラットフォームが存在しない throw new AutoApplicationException("EAPI-100000", "Platform", PARAM_NAME_PLATFORM_NO, platformNo); } if (!platformService.isUsablePlatform(user.getUserNo(), platform) || BooleanUtils.isNotTrue(platform.getSelectable())) { //認証情報が存在しない or 有効ではないプラットフォーム throw new AutoApplicationException("EAPI-000020", "Platform", PARAM_NAME_PLATFORM_NO, platformNo); } // LoadBalancerType ApiValidate.validateLoadBalancerType(loadBalancerType); PlatformAws platformAws = platformAwsDao.read(Long.parseLong(platformNo)); if (LB_TYPE_ELB.equals(loadBalancerType) && (PLATFORM_TYPE_AWS.equals(platform.getPlatformType()) == false || platformAws.getEuca())) { //loadBalancerType=ELB、プラットフォーム=EC2以外の場合→エラー //EC2プラットフォームのみ ELB(Elastic Load Balancing)が使用可能 throw new AutoApplicationException("EAPI-000015", platform.getPlatformNo(), loadBalancerType); } // ComponentNo ApiValidate.validateComponentNo(componentNo); // Comment ApiValidate.validateComment(comment); // isInternal boolean internal = false; if (isInternal != null) { ApiValidate.validateIsInternal(isInternal); internal = Boolean.parseBoolean(isInternal); } if (!LB_TYPE_ELB.equals(loadBalancerType) || !platformAws.getVpc()) { if (BooleanUtils.isTrue(internal)) { // ELB かつプラットフォームがVPC以外の場合は内部ロードバランサ指定不可 throw new AutoApplicationException("EAPI -100041", loadBalancerName); } } // コンポーネント取得 Component component = getComponent(Long.parseLong(componentNo)); if (BooleanUtils.isFalse(component.getFarmNo().equals(farm.getFarmNo()))) { //ファームとコンポーネントが一致しない throw new AutoApplicationException("EAPI-100022", "Component", farm.getFarmNo(), PARAM_NAME_COMPONENT_NO, componentNo); } // ロードバランサー作成 Long loadBalancerNo = null; if (LB_TYPE_ELB.equals(loadBalancerType)) { //AWS ELB(Elastic Load Balancing) loadBalancerNo = loadBalancerService.createAwsLoadBalancer(Long.parseLong(farmNo), loadBalancerName, comment, Long.parseLong(platformNo), Long.parseLong(componentNo), internal); } else if (LB_TYPE_ULTRA_MONKEY.equals(loadBalancerType)) { //ultraMonkey loadBalancerNo = loadBalancerService.createUltraMonkeyLoadBalancer(Long.parseLong(farmNo), loadBalancerName, comment, Long.parseLong(platformNo), Long.parseLong(componentNo)); } else if (LB_TYPE_CLOUDSTACK.equals(loadBalancerType)) { //cloudstack loadBalancerNo = loadBalancerService.createCloudstackLoadBalancer(Long.parseLong(farmNo), loadBalancerName, comment, Long.parseLong(platformNo), Long.parseLong(componentNo)); } CreateLoadBalancerResponse response = new CreateLoadBalancerResponse(loadBalancerNo); return response; }
Example 14
Source File: SearchIndexValidationServiceImpl.java From herd with Apache License 2.0 | 4 votes |
@Override public SearchIndexValidation createSearchIndexValidation(SearchIndexValidationCreateRequest request) { //validate the request validateSearchIndexValidationRequest(request); // Ensure that search index for the specified search index key exists. Fetch the type SearchIndexEntity searchIndexEntity = searchIndexDaoHelper.getSearchIndexEntity(request.getSearchIndexKey()); String searchIndexType = searchIndexEntity.getType().getCode(); String indexName = request.getSearchIndexKey().getSearchIndexName(); boolean sizeCheck = false; boolean spotCheckPercentage = false; boolean spotCheckMostRecent = false; // Currently, only search index for business object definitions and tag are supported. if (SearchIndexTypeEntity.SearchIndexTypes.BUS_OBJCT_DFNTN.name().equalsIgnoreCase(searchIndexType)) { // only perform full validation if specified in the request if (BooleanUtils.isTrue(request.isPerformFullSearchIndexValidation())) { businessObjectDefinitionService.indexValidateAllBusinessObjectDefinitions(indexName); } sizeCheck = businessObjectDefinitionService.indexSizeCheckValidationBusinessObjectDefinitions(indexName); spotCheckPercentage = businessObjectDefinitionService.indexSpotCheckPercentageValidationBusinessObjectDefinitions(indexName); spotCheckMostRecent = businessObjectDefinitionService.indexSpotCheckMostRecentValidationBusinessObjectDefinitions(indexName); } else if (SearchIndexTypeEntity.SearchIndexTypes.TAG.name().equalsIgnoreCase(searchIndexType)) { // only perform full validation if specified in the request if (BooleanUtils.isTrue(request.isPerformFullSearchIndexValidation())) { tagService.indexValidateAllTags(indexName); } sizeCheck = tagService.indexSizeCheckValidationTags(indexName); spotCheckPercentage = tagService.indexSpotCheckPercentageValidationTags(indexName); spotCheckMostRecent = tagService.indexSpotCheckMostRecentValidationTags(indexName); } return new SearchIndexValidation(request.getSearchIndexKey(), getXMLGregorianCalendarValue(new Date()), sizeCheck, spotCheckPercentage, spotCheckMostRecent); }
Example 15
Source File: AwsInstanceProcess.java From primecloud-controller with GNU General Public License v2.0 | 4 votes |
public void createTag(AwsProcessClient awsProcessClient, Long instanceNo) { // Eucalyptusの場合はタグを付けない PlatformAws platformAws = awsProcessClient.getPlatformAws(); if (BooleanUtils.isTrue(platformAws.getEuca())) { return; } Instance instance = instanceDao.read(instanceNo); AwsInstance awsInstance = awsInstanceDao.read(instanceNo); User user = userDao.read(awsProcessClient.getUserNo()); Farm farm = farmDao.read(instance.getFarmNo()); // インスタンスにタグを追加する List<Tag> tags = new ArrayList<Tag>(); tags.add(new Tag("Name", instance.getFqdn())); tags.add(new Tag("UserName", user.getUsername())); tags.add(new Tag("CloudName", farm.getDomainName())); tags.add(new Tag("ServerName", instance.getFqdn())); awsCommonProcess.createTag(awsProcessClient, awsInstance.getInstanceId(), tags); com.amazonaws.services.ec2.model.Instance instance2 = awsCommonProcess.describeInstance(awsProcessClient, awsInstance.getInstanceId()); // EBSにタグを追加する for (InstanceBlockDeviceMapping mapping : instance2.getBlockDeviceMappings()) { if (mapping.getEbs() == null) { continue; } String deviceName = mapping.getDeviceName(); if (deviceName.lastIndexOf("/") != -1) { deviceName = deviceName.substring(deviceName.lastIndexOf("/") + 1); } tags = new ArrayList<Tag>(); tags.add(new Tag("Name", instance.getFqdn() + "_" + deviceName)); tags.add(new Tag("UserName", user.getUsername())); tags.add(new Tag("CloudName", farm.getDomainName())); tags.add(new Tag("ServerName", instance.getFqdn())); awsCommonProcess.createTag(awsProcessClient, mapping.getEbs().getVolumeId(), tags); } }
Example 16
Source File: VmwareCustomizeProcess.java From primecloud-controller with GNU General Public License v2.0 | 4 votes |
public void customize(VmwareProcessClient vmwareProcessClient, Long instanceNo) { VmwareInstance vmwareInstance = vmwareInstanceDao.read(instanceNo); VmwareClient vmwareClient = vmwareProcessClient.getVmwareClient(); // VirtualMachine VirtualMachine machine = vmwareClient.search(VirtualMachine.class, vmwareInstance.getMachineName()); if (machine == null) { // 仮想マシンが見つからない場合 throw new AutoException("EPROCESS-000501", vmwareInstance.getMachineName()); } // Windowsで始まるOSはカスタマイズする Instance instance = instanceDao.read(instanceNo); Image image = imageDao.read(instance.getImageNo()); if (StringUtils.startsWith(image.getOs(), PCCConstant.OS_NAME_WIN)) { if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100464", vmwareInstance.getMachineName())); } customizeWindows(vmwareProcessClient, vmwareInstance, machine); vmwareProcessClient.powerOnVM(vmwareInstance.getMachineName()); vmwareProcessClient.waitForStopped(vmwareInstance.getMachineName()); vmwareProcessClient.powerOnVM(vmwareInstance.getMachineName()); // ネットワーク名の取得 PlatformVmware platformVmware = platformVmwareDao.read(instance.getPlatformNo()); String publicNetworkName = platformVmware.getPublicNetwork(); String privateNetworkName = platformVmware.getPrivateNetwork(); List<VmwareNetwork> vmwareNetworks = vmwareNetworkDao.readByFarmNo(instance.getFarmNo()); for (VmwareNetwork vmwareNetwork : vmwareNetworks) { if (BooleanUtils.isTrue(vmwareNetwork.getPublicNetwork())) { publicNetworkName = vmwareNetwork.getNetworkName(); } else { privateNetworkName = vmwareNetwork.getNetworkName(); } } List<String> networkNames = new ArrayList<String>(); if (StringUtils.isNotEmpty(publicNetworkName)) { networkNames.add(publicNetworkName); } if (StringUtils.isNotEmpty(privateNetworkName)) { networkNames.add(privateNetworkName); } vmwareProcessClient.waitForRunning(vmwareInstance.getMachineName(), networkNames); vmwareProcessClient.shutdownGuest(vmwareInstance.getMachineName()); if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-100465", vmwareInstance.getMachineName())); } } }
Example 17
Source File: LoadBalancerProcess.java From primecloud-controller with GNU General Public License v2.0 | 4 votes |
public void configure(Long loadBalancerNo) { LoadBalancer loadBalancer = loadBalancerDao.read(loadBalancerNo); if (loadBalancer == null) { // ロードバランサが存在しない throw new AutoException("EPROCESS-000010", loadBalancerNo); } if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-200011", loadBalancerNo, loadBalancer.getLoadBalancerName())); } LoadBalancerStatus initStatus = LoadBalancerStatus.fromStatus(loadBalancer.getStatus()); // ステータスの更新 if (BooleanUtils.isTrue(loadBalancer.getConfigure())) { loadBalancer.setStatus(LoadBalancerStatus.CONFIGURING.toString()); loadBalancerDao.update(loadBalancer); } // イベントログ出力 if (BooleanUtils.isTrue(loadBalancer.getConfigure())) { processLogger.info(null, null, "LoadBalancerConfig", new Object[] { loadBalancer.getLoadBalancerName() }); } try { // ロードバランサ設定処理 configureLoadBalancer(loadBalancer); } catch (RuntimeException e) { // イベントログ出力 if (BooleanUtils.isTrue(loadBalancer.getConfigure())) { processLogger.info(null, null, "LoadBalancerConfigFail", new Object[] { loadBalancer.getLoadBalancerName() }); } // ステータスの更新 if (BooleanUtils.isTrue(loadBalancer.getConfigure())) { loadBalancer = loadBalancerDao.read(loadBalancerNo); loadBalancer.setStatus(initStatus.toString()); loadBalancer.setConfigure(false); loadBalancerDao.update(loadBalancer); } // ロードバランサ停止時はエラーを握り潰す if (BooleanUtils.isNotTrue(loadBalancer.getEnabled())) { log.warn(e.getMessage()); return; } throw e; } // イベントログ出力 if (BooleanUtils.isTrue(loadBalancer.getConfigure())) { processLogger.info(null, null, "LoadBalancerConfigFinish", new Object[] { loadBalancer.getLoadBalancerName() }); } // ステータスの更新 if (BooleanUtils.isTrue(loadBalancer.getConfigure())) { loadBalancer = loadBalancerDao.read(loadBalancerNo); loadBalancer.setStatus(initStatus.toString()); loadBalancer.setConfigure(false); loadBalancerDao.update(loadBalancer); } if (log.isInfoEnabled()) { log.info(MessageUtils.getMessage("IPROCESS-200012", loadBalancerNo, loadBalancer.getLoadBalancerName())); } }
Example 18
Source File: AwsProcessClientFactory.java From primecloud-controller with GNU General Public License v2.0 | 4 votes |
protected AwsProcessClient createAwsClient(Platform platform, PlatformAws platformAws, AwsCertificate awsCertificate) { AwsClientFactory factory; if (BooleanUtils.isTrue(platformAws.getEuca())) { factory = new EucaAwsClientFactory(); } else { factory = new AmazonAwsClientFactory(); } factory.setHost(platformAws.getHost()); factory.setPort(platformAws.getPort()); factory.setSecure(platformAws.getSecure()); if (BooleanUtils.isTrue(platform.getProxy())) { Proxy proxy = proxyDao.read(); factory.setProxyHost(proxy.getHost()); factory.setProxyPort(proxy.getPort()); factory.setProxyUser(proxy.getUser()); factory.setProxyPassword(proxy.getPassword()); } // Clientの作成 AmazonEC2 ec2Client = factory.createEc2Client(awsCertificate.getAwsAccessId(), awsCertificate.getAwsSecretKey()); AmazonElasticLoadBalancing elbClient = factory.createElbClient(awsCertificate.getAwsAccessId(), awsCertificate.getAwsSecretKey()); // ログ出力用Clientでラップ String logging = StringUtils.defaultIfEmpty(Config.getProperty("aws.logging"), "false"); if (BooleanUtils.toBoolean(logging)) { LoggingAwsClientWrapper loggingAwsClientWrapper = new LoggingAwsClientWrapper(); ec2Client = loggingAwsClientWrapper.wrap(ec2Client); elbClient = loggingAwsClientWrapper.wrap(elbClient); } // 同期実行用Clientでラップ String sync = StringUtils.defaultIfEmpty(Config.getProperty("aws.synchronized"), "true"); if (BooleanUtils.toBoolean(sync)) { SynchronizedAwsClientWrapper synchronizedAwsClientWrapper = new SynchronizedAwsClientWrapper(); ec2Client = synchronizedAwsClientWrapper.wrap(ec2Client); elbClient = synchronizedAwsClientWrapper.wrap(elbClient); } AwsProcessClient client = new AwsProcessClient(awsCertificate.getUserNo(), platform, platformAws, ec2Client, elbClient); String describeInterval = Config.getProperty("aws.describeInterval"); client.setDescribeInterval(NumberUtils.toInt(describeInterval, 15)); return client; }
Example 19
Source File: StartAllInstance.java From primecloud-controller with GNU General Public License v2.0 | 4 votes |
/** * サーバ起動(ALL) ファーム内のすべてのサーバを起動 * * @param farmNo ファーム番号 * @param isStartService サービス起動有無 true:サービスも起動、false:サーバのみ起動、null:サーバのみ起動 * @return StartAllInstanceResponse */ @GET @Produces(MediaType.APPLICATION_JSON) public StartAllInstanceResponse startAllInstance(@QueryParam(PARAM_NAME_FARM_NO) String farmNo, @QueryParam(PARAM_NAME_IS_START_SERVICE) String isStartService) { // 入力チェック // FarmNo ApiValidate.validateFarmNo(farmNo); // IsStartService ApiValidate.validateIsStartService(isStartService); // データチェック // ファーム Farm farm = getFarm(Long.parseLong(farmNo)); // 権限チェック checkAndGetUser(farm); // インスタンス取得 List<Long> instanceNos = new ArrayList<Long>(); List<Instance> instances = instanceDao.readByFarmNo(Long.parseLong(farmNo)); for (Instance instance : instances) { if (BooleanUtils.isTrue(instance.getLoadBalancer())) { //ロードバランサ以外 continue; } InstanceStatus status = InstanceStatus.fromStatus(instance.getStatus()); if (InstanceStatus.STOPPED == status) { //ファーム内の停止済みのインスタンスが起動対象 instanceNos.add(instance.getInstanceNo()); } } // サーバ起動設定処理 if (StringUtils.isEmpty(isStartService)) { processService.startInstances(Long.parseLong(farmNo), instanceNos); } else { processService.startInstances(Long.parseLong(farmNo), instanceNos, Boolean.parseBoolean(isStartService)); } StartAllInstanceResponse response = new StartAllInstanceResponse(); return response; }
Example 20
Source File: LookupableImpl.java From rice with Educational Community License v2.0 | 2 votes |
/** * Indicator if wildcards and operators are disabled on this search criteria. * * @param lookupCriteria the viewPostMetadata with the attributes of the search criteria field * @return true if wildcards and operators are disabled, false otherwise */ protected boolean isCriteriaWildcardDisabled(Map lookupCriteria) { return BooleanUtils.isTrue((Boolean) lookupCriteria.get(UifConstants.LookupCriteriaPostMetadata.DISABLE_WILDCARDS_AND_OPERATORS)); }