Package com.sequenceiq.cloudbreak.domain

Examples of com.sequenceiq.cloudbreak.domain.Resource


                        final int index = j;
                        for (final String instanceId : instanceIds) {
                            Future<Boolean> submit = resourceBuilderExecutor.submit(new Callable<Boolean>() {
                                @Override
                                public Boolean call() throws Exception {
                                    Resource resource =
                                            new Resource(instanceResourceBuilders.get(cloudPlatform).get(index).resourceType(), instanceId, stack);
                                    Boolean delete = false;
                                    try {
                                        delete = instanceResourceBuilders.get(cloudPlatform).get(index).delete(resource, dCO);
                                    } catch (HttpResponseException ex) {
                                        LOGGER.error(String.format("Error occurred on stack under the instance remove"), ex);
View Full Code Here


        }
        AzureClient azureClient = po.getNewAzureClient(azureCredential);
        HttpResponseDecorator serviceCertificate = (HttpResponseDecorator) azureClient.createServiceCertificate(props);
        String requestId = (String) azureClient.getRequestId(serviceCertificate);
        waitUntilComplete(azureClient, requestId);
        return Arrays.asList(new Resource(resourceType(), name, stack));
    }
View Full Code Here

        } else if (!stack.isStackCompleted()) {
            stack = stackUpdater.updateStackCreateComplete(stack.getId());
            LOGGER.info("CloudFormation stack creation completed.");
            LOGGER.info("Publishing {} event.", ReactorConfig.PROVISION_COMPLETE_EVENT);
            Set<Resource> resourceSet = new HashSet<>();
            resourceSet.add(new Resource(ResourceType.CLOUDFORMATION_STACK, cfMessage.get("StackName"), stack));
            reactor.notify(ReactorConfig.PROVISION_COMPLETE_EVENT, Event.wrap(new ProvisionComplete(CloudPlatform.AWS, stack.getId(), resourceSet)));
        }
    }
View Full Code Here

        firewall.setSourceRanges(ImmutableList.of("10.0.0.0/16"));
        firewall.setNetwork(String.format("https://www.googleapis.com/compute/v1/projects/%s/global/networks/%s",
                pO.getProjectId(), pO.filterResourcesByType(ResourceType.GCC_NETWORK).get(0).getResourceName()));
        Compute.Firewalls.Insert firewallInsert = pO.getCompute().firewalls().insert(pO.getProjectId(), firewall);
        firewallInsert.execute();
        return Arrays.asList(new Resource(resourceType(), stack.getName() + "in", stack));
    }
View Full Code Here

        ins.setPrettyPrint(Boolean.TRUE);
        ins.execute();
        GccInstanceReadyPollerObject gccInstanceReady = new GccInstanceReadyPollerObject(po.getCompute(), stack, name);
        gccInstanceReadyPollerObjectPollingService.pollWithTimeout(gccInstanceReadyCheckerStatus, gccInstanceReady, POLLING_INTERVAL, MAX_POLLING_ATTEMPTS);
        return Arrays.asList(new Resource(resourceType(), name, stack));
    }
View Full Code Here

        firewall.setSourceRanges(ImmutableList.of("0.0.0.0/0"));
        firewall.setNetwork(String.format("https://www.googleapis.com/compute/v1/projects/%s/global/networks/%s",
                pO.getProjectId(), pO.filterResourcesByType(ResourceType.GCC_NETWORK).get(0).getResourceName()));
        Compute.Firewalls.Insert firewallInsert = pO.getCompute().firewalls().insert(pO.getProjectId(), firewall);
        firewallInsert.execute();
        return Arrays.asList(new Resource(resourceType(), stack.getName() + "out", stack));
    }
View Full Code Here

        Network network = new Network();
        network.setName(stack.getName());
        network.setIPv4Range("10.0.0.0/24");
        Compute.Networks.Insert networkInsert = contextObject.getCompute().networks().insert(contextObject.getProjectId(), network);
        networkInsert.execute();
        return Arrays.asList(new Resource(resourceType(), stack.getName(), stack));
    }
View Full Code Here

        AwsTemplate awsInfra = (AwsTemplate) stack.getTemplate();
        AwsCredential awsCredential = (AwsCredential) credential;
        DescribeStacksResult stackResult = null;
        DescribeStackResourcesResult resourcesResult = null;
        DescribeInstancesResult instancesResult = null;
        Resource resource = stack.getResourceByType(ResourceType.CLOUDFORMATION_STACK);
        if (resource != null) {
            try {
                AmazonCloudFormationClient client = awsStackUtil.createCloudFormationClient(awsInfra.getRegion(), awsCredential);
                DescribeStacksRequest stackRequest = new DescribeStacksRequest().withStackName(
                        resource.getResourceName()
                );
                stackResult = client.describeStacks(stackRequest);

                DescribeStackResourcesRequest resourcesRequest = new DescribeStackResourcesRequest().withStackName(
                        resource.getResourceName()
                );
                resourcesResult = client.describeStackResources(resourcesRequest);
            } catch (AmazonServiceException e) {
                if (CF_SERVICE_NAME.equals(e.getServiceName())
                        && e.getErrorMessage().equals(String.format("Stack:%s does not exist",
                        resource.getResourceName()))) {
                    LOGGER.error("Amazon CloudFormation stack {} doesn't exist. Returning null in describeStack.",
                            resource.getResourceName());
                    stackResult = new DescribeStacksResult();
                } else {
                    throw e;
                }
            }
            try {
                AmazonEC2Client ec2Client = awsStackUtil.createEC2Client(awsInfra.getRegion(), awsCredential);
                DescribeInstancesRequest instancesRequest = new DescribeInstancesRequest()
                        .withFilters(new Filter().withName("tag:" + INSTANCE_TAG_NAME).withValues(resource.getResourceName()));
                instancesResult = ec2Client.describeInstances(instancesRequest);
            } catch (Exception ex) {
                LOGGER.error(ex.getMessage(), ex);
                instancesResult = new DescribeInstancesResult();
            }
View Full Code Here

    public void deleteStack(Stack stack, Credential credential) {
        MDCBuilder.buildMdcContext(stack);
        LOGGER.info("Deleting stack: {}", stack.getId());
        AwsTemplate template = (AwsTemplate) stack.getTemplate();
        AwsCredential awsCredential = (AwsCredential) credential;
        Resource resource = stack.getResourceByType(ResourceType.CLOUDFORMATION_STACK);
        if (resource != null) {
            AmazonCloudFormationClient client = awsStackUtil.createCloudFormationClient(template.getRegion(), awsCredential);
            LOGGER.info("Deleting CloudFormation stack for stack: {} [cf stack id: {}]", stack.getId(),
                    resource.getResourceName());
            DeleteStackRequest deleteStackRequest = new DeleteStackRequest()
                    .withStackName(resource.getResourceName());
            client.deleteStack(deleteStackRequest);
        }
    }
View Full Code Here

                .withTemplateBody(cfTemplateBuilder.build("templates/aws-cf-stack.ftl", awsTemplate.getVolumeCount(), spotPriced))
                .withNotificationARNs((String) setupProperties.get(SnsTopicManager.NOTIFICATION_TOPIC_ARN_KEY))
                .withParameters(parameters);
        client.createStack(createStackRequest);
        Set<Resource> resources = new HashSet<>();
        resources.add(new Resource(ResourceType.CLOUDFORMATION_STACK, stackName, stack));
        Stack updatedStack = stackUpdater.updateStackResources(stack.getId(), resources);
        LOGGER.info("CloudFormation stack creation request sent with stack name: '{}' for stack: '{}'", stackName, updatedStack.getId());
    }
View Full Code Here

TOP

Related Classes of com.sequenceiq.cloudbreak.domain.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.