use of com.sequenceiq.cloudbreak.cloud.gcp.context.GcpContext 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.context.GcpContext in project cloudbreak by hortonworks.
the class GcpCredentialConnector method verify.
@Override
public CloudCredentialStatus verify(@Nonnull AuthenticatedContext authenticatedContext) {
Objects.requireNonNull(authenticatedContext);
LOGGER.info("Verify credential: {}", authenticatedContext.getCloudCredential());
GcpContext gcpContext = gcpContextBuilder.contextInit(authenticatedContext.getCloudContext(), authenticatedContext, null, null, false);
try {
checkGcpContextValidity(gcpContext);
preCheckOfGooglePermission(gcpContext);
} catch (TokenResponseException te) {
return createFailedCloudCredentialStatusWithExc(te, authenticatedContext, getErrDescriptionFromTokenResponse(te));
} catch (Exception e) {
return createFailedCloudCredentialStatusWithExc(e, authenticatedContext, Optional.empty());
}
return new CloudCredentialStatus(authenticatedContext.getCloudCredential(), CredentialStatus.VERIFIED);
}
Aggregations