Search in sources :

Example 1 with Resource

use of com.sequenceiq.cloudbreak.domain.Resource in project cloudbreak by hortonworks.

the class StackToStackResponseConverterTest method createSource.

@Override
public Stack createSource() {
    Stack stack = TestUtil.stack();
    Cluster cluster = TestUtil.cluster(TestUtil.blueprint(), stack, 1L);
    stack.setCluster(cluster);
    stack.setAvailabilityZone("avZone");
    Network network = new Network();
    network.setId(1L);
    stack.setNetwork(network);
    stack.setFailurePolicy(new FailurePolicy());
    Orchestrator orchestrator = new Orchestrator();
    orchestrator.setId(1L);
    orchestrator.setApiEndpoint("endpoint");
    orchestrator.setType("type");
    stack.setOrchestrator(orchestrator);
    stack.setParameters(new HashMap<>());
    stack.setCloudPlatform("OPENSTACK");
    stack.setGatewayPort(9443);
    stack.setCustomDomain("custom.domain");
    stack.setCustomHostname("hostname");
    stack.setStackAuthentication(new StackAuthentication());
    stack.getStackAuthentication().setPublicKey("rsakey");
    stack.getStackAuthentication().setLoginUserName("cloudbreak");
    stack.setHostgroupNameAsHostname(false);
    stack.setClusterNameAsSubdomain(false);
    Resource s3ArnResource = new Resource(ResourceType.S3_ACCESS_ROLE_ARN, "s3Arn", stack);
    stack.setResources(Collections.singleton(s3ArnResource));
    return stack;
}
Also used : StackAuthentication(com.sequenceiq.cloudbreak.domain.StackAuthentication) Network(com.sequenceiq.cloudbreak.domain.Network) Resource(com.sequenceiq.cloudbreak.domain.Resource) Cluster(com.sequenceiq.cloudbreak.domain.Cluster) FailurePolicy(com.sequenceiq.cloudbreak.domain.FailurePolicy) Orchestrator(com.sequenceiq.cloudbreak.domain.Orchestrator) Stack(com.sequenceiq.cloudbreak.domain.Stack)

Example 2 with Resource

use of com.sequenceiq.cloudbreak.domain.Resource in project cloudbreak by hortonworks.

the class StackUpscaleService method transformResults.

private Set<Resource> transformResults(Iterable<CloudResourceStatus> cloudResourceStatuses, Stack stack) {
    Set<Resource> retSet = new HashSet<>();
    for (CloudResourceStatus cloudResourceStatus : cloudResourceStatuses) {
        if (!cloudResourceStatus.isFailed()) {
            CloudResource cloudResource = cloudResourceStatus.getCloudResource();
            Resource resource = new Resource(cloudResource.getType(), cloudResource.getName(), cloudResource.getReference(), cloudResource.getStatus(), stack, null);
            retSet.add(resource);
        }
    }
    return retSet;
}
Also used : CloudResourceStatus(com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus) Resource(com.sequenceiq.cloudbreak.domain.Resource) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) HashSet(java.util.HashSet)

Example 3 with Resource

use of com.sequenceiq.cloudbreak.domain.Resource in project cloudbreak by hortonworks.

the class TestUtil method gcpResource.

public static Resource gcpResource(Long id, String instanceGroup) {
    Resource resource = new Resource();
    resource.setId(id);
    resource.setStack(stack());
    resource.setInstanceGroup(instanceGroup);
    resource.setResourceName("testResource");
    resource.setResourceType(ResourceType.GCP_INSTANCE);
    return resource;
}
Also used : Resource(com.sequenceiq.cloudbreak.domain.Resource)

Example 4 with Resource

use of com.sequenceiq.cloudbreak.domain.Resource in project cloudbreak by hortonworks.

the class CloudResourceToResourceConverter method convert.

@Override
public Resource convert(CloudResource source) {
    Resource domainResource = new Resource();
    domainResource.setResourceType(source.getType());
    domainResource.setResourceName(source.getName());
    domainResource.setResourceReference(source.getReference());
    domainResource.setResourceStatus(source.getStatus());
    domainResource.setInstanceGroup(source.getGroup());
    return domainResource;
}
Also used : Resource(com.sequenceiq.cloudbreak.domain.Resource) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource)

Example 5 with Resource

use of com.sequenceiq.cloudbreak.domain.Resource in project cloudbreak by hortonworks.

the class CloudResourcePersisterService method delete.

@Override
public ResourceNotification delete(ResourceNotification notification) {
    LOGGER.debug("Resource deletion notification received: {}", notification);
    Long stackId = notification.getCloudContext().getId();
    CloudResource cloudResource = notification.getCloudResource();
    ResourceRepository repository = getResourceRepository();
    Resource resource = repository.findByStackIdAndNameAndType(stackId, cloudResource.getName(), cloudResource.getType());
    if (resource != null) {
        repository.delete(resource);
    }
    return notification;
}
Also used : Resource(com.sequenceiq.cloudbreak.domain.Resource) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) ResourceRepository(com.sequenceiq.cloudbreak.repository.ResourceRepository)

Aggregations

Resource (com.sequenceiq.cloudbreak.domain.Resource)8 CloudResource (com.sequenceiq.cloudbreak.cloud.model.CloudResource)5 ResourceRepository (com.sequenceiq.cloudbreak.repository.ResourceRepository)3 Stack (com.sequenceiq.cloudbreak.domain.Stack)2 CloudResourceStatus (com.sequenceiq.cloudbreak.cloud.model.CloudResourceStatus)1 ResourceType (com.sequenceiq.cloudbreak.common.type.ResourceType)1 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)1 FailurePolicy (com.sequenceiq.cloudbreak.domain.FailurePolicy)1 InstanceGroup (com.sequenceiq.cloudbreak.domain.InstanceGroup)1 InstanceMetaData (com.sequenceiq.cloudbreak.domain.InstanceMetaData)1 Network (com.sequenceiq.cloudbreak.domain.Network)1 Orchestrator (com.sequenceiq.cloudbreak.domain.Orchestrator)1 StackAuthentication (com.sequenceiq.cloudbreak.domain.StackAuthentication)1 GatewayConfig (com.sequenceiq.cloudbreak.orchestrator.model.GatewayConfig)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1