Package com.sequenceiq.cloudbreak.domain

Examples of com.sequenceiq.cloudbreak.domain.Stack


    @Autowired
    private JsonHelper jsonHelper;

    @Override
    public List<Resource> create(GccProvisionContextObject pO, int index, List<Resource> resources) throws Exception {
        Stack stack = stackRepository.findById(pO.getStackId());

        Firewall firewall = new Firewall();
        Firewall.Allowed allowed1 = new Firewall.Allowed();
        allowed1.setIPProtocol("tcp");
        allowed1.setPorts(ImmutableList.of("1-65535"));

        Firewall.Allowed allowed2 = new Firewall.Allowed();
        allowed2.setIPProtocol("icmp");

        Firewall.Allowed allowed3 = new Firewall.Allowed();
        allowed3.setIPProtocol("udp");
        allowed3.setPorts(ImmutableList.of("1-65535"));

        firewall.setAllowed(ImmutableList.of(allowed1, allowed2, allowed3));
        firewall.setName(stack.getName() + "in");
        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


        return Arrays.asList(new Resource(resourceType(), stack.getName() + "in", stack));
    }

    @Override
    public Boolean delete(Resource resource, GccDeleteContextObject d) throws Exception {
        Stack stack = stackRepository.findById(d.getStackId());
        try {
            GccTemplate gccTemplate = (GccTemplate) stack.getTemplate();
            GccCredential gccCredential = (GccCredential) stack.getCredential();
            Operation execute = d.getCompute().firewalls().delete(gccCredential.getProjectId(), resource.getResourceName()).execute();
            Compute.ZoneOperations.Get zoneOperations = createZoneOperations(d.getCompute(), gccCredential, gccTemplate, execute);
            Compute.GlobalOperations.Get globalOperations = createGlobalOperations(d.getCompute(), gccCredential, gccTemplate, execute);
            GccRemoveReadyPollerObject gccRemoveReady =
                    new GccRemoveReadyPollerObject(zoneOperations, globalOperations, stack, resource.getResourceName());
View Full Code Here

    @Autowired
    private JsonHelper jsonHelper;

    @Override
    public List<Resource> create(GccProvisionContextObject po, int index, List<Resource> resources) throws Exception {
        Stack stack = stackRepository.findById(po.getStackId());
        GccCredential gccCredential = (GccCredential) stack.getCredential();
        GccTemplate gccTemplate = (GccTemplate) stack.getTemplate();

        List<AttachedDisk> listOfDisks = new ArrayList<>();
        listOfDisks.addAll(getBootDiskList(resources, gccCredential, gccTemplate));
        listOfDisks.addAll(getAttachedDisks(resources, gccCredential, gccTemplate));

        String name = String.format("%s-%s", stack.getName(), index);
        Instance instance = new Instance();
        instance.setMachineType(String.format("https://www.googleapis.com/compute/v1/projects/%s/zones/%s/machineTypes/%s",
                po.getProjectId(), gccTemplate.getGccZone().getValue(), gccTemplate.getGccInstanceType().getValue()));
        instance.setName(name);
        instance.setCanIpForward(Boolean.TRUE);
        instance.setNetworkInterfaces(getNetworkInterface(po.getProjectId(), stack.getName()));
        instance.setDisks(listOfDisks);
        Metadata metadata = new Metadata();
        metadata.setItems(Lists.<Metadata.Items>newArrayList());

        Metadata.Items sshMetaData = new Metadata.Items();
View Full Code Here

        return listOfDisks;
    }

    @Override
    public Boolean delete(Resource resource, GccDeleteContextObject d) throws Exception {
        Stack stack = stackRepository.findById(d.getStackId());
        try {
            GccTemplate gccTemplate = (GccTemplate) stack.getTemplate();
            GccCredential gccCredential = (GccCredential) stack.getCredential();
            Operation execute = d.getCompute().instances()
                    .delete(gccCredential.getProjectId(), gccTemplate.getGccZone().getValue(), resource.getResourceName()).execute();
            Compute.ZoneOperations.Get zoneOperations = createZoneOperations(d.getCompute(), gccCredential, gccTemplate, execute);
            Compute.GlobalOperations.Get globalOperations = createGlobalOperations(d.getCompute(), gccCredential, gccTemplate, execute);
            GccRemoveReadyPollerObject gccRemoveReady =
View Full Code Here

    }

    @Override
    public Optional<String> describe(Resource resource, GccDescribeContextObject dco) throws Exception {
        try {
            Stack stack = stackRepository.findById(dco.getStackId());
            GccTemplate gccTemplate = (GccTemplate) stack.getTemplate();
            GccCredential gccCredential = (GccCredential) stack.getCredential();
            Compute.Instances.Get getVm = dco.getCompute().instances().get(gccCredential.getProjectId(), gccTemplate.getGccZone().getValue(),
                    resource.getResourceName());
            return Optional.fromNullable(getVm.execute().toPrettyString());
        } catch (IOException e) {
            return Optional.fromNullable(jsonHelper.createJsonFromString(String.format("{\"VirtualMachine\": {%s}}", ERROR)).toString());
View Full Code Here

    @Autowired
    private Reactor reactor;

    public void setupMetadata(CloudPlatform cloudPlatform, Long stackId) {
        Stack stack = stackRepository.findOneWithLists(stackId);
        MDCBuilder.buildMdcContext(stack);
        try {
            MetadataSetup metadataSetup = metadataSetups.get(cloudPlatform);
            metadataSetup.setupMetadata(stack);
        } catch (Exception e) {
View Full Code Here

            reactor.notify(ReactorConfig.STACK_CREATE_FAILED_EVENT, Event.wrap(stackCreationFailure));
        }
    }

    public void updateMetadata(CloudPlatform cloudPlatform, Long stackId, Set<Resource> resourceSet) {
        Stack stack = stackRepository.findOneWithLists(stackId);
        MDCBuilder.buildMdcContext(stack);
        try {
            metadataSetups.get(cloudPlatform).addNewNodesToMetadata(stack, resourceSet);
        } catch (Exception e) {
            String errMessage = "Unhandled exception occurred while updating stack metadata.";
View Full Code Here

    @Autowired
    private StackRepository stackRepository;

    public StackDescription describeStackWithResources(Stack actualStack) {
        Stack stack = stackRepository.findById(actualStack.getId());
        Credential credential = stack.getCredential();
        final CloudPlatform cloudPlatform = credential.cloudPlatform();
        if (cloudPlatform.isWithTemplate()) {
            return cloudPlatformConnectors.get(cloudPlatform).describeStackWithResources(stack, stack.getCredential());
        } else {
            try {
                DetailedStackDescription dSD = new DetailedStackDescription();
                ResourceBuilderInit resourceBuilderInit = resourceBuilderInits.get(cloudPlatform);
                final DescribeContextObject describeContextObject = resourceBuilderInit.describeInit(stack);
                for (ResourceBuilder resourceBuilder : networkResourceBuilders.get(cloudPlatform)) {
                    for (Resource resource : stack.getResourcesByType(resourceBuilder.resourceType())) {
                        Optional<String> describe = resourceBuilder.describe(resource, describeContextObject);
                        if (describe.isPresent()) {
                            dSD.getResources().add(describe.get());
                        }
                    }
                }
                for (final ResourceBuilder resourceBuilder : instanceResourceBuilders.get(cloudPlatform)) {
                    List<Future<Optional<String>>> futures = new ArrayList<>();
                    for (final Resource resource : stack.getResourcesByType(resourceBuilder.resourceType())) {
                        Future<Optional<String>> submit = resourceBuilderExecutor.submit(new Callable<Optional<String>>() {
                            @Override
                            public Optional<String> call() throws Exception {
                                return resourceBuilder.describe(resource, describeContextObject);
                            }
                        });
                        futures.add(submit);
                    }
                    for (Future<Optional<String>> future : futures) {
                        if (future.get().isPresent()) {
                            dSD.getResources().add(future.get().get());
                        }
                    }
                }
                return dSD;
            } catch (Exception ex) {
                throw new InternalServerException(String.format("Stack describe problem on {} stack", stack.getId()), ex);
            }
        }
    }
View Full Code Here

    public void sendUptime() {
        Map<String, List<UptimeMessage>> uptimes = new HashMap<>();
        List<Cluster> clusters = (List<Cluster>) clusterRepository.findAll();
        long now = new Date().getTime();
        for (Cluster cluster : clusters) {
            Stack stack = stackRepository.findStackForCluster(cluster.getId());
            if (stack != null) {
                Long uptime = cluster.getCreationFinished() == null ? 0L : now - cluster.getCreationFinished();
                if (uptimes.containsKey(stack.getOwner())) {
                    uptimes.get(stack.getOwner()).add(new UptimeMessage(stack.getId(), uptime));
                } else {
                    uptimes.put(stack.getOwner(), new ArrayList<UptimeMessage>());
                    uptimes.get(stack.getOwner()).add(new UptimeMessage(stack.getId(), uptime));
                }
            }
        }
        if (!uptimes.isEmpty()) {
            for (Map.Entry<String, List<UptimeMessage>> longListEntry : uptimes.entrySet()) {
View Full Code Here

    @Autowired
    private Reactor reactor;

    public void setupProvisioning(CloudPlatform cloudPlatform, Long stackId) {
        Stack stack = stackRepository.findById(stackId);
        MDCBuilder.buildMdcContext(stack);
        try {
            ProvisionSetup provisionSetup = provisionSetups.get(cloudPlatform);
            provisionSetup.setupProvisioning(stackRepository.findById(stackId));
        } catch (Exception e) {
View Full Code Here

TOP

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

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.