Java Code Examples for org.apache.commons.lang.BooleanUtils#isNotTrue()

The following examples show how to use org.apache.commons.lang.BooleanUtils#isNotTrue() . 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: ListPlatform.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
/**
 * プラットフォーム一覧取得
 *
 * @return ListPlatformResponse
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public ListPlatformResponse listPlatform() {

    //ユーザ取得
    User user = checkAndGetUser();

    ListPlatformResponse response = new ListPlatformResponse();

    // プラットフォーム情報取得
    List<Platform> platforms = platformDao.readAll();
    for (Platform platform : platforms) {
        if (!platformService.isUsablePlatform(user.getUserNo(), platform)
                || BooleanUtils.isNotTrue(platform.getSelectable())) {
            //認証情報が存在しない or 無効プラットフォーム → 表示しない
            continue;
        }
        PlatformResponse platformResponse = new PlatformResponse(platform);
        response.getPlatforms().add(platformResponse);
    }

    return response;
}
 
Example 2
Source File: AddAwsAddress.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
public AddAwsAddressResponse addAwsAddress(@QueryParam(PARAM_NAME_PLATFORM_NO) String platformNo) {
    // 入力チェック
    ApiValidate.validatePlatformNo(platformNo);

    // ユーザ取得
    User user = checkAndGetUser();

    // プラットフォーム取得
    Platform platform = platformDao.read(Long.parseLong(platformNo));

    // プラットフォームが存在しない場合
    if (platform == null) {
        throw new AutoApplicationException("EAPI-100000", "Platform", PARAM_NAME_PLATFORM_NO, platformNo);
    }

    // プラットフォームを選択できない場合
    if (BooleanUtils.isNotTrue(platform.getSelectable())) {
        throw new AutoApplicationException("EAPI-000020", "Platform", PARAM_NAME_PLATFORM_NO, platformNo);
    }

    // プラットフォームを利用できない場合
    if (!platformService.isUsablePlatform(user.getUserNo(), platform)) {
        throw new AutoApplicationException("EAPI-000020", "Platform", PARAM_NAME_PLATFORM_NO, platformNo);
    }

    // AWSアドレスを作成
    AwsProcessClient awsProcessClient = awsProcessClientFactory.createAwsProcessClient(user.getUserNo(),
            platform.getPlatformNo());
    AwsAddress awsAddress = awsAddressProcess.createAddress(awsProcessClient);

    AwsAddressResponse awsAddressResponse = new AwsAddressResponse(awsAddress);
    AddAwsAddressResponse response = new AddAwsAddressResponse(awsAddressResponse);

    return response;
}
 
Example 3
Source File: WinServiceAdd.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void loadData() {
    // サービス種類情報を取得
    ComponentService componentService = BeanContext.getBean(ComponentService.class);
    componentTypes = componentService.getComponentTypes(ViewContext.getFarmNo());

    // 有効でないサービス種類情報を除外
    for (int i = componentTypes.size() - 1; i >= 0; i--) {
        if (BooleanUtils.isNotTrue(componentTypes.get(i).getComponentType().getSelectable())) {
            componentTypes.remove(i);
        }
    }

    // サービス種類情報をソート
    Collections.sort(componentTypes, new Comparator<ComponentTypeDto>() {
        @Override
        public int compare(ComponentTypeDto o1, ComponentTypeDto o2) {
            int order1 = (o1.getComponentType().getViewOrder() != null) ? o1.getComponentType().getViewOrder()
                    : Integer.MAX_VALUE;
            int order2 = (o2.getComponentType().getViewOrder() != null) ? o2.getComponentType().getViewOrder()
                    : Integer.MAX_VALUE;
            return order1 - order2;
        }
    });

    // 全インスタンスを取得
    InstanceService instanceService = BeanContext.getBean(InstanceService.class);
    instances = instanceService.getInstances(ViewContext.getFarmNo());
}
 
Example 4
Source File: ProcessServiceImpl.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void startComponents(Long farmNo, Long componentNo, List<Long> instanceNos) {
    // コンポーネントを有効にする
    List<ComponentInstance> componentInstances = componentInstanceDao.readByComponentNo(componentNo);
    for (ComponentInstance componentInstance : componentInstances) {
        if (!instanceNos.contains(componentInstance.getInstanceNo())) {
            continue;
        }
        if (BooleanUtils.isNotTrue(componentInstance.getAssociate())) {
            // 関連付けが無効なコンポーネントは無効にする
            if (BooleanUtils.isTrue(componentInstance.getEnabled())
                    || BooleanUtils.isNotTrue(componentInstance.getConfigure())) {
                componentInstance.setEnabled(false);
                componentInstance.setConfigure(true);
                componentInstanceDao.update(componentInstance);
            }
            continue;
        }
        if (BooleanUtils.isNotTrue(componentInstance.getEnabled())
                || BooleanUtils.isNotTrue(componentInstance.getConfigure())) {
            componentInstance.setEnabled(true);
            componentInstance.setConfigure(true);
            componentInstanceDao.update(componentInstance);
        }
    }

    // インスタンスが起動していない場合は起動する
    List<Instance> instances = instanceDao.readInInstanceNos(instanceNos);
    for (Instance instance : instances) {
        if (BooleanUtils.isNotTrue(instance.getEnabled())) {
            instance.setEnabled(true);
            instanceDao.update(instance);
        }
    }

    // ファームを更新処理対象として登録
    scheduleFarm(farmNo);
}
 
Example 5
Source File: ProcessServiceImpl.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
protected void scheduleFarm(Long farmNo) {
    Farm farm = farmDao.read(farmNo);
    if (BooleanUtils.isNotTrue(farm.getScheduled())) {
        farm.setScheduled(true);
        farmDao.update(farm);
    }
}
 
Example 6
Source File: ListTemplate.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 使用可能なコンポーネントタイプ番号のリストを取得する
 *
 * @return 使用可能なコンポーネントタイプ番号のリスト
 */
private List<Long> getEnabledComponentTypeNos() {
    List<Long> componentTypeNos = new ArrayList<Long>();
    List<ComponentType> componentTypes = componentTypeDao.readAll();
    for (ComponentType componentType : componentTypes) {
        if (BooleanUtils.isNotTrue(componentType.getSelectable())) {
            //有効コンポーネントタイプではない場合、ロードバランサーイメージの場合はリストに含めない
            continue;
        }
        componentTypeNos.add(componentType.getComponentTypeNo());
    }
    return componentTypeNos;
}
 
Example 7
Source File: WinLoadBalancerAdd.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
private void loadData() {
    // プラットフォーム情報を取得
    LoadBalancerService loadBalancerService = BeanContext.getBean(LoadBalancerService.class);
    platforms = loadBalancerService.getPlatforms(ViewContext.getUserNo());

    // 有効でないプラットフォーム情報を除外
    for (int i = platforms.size() - 1; i >= 0; i--) {
        if (BooleanUtils.isNotTrue(platforms.get(i).getPlatform().getSelectable())) {
            platforms.remove(i);
        }
    }

    // プラットフォーム情報をソート
    Collections.sort(platforms, new Comparator<LoadBalancerPlatformDto>() {
        @Override
        public int compare(LoadBalancerPlatformDto o1, LoadBalancerPlatformDto o2) {
            int order1 = (o1.getPlatform().getViewOrder() != null) ? o1.getPlatform().getViewOrder()
                    : Integer.MAX_VALUE;
            int order2 = (o2.getPlatform().getViewOrder() != null) ? o2.getPlatform().getViewOrder()
                    : Integer.MAX_VALUE;
            return order1 - order2;
        }
    });

    // サービス情報を取得
    ComponentService componentService = BeanContext.getBean(ComponentService.class);
    components = componentService.getComponents(ViewContext.getFarmNo());
}
 
Example 8
Source File: PuppetComponentProcess.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
protected void deleteAssociate(Long componentNo, Long instanceNo) {
    ComponentInstance componentInstance = componentInstanceDao.read(componentNo, instanceNo);

    // コンポーネントとインスタンスの関連付けが無効で、コンポーネントが停止している場合、レコードを削除する
    if (BooleanUtils.isNotTrue(componentInstance.getAssociate())) {
        ComponentInstanceStatus status = ComponentInstanceStatus.fromStatus(componentInstance.getStatus());
        if (status == ComponentInstanceStatus.STOPPED) {
            componentInstanceDao.delete(componentInstance);
        }
    }
}
 
Example 9
Source File: CreateFarm.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 使用可能なイメージ番号のリストを取得する
 *
 * @return 使用可能なイメージ番号のリスト
 */
private List<Long> getEnabledImageNos() {
    List<Long> imageNos = new ArrayList<Long>();
    List<Image> images = imageDao.readAll();
    for (Image image : images) {
        if (BooleanUtils.isNotTrue(image.getSelectable())) {
            //有効イメージではない場合、ロードバランサーイメージの場合はリストに含めない
            continue;
        }
        imageNos.add(image.getImageNo());
    }
    return imageNos;
}
 
Example 10
Source File: CreateFarm.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 使用可能なプラットフォーム番号のリストを取得する
 *
 * @param userNo ユーザ番号
 * @return 使用可能なプラットフォーム番号のリスト
 */
private List<Long> getEnabledPlatformNos(Long userNo) {
    List<Long> platformNos = new ArrayList<Long>();
    List<Platform> platforms = platformDao.readAll();
    for (Platform platform : platforms) {
        if (!platformService.isUsablePlatform(userNo, platform)
                || BooleanUtils.isNotTrue(platform.getSelectable())) {
            //認証情報が存在しない or 有効プラットフォームではない場合はリストに含めない
            continue;
        }
        platformNos.add(platform.getPlatformNo());
    }
    return platformNos;
}
 
Example 11
Source File: TemplateServiceImpl.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 使用可能なイメージ番号のリストを取得する
 *
 * @return 使用可能なイメージ番号のリスト
 */
protected List<Long> getEnabledImageNos() {
    List<Long> imageNos = new ArrayList<Long>();

    List<Image> images = imageDao.readAll();
    for (Image image : images) {
        if (BooleanUtils.isNotTrue(image.getSelectable())) {
            //有効イメージではない場合、ロードバランサーイメージの場合はリストに含めない
            continue;
        }
        imageNos.add(image.getImageNo());
    }

    return imageNos;
}
 
Example 12
Source File: CreateComponent.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
/**
 * サービス作成
 *
 * @param farmNo ファーム番号
 * @param componentName コンポーネント名
 * @param componentTypeNo コンポーネントタイプ番号
 * @param diskSize ディスクサイズ
 * @param comment コメント
 * @return CreateComponentResponse
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public CreateComponentResponse createComponent(@QueryParam(PARAM_NAME_FARM_NO) String farmNo,
        @QueryParam(PARAM_NAME_COMPONENT_NAME) String componentName,
        @QueryParam(PARAM_NAME_COMPONENT_TYPE_NO) String componentTypeNo,
        @QueryParam(PARAM_NAME_DISK_SIZE) String diskSize, @QueryParam(PARAM_NAME_COMMENT) String comment) {

    // 入力チェック
    // farmNo
    ApiValidate.validateFarmNo(farmNo);
    // componentName
    ApiValidate.validateComponentName(componentName);
    // componentTypeNo
    ApiValidate.validateComponentTypeNo(componentTypeNo);
    // diskSize
    ApiValidate.validateDiskSize(diskSize);
    // comments
    ApiValidate.validateComment(comment);

    // 権限チェック
    Farm farm = farmDao.read(Long.parseLong(farmNo));
    checkAndGetUser(farm);

    ComponentType componentType = componentTypeDao.read(Long.parseLong(componentTypeNo));
    if (componentType == null) {
        //コンポーネントタイプが存在しない
        throw new AutoApplicationException("EAPI-100000", "ComponentType", PARAM_NAME_COMPONENT_TYPE_NO,
                componentTypeNo);
    }
    if (BooleanUtils.isNotTrue(componentType.getSelectable())) {
        //有効ではないコンポーネントタイプ
        throw new AutoApplicationException("EAPI-000020", "ComponentType", PARAM_NAME_COMPONENT_TYPE_NO,
                componentTypeNo);
    }

    // サービス作成
    Long componentNo = componentService.createComponent(Long.parseLong(farmNo), componentName,
            Long.valueOf(componentTypeNo), comment, Integer.parseInt(diskSize));

    CreateComponentResponse response = new CreateComponentResponse(componentNo);

    return response;
}
 
Example 13
Source File: AwsLoadBalancerProcess.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
public void applySecurityGroups(AwsProcessClient awsProcessClient, Long loadBalancerNo) {
    // 非VPCの場合はスキップ
    if (BooleanUtils.isNotTrue(awsProcessClient.getPlatformAws().getVpc())) {
        return;
    }

    AwsLoadBalancer awsLoadBalancer = awsLoadBalancerDao.read(loadBalancerNo);

    // 現在設定されているSecurityGroup
    LoadBalancerDescription description = awsCommonProcess.describeLoadBalancer(awsProcessClient,
            awsLoadBalancer.getName());
    List<String> groupIds = description.getSecurityGroups();

    // 新しく設定するSecurityGroup
    List<String> newGroupIds = new ArrayList<String>();
    List<SecurityGroup> securityGroups = awsCommonProcess.describeSecurityGroupsByVpcId(awsProcessClient,
            awsProcessClient.getPlatformAws().getVpcId());
    for (String groupName : StringUtils.split(awsLoadBalancer.getSecurityGroups(), ",")) {
        groupName = groupName.trim();
        for (SecurityGroup securityGroup : securityGroups) {
            if (StringUtils.equals(groupName, securityGroup.getGroupName())) {
                newGroupIds.add(securityGroup.getGroupId());
                break;
            }
        }
    }

    // SecurityGroupに変更がない場合はスキップ
    if (groupIds.size() == newGroupIds.size() && groupIds.containsAll(newGroupIds)) {
        return;
    }

    // セキュリティグループを変更
    ApplySecurityGroupsToLoadBalancerRequest request = new ApplySecurityGroupsToLoadBalancerRequest();
    request.withLoadBalancerName(awsLoadBalancer.getName());
    request.withSecurityGroups(newGroupIds);
    awsProcessClient.getElbClient().applySecurityGroupsToLoadBalancer(request);

    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-200225", awsLoadBalancer.getName()));
    }

    // イベントログ出力
    processLogger.debug(null, null, "AwsElbSecurityGroupsConfig",
            new Object[] { awsProcessClient.getPlatform().getPlatformName(), awsLoadBalancer.getName() });
}
 
Example 14
Source File: CreateLoadBalancer.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
/**
 * ロードバランサリスナ作成
 *
 * @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 15
Source File: AwsInstanceProcess.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
/**
 * TODO: メソッドコメント
 * 
 * @param awsProcessClient
 * @param instanceNo
 */
public void startInstance(AwsProcessClient awsProcessClient, Long instanceNo) {
    AwsInstance awsInstance = awsInstanceDao.read(instanceNo);
    Instance instance = instanceDao.read(instanceNo);
    Image image = imageDao.read(instance.getImageNo());
    ImageAws imageAws = imageAwsDao.read(instance.getImageNo());

    // インスタンスストアイメージの場合や、EBSイメージで初回起動の場合
    if (BooleanUtils.isNotTrue(imageAws.getEbsImage()) || StringUtils.isEmpty(awsInstance.getInstanceId())) {
        // インスタンスIDがある場合はスキップ
        if (!StringUtils.isEmpty(awsInstance.getInstanceId())) {
            return;
        }

        // インスタンスの作成
        run(awsProcessClient, instanceNo);

        // インスタンスの作成待ち
        waitRun(awsProcessClient, instanceNo);

        // インスタンスにタグをつける
        createTag(awsProcessClient, instanceNo);

        // Windowsの場合、パスワードデータを取得できるようになるまで待つ
        if (StringUtils.startsWithIgnoreCase(image.getOs(), "windows")) {
            waitGetPasswordData(awsProcessClient, instanceNo);
        }
    }
    // EBSイメージで2回目以降の起動の場合
    else {
        // インスタンスが停止中でない場合はスキップ
        if (!StringUtils.equals(awsInstance.getStatus(), InstanceStateName.Stopped.toString())) {
            return;
        }

        // インスタンスの設定変更
        modify(awsProcessClient, instanceNo);

        // インスタンスの起動
        start(awsProcessClient, instanceNo);

        // インスタンスの起動待ち
        waitStart(awsProcessClient, instanceNo);
    }
}
 
Example 16
Source File: PuppetLoadBalancerProcess.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
protected void configureInstance(Long loadBalancerNo, Long componentNo, Long instanceNo,
        Map<String, Object> rootMap) {
    LoadBalancer loadBalancer = loadBalancerDao.read(loadBalancerNo);
    Component component = componentDao.read(componentNo);
    Instance instance = instanceDao.read(instanceNo);

    // インスタンス情報
    Map<String, Object> instanceMap = createInstanceMap(instanceNo);
    rootMap.putAll(instanceMap);

    // マニフェストファイル
    ComponentType componentType = componentTypeDao.read(component.getComponentTypeNo());
    File manifestFile = new File(manifestDir, instance.getFqdn() + "." + component.getComponentName() + ".pp");

    // マニフェストファイルのリストア
    restoreManifest(manifestFile);

    // 既にあるマニフェストファイルのダイジェストを求める
    String digest = getFileDigest(manifestFile, "UTF-8");

    // ロードバランサ停止時でマニフェストが存在しない場合、スキップする
    if (digest == null && BooleanUtils.isNotTrue(loadBalancer.getEnabled())) {
        return;
    }

    // マニフェストの生成
    String templateName = "loadBalancer_" + componentType.getComponentTypeName() + ".ftl";
    generateManifest(templateName, rootMap, manifestFile, "UTF-8");

    // 生成したマニフェストのダイジェストの比較
    if (digest != null) {
        String newDigest = getFileDigest(manifestFile, "UTF-8");
        if (digest.equals(newDigest)) {
            // マニフェストファイルに変更がない場合
            if (log.isDebugEnabled()) {
                log.debug(MessageUtils.format("Not changed manifest.(file={0})", manifestFile.getName()));
            }
            return;
        }
    }

    // Puppetクライアントの設定更新指示
    try {
        runPuppet(instance, component);
    } finally {
        if (BooleanUtils.isTrue(loadBalancer.getEnabled())) {
            // マニフェストファイルのバックアップ
            backupManifest(manifestFile);
        } else {
            // マニフェストファイルの削除
            deleteManifest(manifestFile);
        }
    }
}
 
Example 17
Source File: DescribeComponent.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
/**
 * サービス情報取得
 *
 * @param componentNo コンポーネント番号
 * @return DescribeComponentResponse
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public DescribeComponentResponse describeComponent(@QueryParam(PARAM_NAME_COMPONENT_NO) String componentNo) {

    // 入力チェック
    // ComponentNo
    ApiValidate.validateComponentNo(componentNo);

    // コンポーネント取得
    Component component = getComponent(Long.parseLong(componentNo));

    // 権限チェック
    checkAndGetUser(component);

    //コンポーネント情報設定
    ComponentResponse componentResponse = new ComponentResponse(component);

    List<ComponentInstance> componentInstances = componentInstanceDao
            .readByComponentNo(Long.parseLong(componentNo));
    if (componentInstances.isEmpty() == false) {
        //ソート
        Collections.sort(componentInstances, Comparators.COMPARATOR_COMPONENT_INSTANCE);
        for (ComponentInstance componentInstance : componentInstances) {
            // 関連付けが無効で停止している場合は除外
            if (BooleanUtils.isNotTrue(componentInstance.getAssociate())) {
                ComponentInstanceStatus status = ComponentInstanceStatus.fromStatus(componentInstance.getStatus());
                if (status == ComponentInstanceStatus.STOPPED) {
                    continue;
                }
            }
            //コンポーネントインスタンス情報設定
            componentResponse.getInstances().add(new ComponentInstanceResponse(componentInstance));
        }
    }

    //ロードバランサ取得
    List<LoadBalancer> loadBalancers = loadBalancerDao.readByComponentNo(component.getComponentNo());
    if (loadBalancers.isEmpty() == false) {
        //ソート
        Collections.sort(loadBalancers, Comparators.COMPARATOR_LOAD_BALANCER);

        for (LoadBalancer loadBalancer : loadBalancers) {
            componentResponse.getLoadBalancers().add(new ComponentLoadBalancerResponse(loadBalancer));
        }
    }

    DescribeComponentResponse response = new DescribeComponentResponse(componentResponse);

    return response;
}
 
Example 18
Source File: DeleteAwsAddress.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
public DeleteAwsAddressResponse deleteAwsAddress(@QueryParam(PARAM_NAME_ADDRESS_NO) String addressNo) {
    // 入力チェック
    ApiValidate.validateAddressNo(addressNo);

    // ユーザ取得
    User user = checkAndGetUser();

    // アドレス情報取得
    AwsAddress awsAddress = awsAddressDao.read(Long.parseLong(addressNo));

    // アドレス情報が存在しない場合
    if (awsAddress == null) {
        throw new AutoApplicationException("EAPI-100000", "AwsAddress", PARAM_NAME_ADDRESS_NO, addressNo);
    }

    // 他ユーザのアドレスの場合
    if (!awsAddress.getUserNo().equals(user.getUserNo())) {
        throw new AutoApplicationException("EAPI-000020", "AwsAddress", PARAM_NAME_ADDRESS_NO, addressNo);
    }

    // プラットフォーム取得
    Platform platform = platformDao.read(awsAddress.getPlatformNo());

    // プラットフォームを選択できない場合
    if (BooleanUtils.isNotTrue(platform.getSelectable())) {
        throw new AutoApplicationException("EAPI-000020", "AwsAddress", PARAM_NAME_ADDRESS_NO, addressNo);
    }

    // プラットフォームを利用できない場合
    if (!platformService.isUsablePlatform(user.getUserNo(), platform)) {
        throw new AutoApplicationException("EAPI-000020", "AwsAddress", PARAM_NAME_ADDRESS_NO, addressNo);
    }

    // インスタンスに関連付けられている場合
    if (awsAddress.getInstanceNo() != null) {
        throw new AutoApplicationException("EAPI-100046", "AwsAddress", PARAM_NAME_ADDRESS_NO, addressNo);
    }

    // AWSアドレスを削除
    AwsProcessClient awsProcessClient = awsProcessClientFactory.createAwsProcessClient(user.getUserNo(),
            platform.getPlatformNo());
    awsAddressProcess.deleteAddress(awsProcessClient, awsAddress.getAddressNo());

    DeleteAwsAddressResponse response = new DeleteAwsAddressResponse();

    return response;
}
 
Example 19
Source File: WinServerEdit.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void attach() {
    setHeight(TAB_HEIGHT);
    setMargin(false, true, false, true);
    setSpacing(false);

    Form form = new Form();
    form.setSizeFull();
    form.addStyleName("win-server-edit-form");

    // サーバ名
    serverNameField = new TextField(ViewProperties.getCaption("field.serverName"));
    form.getLayout().addComponent(serverNameField);

    // ホスト名
    hostNameField = new TextField(ViewProperties.getCaption("field.hostName"));
    hostNameField.setWidth("100%");
    form.getLayout().addComponent(hostNameField);

    // コメント
    commentField = new TextField(ViewProperties.getCaption("field.comment"));
    commentField.setWidth("100%");
    form.getLayout().addComponent(commentField);

    // プラットフォーム
    CssLayout cloudLayout = new CssLayout();
    cloudLayout.setWidth("100%");
    cloudLayout.setCaption(ViewProperties.getCaption("field.cloud"));
    cloudLabel = new Label();
    cloudLayout.addComponent(cloudLabel);
    form.getLayout().addComponent(cloudLayout);

    // サーバ種別
    CssLayout imageLayout = new CssLayout();
    imageLayout.setWidth("100%");
    imageLayout.setCaption(ViewProperties.getCaption("field.image"));
    imageLabel = new Label();
    imageLayout.addComponent(imageLabel);
    form.getLayout().addComponent(imageLayout);

    // OS
    CssLayout osLayout = new CssLayout();
    osLayout.setWidth("100%");
    osLayout.setCaption(ViewProperties.getCaption("field.os"));
    osLabel = new Label();
    osLayout.addComponent(osLabel);
    form.getLayout().addComponent(osLayout);

    // ロードバランサでない場合
    if (BooleanUtils.isNotTrue(instance.getInstance().getLoadBalancer())) {
        // サービスを有効にするかどうか
        String enableService = Config.getProperty("ui.enableService");

        // サービスを有効にする場合
        if (StringUtils.isEmpty(enableService) || BooleanUtils.toBoolean(enableService)) {
            // 利用可能サービス
            Panel panel = new Panel();
            serviceTable = new AvailableServiceTable();
            panel.addComponent(serviceTable);
            form.getLayout().addComponent(panel);
            panel.setSizeFull();

            // サービス選択ボタン
            Button attachServiceButton = new Button(ViewProperties.getCaption("button.serverAttachService"));
            attachServiceButton.setDescription(ViewProperties.getCaption("description.serverAttachService"));
            attachServiceButton.setIcon(Icons.SERVICETAB.resource());
            attachServiceButton.addListener(new Button.ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    attachServiceButtonClick(event);
                }
            });

            HorizontalLayout layout = new HorizontalLayout();
            layout.setSpacing(true);
            layout.addComponent(attachServiceButton);
            Label label = new Label(ViewProperties.getCaption("label.serverAttachService"));
            layout.addComponent(label);
            layout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
            form.getLayout().addComponent(layout);
        }
    }

    addComponent(form);
}
 
Example 20
Source File: ConfigMain.java    From primecloud-controller with GNU General Public License v2.0 4 votes vote down vote up
public static void getPlatformNo(String platformName, String platformKind) {
    try {
        String platformSql = "SELECT * FROM PLATFORM";
        List<Platform> platforms = SQLMain.selectExecuteWithResult(platformSql, Platform.class);
        if (platforms == null || platforms.isEmpty()) {
            System.out.println("NULL");
            return;
        }
        for (Platform platform : platforms) {
            if (StringUtils.equals(platform.getPlatformName(), platformName)) {
                if (BooleanUtils.isNotTrue(platform.getSelectable())) {
                    //使用不可なプラットフォーム
                    System.out.println("DISABLE");
                    return;
                }

                String platformAwsSql = "SELECT * FROM PLATFORM_AWS WHERE PLATFORM_NO=" + platform.getPlatformNo();
                List<PlatformAws> platformAwses = SQLMain.selectExecuteWithResult(platformAwsSql, PlatformAws.class);
                if ("ec2".equals(platformKind) && "aws".equals(platform.getPlatformType()) &&
                    BooleanUtils.isFalse(platformAwses.get(0).getEuca())) {
                    System.out.println(platform.getPlatformNo().toString());
                    return;
                } else if ("vmware".equals(platformKind) && "vmware".equals(platform.getPlatformType())) {
                    System.out.println(platform.getPlatformNo().toString());
                    return;
                } else if ("eucalyptus".equals(platformKind) && "aws".equals(platform.getPlatformType()) &&
                           BooleanUtils.isTrue(platformAwses.get(0).getEuca())) {
                    System.out.println(platform.getPlatformNo().toString());
                    return;
                } else if ("nifty".equals(platformKind) && "nifty".equals(platform.getPlatformType())) {
                    System.out.println(platform.getPlatformNo().toString());
                    return;
                } else if ("cloudstack".equals(platformKind) && "cloudstack".equals(platform.getPlatformType())) {
                    System.out.println(platform.getPlatformNo().toString());
                    return;
                } else if ("vcloud".equals(platformKind) && "vcloud".equals(platform.getPlatformType())) {
                    System.out.println(platform.getPlatformNo().toString());
                    return;
                } else if ("azure".equals(platformKind) && "azure".equals(platform.getPlatformType())) {
                    System.out.println(platform.getPlatformNo().toString());
                    return;
                } else if ("openstack".equals(platformKind) && "openstack".equals(platform.getPlatformType())) {
                    System.out.println(platform.getPlatformNo().toString());
                    return;
                }
            }
        }
        System.out.println("OTHER");
    } catch (Exception e) {
        e.printStackTrace();
        log.error(e.getMessage(), e);
    }
}