Examples of GccCredential


Examples of com.sequenceiq.cloudbreak.domain.GccCredential

        return credentialJson;
    }

    @Override
    public GccCredential convert(CredentialJson json) {
        GccCredential gccCredential = new GccCredential();
        gccCredential.setName(json.getName());
        gccCredential.setServiceAccountId(String.valueOf(json.getParameters().get(GccCredentialParam.SERVICE_ACCOUNT_ID.getName())));
        gccCredential.setServiceAccountPrivateKey(String.valueOf(json.getParameters().get(GccCredentialParam.SERVICE_ACCOUNT_PRIVATE_KEY.getName())));
        gccCredential.setProjectId(String.valueOf(json.getParameters().get(GccCredentialParam.PROJECTID.getName())));
        gccCredential.setCloudPlatform(CloudPlatform.GCC);
        gccCredential.setDescription(json.getDescription());
        gccCredential.setPublicKey(json.getPublicKey());
        gccCredentialInitializer.init(gccCredential);
        return gccCredential;
    }
View Full Code Here

Examples of com.sequenceiq.cloudbreak.domain.GccCredential

    }

    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

Examples of com.sequenceiq.cloudbreak.domain.GccCredential

    @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

Examples of com.sequenceiq.cloudbreak.domain.GccCredential

    @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

Examples of com.sequenceiq.cloudbreak.domain.GccCredential

    @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());
            gccRemoveReadyPollerObjectPollingService.pollWithTimeout(gccRemoveCheckerStatus, gccRemoveReady, POLLING_INTERVAL, MAX_POLLING_ATTEMPTS);
View Full Code Here

Examples of com.sequenceiq.cloudbreak.domain.GccCredential

    @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());
            gccRemoveReadyPollerObjectPollingService.pollWithTimeout(gccRemoveCheckerStatus, gccRemoveReady, POLLING_INTERVAL, MAX_POLLING_ATTEMPTS);
View Full Code Here

Examples of com.sequenceiq.cloudbreak.domain.GccCredential

    @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 =
                    new GccRemoveReadyPollerObject(zoneOperations, globalOperations, stack, resource.getResourceName());
            gccRemoveReadyPollerObjectPollingService.pollWithTimeout(gccRemoveCheckerStatus, gccRemoveReady, POLLING_INTERVAL, MAX_POLLING_ATTEMPTS);
View Full Code Here

Examples of com.sequenceiq.cloudbreak.domain.GccCredential

    }

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

Examples of com.sequenceiq.cloudbreak.domain.GccCredential

        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 {
                    Bucket bucket = new Bucket();
                    bucket.setName(credential.getProjectId() + time);
                    bucket.setStorageClass("STANDARD");
                    Storage.Buckets.Insert ins = storage.buckets().insert(credential.getProjectId(), bucket);
                    ins.execute();
                } catch (GoogleJsonResponseException ex) {
                    if (ex.getStatusCode() != CONFLICT) {
                        throw ex;
                    }
                }
                Storage.Objects.Copy copy = storage.objects().copy(BUCKET_NAME, TAR_NAME, credential.getProjectId() + time, TAR_NAME,
                        new StorageObject());
                copy.execute();

                Image image = new Image();
                image.setName(GccImageType.DEBIAN_HACK.getImageName());
                Image.RawDisk rawDisk = new Image.RawDisk();
                rawDisk.setSource(String.format("http://storage.googleapis.com/%s/%s", credential.getProjectId() + time, TAR_NAME));
                image.setRawDisk(rawDisk);
                Compute.Images.Insert ins1 = compute.images().insert(credential.getProjectId(), image);
                ins1.execute();
            }
        } catch (IOException e) {
            LOGGER.error(String.format("Error occurs on %s stack under the setup", stack.getId()), e);
            throw new InternalServerException(e.getMessage());
View Full Code Here

Examples of com.sequenceiq.cloudbreak.domain.GccCredential

    private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
    private static final List<String> SCOPES = Arrays.asList(ComputeScopes.COMPUTE, StorageScopes.DEVSTORAGE_FULL_CONTROL);

    @Override
    public GccProvisionContextObject provisionInit(Stack stack, String userData) throws Exception {
        GccCredential credential = (GccCredential) stack.getCredential();
        GccProvisionContextObject gccProvisionContextObject = new GccProvisionContextObject(stack.getId(), credential.getProjectId(),
                buildCompute(stack, credential, stack.getName()));
        gccProvisionContextObject.setUserData(userData);
        return gccProvisionContextObject;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.