use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class AzureUtils method storeKeys.
public static DeferredResult<AuthCredentialsServiceState> storeKeys(ServiceHost host, StorageAccountListKeysResultInner keys, String endpointLink, List<String> tenantLinks) {
AuthCredentialsServiceState storageAuth = new AuthCredentialsServiceState();
storageAuth.documentSelfLink = UUID.randomUUID().toString();
storageAuth.customProperties = new HashMap<>();
for (StorageAccountKey key : keys.keys()) {
storageAuth.customProperties.put(getStorageAccountKeyName(storageAuth.customProperties), key.value());
}
storageAuth.tenantLinks = tenantLinks;
if (endpointLink != null) {
storageAuth.customProperties.put(CUSTOM_PROP_ENDPOINT_LINK, endpointLink);
}
Operation storageAuthOp = Operation.createPost(createInventoryUri(host, AuthCredentialsService.FACTORY_LINK)).setReferer(host.getPublicUri()).setBody(storageAuth);
return host.sendWithDeferredResult(storageAuthOp, AuthCredentialsServiceState.class);
}
use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class AzureLifecycleOperationServiceTest method setUp.
@Before
public void setUp() throws Exception {
try {
/*
* Init Class-specific (shared between test runs) vars.
*
* NOTE: Ultimately this should go to @BeforeClass, BUT BasicReusableHostTestCase.HOST
* is not accessible.
*/
if (computeHost == null) {
PhotonModelServices.startServices(this.host);
PhotonModelAdaptersRegistryAdapters.startServices(this.host);
PhotonModelMetricServices.startServices(this.host);
PhotonModelTaskServices.startServices(this.host);
AzureAdaptersTestUtils.startServicesSynchronouslyAzure(this.host);
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
// TODO: VSYM-992 - improve test/fix arbitrary timeout
this.host.setTimeoutSeconds(1200);
// Create a resource pool where the VM will be housed
ResourcePoolState resourcePool = createDefaultResourcePool(this.host);
AuthCredentialsServiceState authCredentials = createDefaultAuthCredentials(this.host, this.clientID, this.clientKey, this.subscriptionId, this.tenantId);
endpointState = createDefaultEndpointState(this.host, authCredentials.documentSelfLink);
// create a compute host for the Azure
computeHost = createDefaultComputeHost(this.host, resourcePool.documentSelfLink, endpointState);
}
if (!this.isMock) {
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(this.clientID, this.tenantId, this.clientKey, AzureEnvironment.AZURE);
this.computeManagementClient = new ComputeManagementClientImpl(credentials).withSubscriptionId(this.subscriptionId);
}
} catch (Throwable e) {
throw new Exception(e);
}
}
use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class AzureSubscriptionEndpointsEnumerationServiceTest method testAddSecondAzureSubscription.
private void testAddSecondAzureSubscription() throws Throwable {
// Request for creating computes for 1 Azure Subscriptions
AzureSubscription subscription = getAzureSubscription(SUBSCRIPTION_ID_2, ACCOUNT_ID_2);
createAzureEndpointsForSubscriptions(Collections.singletonList(subscription));
// Query the Endpoints to assert
ServiceDocumentQueryResult result = this.host.getExpandedFactoryState(UriUtils.buildUri(this.host, EndpointService.FACTORY_LINK));
Assert.assertEquals(3, result.documents.size());
// Assert the created Endpoint and other resources
result.documents.remove(this.endpointLink);
// Remove the endpoints created earlier
this.createdEndpointLinks.forEach(endpoint -> result.documents.remove(endpoint));
EndpointState endpointStateCreated = Utils.fromJson(result.documents.values().iterator().next(), EndpointState.class);
assertCreatedEndpoint(endpointStateCreated, SUBSCRIPTION_ID_2);
this.createdEndpointLinks.add(endpointStateCreated.documentSelfLink);
// Assert the root compute under the endpoint
ComputeState computeStateCreated = getServiceSynchronously(endpointStateCreated.computeLink, ComputeState.class);
assertCreatedComputeState(computeStateCreated, SUBSCRIPTION_ID_2, ACCOUNT_ID_2);
// Assert the partial AuthCredentialsState
AuthCredentialsServiceState authCreated = getServiceSynchronously(endpointStateCreated.authCredentialsLink, AuthCredentialsServiceState.class);
assertAuthCredentialState(authCreated, SUBSCRIPTION_ID_2);
}
use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class TestAWSImageEnumerationTask method beforeTest.
@Before
public final void beforeTest() throws Throwable {
CommandLineArgumentParser.parseFromProperties(this);
if (this.isMock) {
return;
}
if (AMAZON_PARAVIRTUAL_IMAGE_NAME == null || AMAZON_HVM_IMAGE_NAME == null) {
// create credentials
AuthCredentialsServiceState creds = new AuthCredentialsServiceState();
creds.privateKey = this.secretKey;
creds.privateKeyId = this.accessKey;
AmazonEC2AsyncClient client = AWSUtils.getAsyncClient(creds, this.regionId, getExecutor());
// Get arbitrary PARAVIRTUAL image name
AMAZON_PARAVIRTUAL_IMAGE_NAME = lookupAwsImage(client, AWSConstants.AWS_IMAGE_VIRTUALIZATION_TYPE_PARAVIRTUAL);
// Get arbitrary HVM image name
AMAZON_HVM_IMAGE_NAME = lookupAwsImage(client, AWSConstants.AWS_IMAGE_VIRTUALIZATION_TYPE_HVM);
{
Filter nameFilter = new Filter("name").withValues(AMAZON_PARAVIRTUAL_IMAGE_NAME);
// Serialize the list of filters to JSON string
AMAZON_PUBLIC_IMAGE_FILTER_SINGLE = Utils.toJson(Arrays.asList(nameFilter));
}
{
Filter nameFilter = new Filter("name").withValues(AMAZON_PARAVIRTUAL_IMAGE_NAME, AMAZON_HVM_IMAGE_NAME);
// Serialize the list of filters to JSON string
AMAZON_PUBLIC_IMAGE_FILTER_PARTITIONING = Utils.toJson(Arrays.asList(nameFilter));
}
}
}
use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class TestAWSUtils method testClientCreation.
@Test
public void testClientCreation() throws Throwable {
AuthCredentialsServiceState creds = new AuthCredentialsServiceState();
creds.privateKey = this.privateKey;
creds.privateKeyId = this.privateKeyId;
AWSUtils.getAsyncClient(creds, this.region, getExecutor());
}
Aggregations