use of com.vmware.photon.controller.model.adapters.awsadapter.util.AWSNetworkClient in project photon-model by vmware.
the class TestProvisionAWSSecurityGroup method setUp.
@Before
public void setUp() throws Exception {
CommandLineArgumentParser.parseFromProperties(this);
// ignore if any of the required properties are missing
org.junit.Assume.assumeTrue(TestUtils.isNull(this.privateKey, this.privateKeyId, this.region, this.vpcId, this.subnetId));
try {
PhotonModelServices.startServices(this.host);
PhotonModelMetricServices.startServices(this.host);
PhotonModelTaskServices.startServices(this.host);
PhotonModelAdaptersRegistryAdapters.startServices(this.host);
AWSAdaptersTestUtils.startServicesSynchronously(this.host);
// start the aws sg service
this.host.startService(Operation.createPost(UriUtils.buildUri(this.host, AWSSecurityGroupService.class)), new AWSSecurityGroupService());
this.provisionSecurityGroupFactory = UriUtils.buildUri(this.host, ProvisionSecurityGroupTaskService.FACTORY_LINK);
this.netClient = new AWSNetworkClient(TestUtils.getClient(this.privateKeyId, this.privateKey, this.region, false));
this.vpc = this.netClient.getVPC(this.vpcId);
assertNotNull(this.vpc);
AuthCredentialsServiceState creds = new AuthCredentialsServiceState();
creds.privateKey = this.privateKey;
creds.privateKeyId = this.privateKeyId;
TestContext ec2WaitContext = new TestContext(1, Duration.ofSeconds(30L));
AWSUtils.getEc2AsyncClient(creds, this.region, getExecutor()).exceptionally(t -> {
ec2WaitContext.fail(t);
throw new CompletionException(t);
}).thenAccept(ec2Client -> {
this.ec2client = ec2Client;
ec2WaitContext.complete();
});
ec2WaitContext.await();
} catch (Throwable e) {
throw new Exception(e);
}
}
Aggregations