本文整理汇总了Java中com.microsoft.azure.AzureEnvironment.AZURE属性的典型用法代码示例。如果您正苦于以下问题:Java AzureEnvironment.AZURE属性的具体用法?Java AzureEnvironment.AZURE怎么用?Java AzureEnvironment.AZURE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.microsoft.azure.AzureEnvironment
的用法示例。
在下文中一共展示了AzureEnvironment.AZURE属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAzureEnvironment
protected AzureEnvironment getAzureEnvironment(String environment) {
if (StringUtils.isEmpty(environment)) {
return AzureEnvironment.AZURE;
}
switch (environment.toUpperCase(Locale.ENGLISH)) {
case "AZURE_CHINA":
return AzureEnvironment.AZURE_CHINA;
case "AZURE_GERMANY":
return AzureEnvironment.AZURE_GERMANY;
case "AZURE_US_GOVERNMENT":
return AzureEnvironment.AZURE_US_GOVERNMENT;
default:
return AzureEnvironment.AZURE;
}
}
示例2: getAzureConfig
/**
* Configures authentication credential for Azure.
*/
public static ApplicationTokenCredentials getAzureConfig(
AuthCredentialsServiceState parentAuth) {
String clientId = parentAuth.privateKeyId;
String clientKey = EncryptionUtils.decrypt(parentAuth.privateKey);
String tenantId = parentAuth.customProperties.get(AzureConstants.AZURE_TENANT_ID);
AzureEnvironment azureEnvironment = AzureEnvironment.AZURE;
if (AzureUtils.isAzureClientMock()) {
azureEnvironment.endpoints().put(AzureEnvironment.Endpoint.ACTIVE_DIRECTORY.toString(),
AzureUtils.getAzureBaseUri());
}
return new ApplicationTokenCredentials(clientId, tenantId, clientKey, azureEnvironment);
}
示例3: getAzureEnvironmentFromDeprecatedConfig
/**
* Gets the corresponding AzureEnvironment from the deprecated plugin v1 management url.
*
* N.b. that Azure China is currently not supported.
*
* @param managementUrl plugin v1 endpoint
* @return the AzureEnvironment or null if it doesn't exist
*/
static AzureEnvironment getAzureEnvironmentFromDeprecatedConfig(String managementUrl) {
if (managementUrl == null) {
return null;
}
managementUrl = managementUrl.replaceAll("/$", "");
if (managementUrl.equals(AzureEnvironment.AZURE.managementEndpoint().replaceAll("/$", ""))) {
return AzureEnvironment.AZURE;
} else if (managementUrl.equals(AzureEnvironment.AZURE_US_GOVERNMENT.managementEndpoint()
.replaceAll("/$", ""))) {
return AzureEnvironment.AZURE_US_GOVERNMENT;
} else if (managementUrl.equals(AzureEnvironment.AZURE_GERMANY.managementEndpoint()
.replaceAll("/$", ""))) {
return AzureEnvironment.AZURE_GERMANY;
}
// Azure China is currently not supported
// the deprecated config doesn't match any AzureEnvironment; return null
return null;
}
示例4: get
@Override
public Azure get() {
final String[] split = cloud.credential().user().split(DELIMITER);
if (split.length != 2) {
throw new IllegalStateException("Expected user to be of format clientId:tenant");
}
String clientId = split[0];
String tenant = split[1];
String key = cloud.credential().password();
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(clientId, tenant, key,
AzureEnvironment.AZURE);
try {
return Azure.authenticate(credentials).withDefaultSubscription();
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
示例5: validateAdlsFileSystem
private void validateAdlsFileSystem(CloudCredential credential, FileSystem fileSystem) {
Map<String, Object> credentialAttributes = credential.getParameters();
String clientSecret = String.valueOf(credentialAttributes.get(AdlsFileSystemConfiguration.CREDENTIAL_SECRET_KEY));
String subscriptionId = String.valueOf(credentialAttributes.get(AdlsFileSystemConfiguration.SUBSCRIPTION_ID));
String clientId = String.valueOf(credentialAttributes.get(AdlsFileSystemConfiguration.ACCESS_KEY));
String tenantId = fileSystem.getStringParameter(AdlsFileSystemConfiguration.TENANT_ID);
String accountName = fileSystem.getStringParameter(FileSystemConfiguration.ACCOUNT_NAME);
ApplicationTokenCredentials creds = new ApplicationTokenCredentials(clientId, tenantId, clientSecret, AzureEnvironment.AZURE);
DataLakeStoreAccountManagementClient adlsClient = new DataLakeStoreAccountManagementClientImpl(creds);
adlsClient.withSubscriptionId(subscriptionId);
List<DataLakeStoreAccount> dataLakeStoreAccounts = adlsClient.accounts().list();
boolean validAccountname = false;
for (DataLakeStoreAccount account : dataLakeStoreAccounts) {
if (account.name().equalsIgnoreCase(accountName)) {
validAccountname = true;
break;
}
}
if (!validAccountname) {
throw new CloudConnectorException("The provided file system account name does not belong to a valid ADLS account");
}
}
示例6: getEnvironment
private AzureEnvironment getEnvironment()
{
switch (azureEnvironmentName)
{
case "AZURE":
return AzureEnvironment.AZURE;
case "AZURE_CHINA":
return AzureEnvironment.AZURE_CHINA;
case "AZURE_GERMANY":
return AzureEnvironment.AZURE_GERMANY;
case "AZURE_US_GOVERNMENT":
return AzureEnvironment.AZURE_US_GOVERNMENT;
}
throw new IllegalArgumentException("Invalid setting for azure.environment " + azureEnvironmentName);
}
示例7: environment
AzureEnvironment environment() {
if (environmentName == null) {
return null;
} else if (environmentName.equalsIgnoreCase("AzureCloud")) {
return AzureEnvironment.AZURE;
} else if (environmentName.equalsIgnoreCase("AzureChinaCloud")) {
return AzureEnvironment.AZURE_CHINA;
} else if (environmentName.equalsIgnoreCase("AzureGermanCloud")) {
return AzureEnvironment.AZURE_GERMANY;
} else if (environmentName.equalsIgnoreCase("AzureUSGovernment")) {
return AzureEnvironment.AZURE_US_GOVERNMENT;
} else {
return null;
}
}
示例8: parseEnvironment
static AzureEnvironment parseEnvironment(String environmentName) {
switch (environmentName) {
case "AZURE":
return AzureEnvironment.AZURE;
case "AZURE_CHINA":
return AzureEnvironment.AZURE_CHINA;
case "AZURE_US_GOVERNMENT":
return AzureEnvironment.AZURE_US_GOVERNMENT;
case "AZURE_GERMANY":
return AzureEnvironment.AZURE_GERMANY;
default:
throw new IllegalArgumentException("auth: unrecognized Azure environment: " + environmentName);
}
}
示例9: setUp
@Override
@Before
public void setUp() throws Throwable {
CommandLineArgumentParser.parseFromProperties(this);
if (computeHost == null) {
PhotonModelServices.startServices(this.host);
PhotonModelTaskServices.startServices(this.host);
PhotonModelAdaptersRegistryAdapters.startServices(this.host);
AzureAdapters.startServices(this.host);
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelAdaptersRegistryAdapters.LINKS);
this.host.waitForServiceAvailable(AzureAdapters.LINKS);
// TODO: VSYM-992 - improve test/fix arbitrary timeout
this.host.setTimeoutSeconds(600);
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);
NetworkManagementClientImpl networkManagementClient = new NetworkManagementClientImpl(
credentials).withSubscriptionId(this.subscriptionId);
ResourceManagementClientImpl resourceManagementClient =
new ResourceManagementClientImpl(credentials).withSubscriptionId(this.subscriptionId);
this.vNetClient = networkManagementClient.virtualNetworks();
this.rgOpsClient = resourceManagementClient.resourceGroups();
this.subnetsClient = networkManagementClient.subnets();
ResourceGroupInner rg = new ResourceGroupInner();
rg.withName(this.rgName);
rg.withLocation(this.regionId);
this.rgOpsClient.createOrUpdate(this.rgName, rg);
VirtualNetworkInner vNet = new VirtualNetworkInner();
// Azure's custom serializers don't handle Collections.SingletonList well, so use ArrayList
AddressSpace addressSpace = new AddressSpace();
List<String> cidrs = new ArrayList<>();
cidrs.add(AZURE_DEFAULT_VPC_CIDR);
addressSpace.withAddressPrefixes(cidrs);
vNet.withAddressSpace(addressSpace);
vNet.withLocation(this.regionId);
this.vNetClient.createOrUpdate(this.rgName, this.vNetName, vNet);
}
ResourceGroupState rgState = createDefaultResourceGroupState(
this.host,
this.rgName,
computeHost, endpointState,
ResourceGroupStateType.AzureResourceGroup);
this.networkState = createNetworkState(rgState.documentSelfLink);
}
示例10: 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);
PhotonModelMetricServices.startServices(this.host);
PhotonModelAdaptersRegistryAdapters.startServices(this.host);
PhotonModelTaskServices.startServices(this.host);
AzureAdapters.startServices(this.host);
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelAdaptersRegistryAdapters.LINKS);
this.host.waitForServiceAvailable(AzureAdapters.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);
}
}
示例11: 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);
AzureAdapters.startServices(this.host);
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelAdaptersRegistryAdapters.LINKS);
this.host.waitForServiceAvailable(AzureAdapters.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);
}
}
示例12: setUp
@Override
@Before
public void setUp() throws Exception {
for (int i = 0; i < numOfVMsToTest; i++) {
String azureName = generateName(azureVMNamePrefix);
azureVMNames.add(azureName);
nicSpecs.add(initializeNicSpecs(azureName, false, true, false));
}
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);
PhotonModelTaskServices.startServices(this.host);
PhotonModelAdaptersRegistryAdapters.startServices(this.host);
AzureAdapters.startServices(this.host);
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelAdaptersRegistryAdapters.LINKS);
this.host.waitForServiceAvailable(AzureAdapters.LINKS);
// TODO: VSYM-992 - improve test/fix arbitrary timeout
this.host.setTimeoutSeconds(this.timeoutSeconds);
// Create a resource pool where the VMs 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);
}
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
this.host.waitForServiceAvailable(AzureAdapters.LINKS);
this.nodeStatsUri = UriUtils.buildUri(this.host.getUri(), ServiceUriPaths.CORE_MANAGEMENT);
this.maxMemoryInMb = this.host.getState().systemInfo.maxMemoryByteCount / BYTES_TO_MB;
internalTagResourcesMap.put(NetworkState.class, NETWORK_TAG_TYPE_VALUE);
internalTagResourcesMap.put(SubnetState.class, SUBNET_TAG_TYPE_VALUE);
internalTagResourcesMap
.put(NetworkInterfaceState.class, NETWORK_INTERFACE_TAG_TYPE_VALUE);
if (!this.isMock) {
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(
this.clientID,
this.tenantId, this.clientKey, AzureEnvironment.AZURE);
this.computeManagementClient = new ComputeManagementClientImpl(credentials)
.withSubscriptionId(this.subscriptionId);
this.resourceManagementClient = new ResourceManagementClientImpl(credentials)
.withSubscriptionId(this.subscriptionId);
this.storageManagementClient = new StorageManagementClientImpl(credentials)
.withSubscriptionId(this.subscriptionId);
this.networkManagementClient = new NetworkManagementClientImpl(credentials)
.withSubscriptionId(this.subscriptionId);
}
} catch (Throwable e) {
throw new Exception(e);
}
}
示例13: MSICredentials
/**
* Initializes a new instance of the MSICredentials.
*/
public MSICredentials() {
this(AzureEnvironment.AZURE);
}
示例14: AzureTokenCredentials
/**
* Initializes a new instance of the AzureTokenCredentials.
*
* @param environment the Azure environment to use
* @param domain the tenant or domain the credential is authorized to
*/
public AzureTokenCredentials(AzureEnvironment environment, String domain) {
super("Bearer", null);
this.environment = (environment == null) ? AzureEnvironment.AZURE : environment;
this.domain = domain;
}