use of com.sequenceiq.cloudbreak.cloud.gcp.service.GcpResourceNameService in project cloudbreak by hortonworks.
the class GcpInstanceResourceBuilderTest method setUp.
@Before
public void setUp() {
privateId = 0L;
name = "master";
flavor = "m1.medium";
instanceId = "SOME_ID";
volumes = Arrays.asList(new Volume("/hadoop/fs1", "HDD", 1), new Volume("/hadoop/fs2", "HDD", 1));
List<SecurityRule> rules = Collections.singletonList(new SecurityRule("0.0.0.0/0", new PortDefinition[] { new PortDefinition("22", "22"), new PortDefinition("443", "443") }, "tcp"));
security = new Security(rules, null);
Location location = Location.location(Region.region("region"), AvailabilityZone.availabilityZone("az"));
Map<InstanceGroupType, String> userData = ImmutableMap.of(InstanceGroupType.CORE, "CORE", InstanceGroupType.GATEWAY, "GATEWAY");
image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "", "default", "default-id");
CloudContext cloudContext = new CloudContext(privateId, "testname", "GCP", "owner");
CloudCredential cloudCredential = new CloudCredential(privateId, "credentialname");
cloudCredential.putParameter("projectId", "projectId");
String projectId = GcpStackUtil.getProjectId(cloudCredential);
String serviceAccountId = GcpStackUtil.getServiceAccountId(cloudCredential);
authenticatedContext = new AuthenticatedContext(cloudContext, cloudCredential);
context = new GcpContext(cloudContext.getName(), location, projectId, serviceAccountId, compute, false, 30, false);
List<CloudResource> networkResources = Arrays.asList(new Builder().type(ResourceType.GCP_NETWORK).name("network-test").build());
context.addNetworkResources(networkResources);
operation = new Operation();
operation.setName("operation");
operation.setHttpErrorStatusCode(null);
GcpResourceNameService resourceNameService = new GcpResourceNameService();
ReflectionTestUtils.setField(resourceNameService, "maxResourceNameLength", 50);
ReflectionTestUtils.setField(builder, "resourceNameService", resourceNameService);
}
use of com.sequenceiq.cloudbreak.cloud.gcp.service.GcpResourceNameService in project cloudbreak by hortonworks.
the class GcpAttachedDiskResourceBuilder method create.
@Override
public List<CloudResource> create(GcpContext context, long privateId, AuthenticatedContext auth, Group group, Image image) {
List<CloudResource> cloudResources = new ArrayList<>();
CloudInstance instance = group.getReferenceInstanceConfiguration();
InstanceTemplate template = instance.getTemplate();
GcpResourceNameService resourceNameService = getResourceNameService();
String groupName = group.getName();
CloudContext cloudContext = auth.getCloudContext();
String stackName = cloudContext.getName();
for (int i = 0; i < template.getVolumes().size(); i++) {
String resourceName = resourceNameService.resourceName(resourceType(), stackName, groupName, privateId, i);
cloudResources.add(createNamedResource(resourceType(), resourceName));
}
return cloudResources;
}
Aggregations