Package com.sequenceiq.cloudbreak.domain

Examples of com.sequenceiq.cloudbreak.domain.GccTemplate


        return gccTemplateJson;
    }

    @Override
    public GccTemplate convert(TemplateJson json) {
        GccTemplate gccTemplate = new GccTemplate();
        gccTemplate.setName(json.getName());
        gccTemplate.setDescription(json.getDescription());
        gccTemplate.setVolumeCount((json.getVolumeCount() == null) ? 0 : json.getVolumeCount());
        gccTemplate.setVolumeSize((json.getVolumeSize() == null) ? 0 : json.getVolumeSize());
        gccTemplate.setGccImageType(GccImageType.valueOf(json.getParameters().get(GccTemplateParam.IMAGETYPE.getName()).toString()));
        gccTemplate.setGccInstanceType(GccInstanceType.valueOf(json.getParameters().get(GccTemplateParam.INSTANCETYPE.getName()).toString()));
        gccTemplate.setGccZone(GccZone.valueOf(json.getParameters().get(GccTemplateParam.ZONE.getName()).toString()));
        Object containerCount = json.getParameters().get(GccTemplateParam.CONTAINERCOUNT.getName());
        if (containerCount != null) {
            gccTemplate.setContainerCount(Integer.valueOf(containerCount.toString()));
        }
        Object type = json.getParameters().get(GccTemplateParam.TYPE.getName());
        if (type != null) {
            gccTemplate.setGccRawDiskType(GccRawDiskType.valueOf(type.toString()));
        }
        gccTemplate.setDescription(json.getDescription());
        return gccTemplate;
    }
View Full Code Here


    @Override
    public void setupMetadata(Stack stack) {
        MDCBuilder.buildMdcContext(stack);
        Set<CoreInstanceMetaData> instanceMetaDatas = new HashSet<>();
        List<Resource> resourcesByType = stack.getResourcesByType(ResourceType.GCC_INSTANCE);
        GccTemplate template = (GccTemplate) stack.getTemplate();
        instanceMetaDatas = collectMetaData(stack, template, resourcesByType);
        LOGGER.info("Publishing {} event [StackId: '{}']", ReactorConfig.METADATA_SETUP_COMPLETE_EVENT, stack.getId());
        reactor.notify(ReactorConfig.METADATA_SETUP_COMPLETE_EVENT,
                Event.wrap(new MetadataSetupComplete(CloudPlatform.GCC, stack.getId(), instanceMetaDatas)));
    }
View Full Code Here

    public CoreInstanceMetaData getMetadata(Stack stack, Compute compute, String resource) {
        MDCBuilder.buildMdcContext(stack);
        try {
            GccCredential credential = (GccCredential) stack.getCredential();
            GccTemplate template = (GccTemplate) stack.getTemplate();
            Compute.Instances.Get instanceGet = compute.instances().get(
                    credential.getProjectId(), template.getGccZone().getValue(), resource);
            Instance executeInstance = instanceGet.execute();
            CoreInstanceMetaData coreInstanceMetaData = new CoreInstanceMetaData(
                    resource,
                    executeInstance.getNetworkInterfaces().get(0).getNetworkIP(),
                    executeInstance.getNetworkInterfaces().get(0).getAccessConfigs().get(0).getNatIP(),
                    template.getVolumeCount(),
                    longName(resource, credential.getProjectId()),
                    template.getContainerCount()
            );
            return coreInstanceMetaData;
        } catch (IOException e) {
            LOGGER.error(String.format("Instance %s is not reachable: %s", resource, e.getMessage()), e);
        }
View Full Code Here

    @Override
    public boolean checkStatus(GccInstanceReadyPollerObject gccInstanceReadyPollerObject) {
        MDCBuilder.buildMdcContext(gccInstanceReadyPollerObject.getStack());
        LOGGER.info("Checking status of Gcc Instance '{}'.", gccInstanceReadyPollerObject.getName());
        GccTemplate gccTemplate = (GccTemplate) gccInstanceReadyPollerObject.getStack().getTemplate();
        GccCredential gccCredential = (GccCredential) gccInstanceReadyPollerObject.getStack().getCredential();
        try {
            Compute.Instances.Get getInstances = gccInstanceReadyPollerObject
                    .getCompute()
                    .instances()
                    .get(gccCredential.getProjectId(), gccTemplate.getGccZone().getValue(), gccInstanceReadyPollerObject.getName());
            String status = getInstances.execute().getStatus();
            return RUNNING.equals(status) ? true : false;
        } catch (NullPointerException | IOException e) {
            return false;
        }
View Full Code Here

    @Override
    public boolean checkStatus(GccDiskReadyPollerObject gccDiskReadyPollerObject) {
        MDCBuilder.buildMdcContext(gccDiskReadyPollerObject.getStack());
        LOGGER.info("Checking status of Gcc Disk '{}'.", gccDiskReadyPollerObject.getName());
        GccTemplate gccTemplate = (GccTemplate) gccDiskReadyPollerObject.getStack().getTemplate();
        GccCredential credential = (GccCredential) gccDiskReadyPollerObject.getStack().getCredential();
        try {
            Compute.Disks.Get getDisks = gccDiskReadyPollerObject
                    .getCompute()
                    .disks()
                    .get(credential.getProjectId(), gccTemplate.getGccZone().getValue(), gccDiskReadyPollerObject.getName());
            String status = getDisks.execute().getStatus();
            return READY.equals(status) ? true : false;
        } catch (NullPointerException | IOException e) {
            return false;
        }
View Full Code Here

    @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 =
View Full Code Here

    @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 =
View Full Code Here

    @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().networks().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 =
View Full Code Here

    public void setupProvisioning(Stack stack) {
        MDCBuilder.buildMdcContext(stack);
        try {
            Storage storage = gccStackUtil.buildStorage((GccCredential) stack.getCredential(), stack);
            Compute compute = gccStackUtil.buildCompute((GccCredential) stack.getCredential(), stack.getName());
            GccTemplate template = (GccTemplate) stack.getTemplate();
            GccCredential credential = (GccCredential) stack.getCredential();
            ImageList list = compute.images().list(credential.getProjectId()).execute();
            Long time = new Date().getTime();
            if (!containsSpecificImage(list)) {
                try {
View Full Code Here

    private ConcurrentTaskExecutor resourceBuilderExecutor;

    @Override
    public List<Resource> create(final GccProvisionContextObject po, int index, List<Resource> resources) throws Exception {
        final Stack stack = stackRepository.findById(po.getStackId());
        final GccTemplate gccTemplate = (GccTemplate) stack.getTemplate();
        final List<Resource> resourcesListTemp = new ArrayList<>();
        final String name = String.format("%s-%s", stack.getName(), index);

        List<Future<Resource>> futures = new ArrayList<>();
        for (int i = 0; i < gccTemplate.getVolumeCount(); i++) {
            final int indexVolume = i;
            Future<Resource> submit = resourceBuilderExecutor.submit(new Callable<Resource>() {
                @Override
                public Resource call() throws Exception {
                    String value = name + "-" + indexVolume;
                    Disk disk = new Disk();
                    disk.setSizeGb(gccTemplate.getVolumeSize().longValue());
                    disk.setName(value);
                    disk.setKind(((GccTemplate) stack.getTemplate()).getGccRawDiskType().getUrl(po.getProjectId(), gccTemplate.getGccZone()));
                    Compute.Disks.Insert insDisk = po.getCompute().disks().insert(po.getProjectId(), gccTemplate.getGccZone().getValue(), disk);
                    insDisk.execute();
                    GccDiskReadyPollerObject gccDiskReady = new GccDiskReadyPollerObject(po.getCompute(), stack, value);
                    gccDiskReadyPollerObjectPollingService.pollWithTimeout(gccDiskCheckerStatus, gccDiskReady, POLLING_INTERVAL, MAX_POLLING_ATTEMPTS);
                    return new Resource(resourceType(), value, stack);
                }
View Full Code Here

TOP

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

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.