当前位置: 首页>>代码示例>>Java>>正文


Java ManagementConfiguration类代码示例

本文整理汇总了Java中com.microsoft.windowsazure.management.configuration.ManagementConfiguration的典型用法代码示例。如果您正苦于以下问题:Java ManagementConfiguration类的具体用法?Java ManagementConfiguration怎么用?Java ManagementConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ManagementConfiguration类属于com.microsoft.windowsazure.management.configuration包,在下文中一共展示了ManagementConfiguration类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import com.microsoft.windowsazure.management.configuration.ManagementConfiguration; //导入依赖的package包/类
@Override
public DnsManagementClient get()
{
	try
	{
		final Configuration config = ManagementConfiguration.configure(null,
		                                                               URI.create("https://management.core.windows.net/"),
		                                                               subscriptionId,
		                                                               azureCredentials.get().getToken());

		return config.create(DnsManagementClient.class);
	}
	catch (IOException e)
	{
		throw new RuntimeException("Error building Azure DNS Client", e);
	}
}
 
开发者ID:petergeneric,项目名称:stdlib,代码行数:18,代码来源:AzureDNSClientProvider.java

示例2: AzureComputeServiceImpl

import com.microsoft.windowsazure.management.configuration.ManagementConfiguration; //导入依赖的package包/类
public AzureComputeServiceImpl(Settings settings) {
    super(settings);
    String subscriptionId = getRequiredSetting(settings, Management.SUBSCRIPTION_ID_SETTING);

    serviceName = getRequiredSetting(settings, Management.SERVICE_NAME_SETTING);
    String keystorePath = getRequiredSetting(settings, Management.KEYSTORE_PATH_SETTING);
    String keystorePassword = getRequiredSetting(settings, Management.KEYSTORE_PASSWORD_SETTING);
    KeyStoreType keystoreType = Management.KEYSTORE_TYPE_SETTING.get(settings);

    logger.trace("creating new Azure client for [{}], [{}]", subscriptionId, serviceName);
    try {
        // Azure SDK configuration uses DefaultBuilder which uses java.util.ServiceLoader to load the
        // various Azure services. By default, this will use the current thread's context classloader
        // to load services. Since the current thread refers to the main application classloader it
        // won't find any Azure service implementation.

        // Here we basically create a new DefaultBuilder that uses the current class classloader to load services.
        DefaultBuilder builder = new DefaultBuilder();
        for (Builder.Exports exports : ServiceLoader.load(Builder.Exports.class, getClass().getClassLoader())) {
            exports.register(builder);
        }

        // And create a new blank configuration based on the previous DefaultBuilder
        Configuration configuration = new Configuration(builder);
        configuration.setProperty(Configuration.PROPERTY_LOG_HTTP_REQUESTS, logger.isTraceEnabled());

        Configuration managementConfig = ManagementConfiguration.configure(null, configuration,
                Management.ENDPOINT_SETTING.get(settings), subscriptionId, keystorePath, keystorePassword, keystoreType);

        logger.debug("creating new Azure client for [{}], [{}]", subscriptionId, serviceName);
        client = ComputeManagementService.create(managementConfig);
    } catch (IOException e) {
        throw new ElasticsearchException("Unable to configure Azure compute service", e);
    }
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:36,代码来源:AzureComputeServiceImpl.java

示例3: loadConfiguration

import com.microsoft.windowsazure.management.configuration.ManagementConfiguration; //导入依赖的package包/类
public static Configuration loadConfiguration(String subscriptionId, String url) throws IOException {
    String keystore = System.getProperty("user.home") + File.separator + ".azure" + File.separator + subscriptionId + ".out";
    URI mngUri = URI.create(url);
    // Get current context class loader
    ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
    // Change context classloader to class context loader
    Thread.currentThread().setContextClassLoader(WindowsAzureRestUtils.class.getClassLoader());
    Configuration configuration = ManagementConfiguration.configure(null, Configuration.load(), mngUri, subscriptionId, keystore, "", KeyStoreType.pkcs12);
    // Call Azure API and reset back the context loader
    Thread.currentThread().setContextClassLoader(contextLoader);
    return configuration;
}
 
开发者ID:Microsoft,项目名称:Azure-Toolkit-for-IntelliJ,代码行数:13,代码来源:WindowsAzureRestUtils.java

示例4: doStartInternal

import com.microsoft.windowsazure.management.configuration.ManagementConfiguration; //导入依赖的package包/类
private void doStartInternal() throws Exception {
  LOG.info("Starting AzureCloudInstance: " + getImageId() + " - " + getInstanceId());
  instanceStatus = InstanceStatus.STARTING;
  startDate = new Date();

  // TODO: refactor this to something nicer. This is crap.
  ComputeManagementClient client = ComputeManagementService.create(ManagementConfiguration.configure(
          new URI(azurePublishSettings.getManagementUrl()), azureSubscriptionId, AzureCloudConstants.getKeyStorePath(), AzureCloudConstants.KEYSTORE_PWD, KeyStoreType.pkcs12));

  HostedServiceOperations hostedServicesOperations = client.getHostedServicesOperations();
  HostedServiceListResponse hostedServicesList = hostedServicesOperations.listAsync().get();
  for (HostedServiceListResponse.HostedService service : hostedServicesList.getHostedServices()) {
    String serviceName = service.getServiceName();
    HostedServiceGetDetailedResponse serviceDetails = hostedServicesOperations.getDetailedAsync(serviceName).get();

    List<HostedServiceGetDetailedResponse.Deployment> serviceDeployments = serviceDetails.getDeployments();
    if (!serviceDeployments.isEmpty()) {
      for (HostedServiceGetDetailedResponse.Deployment serviceDeployment : serviceDeployments) {
        for (Role role : serviceDeployment.getRoles()) {
          if (role.getRoleType() != null && role.getRoleType().equalsIgnoreCase(VirtualMachineRoleType.PersistentVMRole.toString())) {
            for (RoleInstance instance : serviceDeployment.getRoleInstances()) {
              if (instance.getRoleName().equalsIgnoreCase(id) && !instance.getInstanceStatus().equalsIgnoreCase(RoleInstanceStatus.READYROLE)) {
                client.getVirtualMachinesOperations().startAsync(serviceName, serviceDeployment.getName(), instance.getInstanceName()).get();
              }
            }
          }
        }
      }
    }
  }

  instanceStatus = InstanceStatus.RUNNING;
  LOG.info("Started AzureCloudInstance: " + getImageId() + " - " + getInstanceId());
}
 
开发者ID:maartenba,项目名称:teamcity-cloud-azure,代码行数:35,代码来源:AzureCloudInstance.java

示例5: doStopInternal

import com.microsoft.windowsazure.management.configuration.ManagementConfiguration; //导入依赖的package包/类
private void doStopInternal() throws Exception {
  LOG.info("Stopping AzureCloudInstance: " + getImageId() + " - " + getInstanceId());
  instanceStatus = InstanceStatus.STOPPING;

  // TODO: refactor this to something nicer. This is crap.
  ComputeManagementClient client = ComputeManagementService.create(ManagementConfiguration.configure(
          new URI(azurePublishSettings.getManagementUrl()), azureSubscriptionId, AzureCloudConstants.getKeyStorePath(), AzureCloudConstants.KEYSTORE_PWD, KeyStoreType.pkcs12));

  HostedServiceOperations hostedServicesOperations = client.getHostedServicesOperations();
  HostedServiceListResponse hostedServicesList = hostedServicesOperations.listAsync().get();
  for (HostedServiceListResponse.HostedService service : hostedServicesList.getHostedServices()) {
    String serviceName = service.getServiceName();
    HostedServiceGetDetailedResponse serviceDetails = hostedServicesOperations.getDetailedAsync(serviceName).get();

    List<HostedServiceGetDetailedResponse.Deployment> serviceDeployments = serviceDetails.getDeployments();
    if (!serviceDeployments.isEmpty()) {
      for (HostedServiceGetDetailedResponse.Deployment serviceDeployment : serviceDeployments) {
        for (Role role : serviceDeployment.getRoles()) {
          if (role.getRoleType() != null && role.getRoleType().equalsIgnoreCase(VirtualMachineRoleType.PersistentVMRole.toString())) {
            for (RoleInstance instance : serviceDeployment.getRoleInstances()) {
              if (instance.getRoleName().equalsIgnoreCase(id) && !instance.getInstanceStatus().equalsIgnoreCase(RoleInstanceStatus.STOPPEDVM)) {
                VirtualMachineShutdownParameters params = new VirtualMachineShutdownParameters();
                params.setPostShutdownAction(PostShutdownAction.StoppedDeallocated);
                client.getVirtualMachinesOperations().shutdownAsync(serviceName, serviceDeployment.getName(), instance.getInstanceName(), params).get();
              }
            }
          }
        }
      }
    }
  }

  instanceStatus = InstanceStatus.STOPPED;
  LOG.info("Stopped AzureCloudInstance: " + getImageId() + " - " + getInstanceId());
}
 
开发者ID:maartenba,项目名称:teamcity-cloud-azure,代码行数:36,代码来源:AzureCloudInstance.java

示例6: createConfiguration

import com.microsoft.windowsazure.management.configuration.ManagementConfiguration; //导入依赖的package包/类
private Configuration createConfiguration(String endpoint, String provider,String login,String secretKey) throws Exception {
    return ManagementConfiguration.configure(
            new URI("https://management.core.windows.net"),
            endpoint,
            login,
            secretKey,
            KeyStoreType.pkcs12
    );
}
 
开发者ID:SINTEF-9012,项目名称:cloudml,代码行数:10,代码来源:AzureConnector.java

示例7: main

import com.microsoft.windowsazure.management.configuration.ManagementConfiguration; //导入依赖的package包/类
public static void main(String[] args) 
{
    try
    {
        //Load SubscriptionID, TenantID, Application ID and Password from the config file
        LoadConfiguration();
        
        //Fetch the Auth Headers for our requests
        String token = GetAuthorizationHeader();
    
        //Create Configuration Object
        Configuration config = ManagementConfiguration.configure(
                null,
                new URI("https://management.azure.com/"),
                subscriptionId,
                token);
        
        //Create the Resource Management Client, we will use this for creating a Resource Group later
        ResourceManagementClient resourcesClient = ResourceManagementService.create(config); 
        
        //Create the Resource Management Client, we will use this for managing storage accounts
        StorageManagementClient storageMgmtClient = StorageManagementService.create(config);
    
        //Create a new resource group
        CreateResourceGroup(rgName, resourcesClient);

        //Register our subscription with the Storage Resource Provider
        resourcesClient.getProvidersOperations().register("Microsoft.Storage");
        
        //Create a new account in a specific resource group with the specified account name
        CreateStorageAccount(rgName, accountName, storageMgmtClient);

        //Get all the account properties for a given resource group and account name
        StorageAccount storAcct = storageMgmtClient.getStorageAccountsOperations().getProperties(rgName, accountName).getStorageAccount();

        //Get a list of storage accounts within a specific resource group
        ArrayList<StorageAccount> storAccts = storageMgmtClient.getStorageAccountsOperations().listByResourceGroup(rgName).getStorageAccounts();

        //Get all the storage accounts for a given subscription
        ArrayList<StorageAccount> storAcctsSub = storageMgmtClient.getStorageAccountsOperations().list().getStorageAccounts();

        //Get the storage account keys for a given account and resource group
        StorageAccountKeys acctKeys = storageMgmtClient.getStorageAccountsOperations().listKeys(rgName, accountName).getStorageAccountKeys();

        //Regenerate the account key for a given account in a specific resource group
        StorageAccountKeys regenAcctKeys = storageMgmtClient.getStorageAccountsOperations().regenerateKey(rgName, accountName, KeyName.KEY1).getStorageAccountKeys();

        //Update the storage account for a given account name and resource group
        UpdateStorageAccount(rgName, accountName, storageMgmtClient);

        //Check if the account name is available
        boolean nameAvailable = storageMgmtClient.getStorageAccountsOperations().checkNameAvailability(accountName).isNameAvailable();
        
        //Delete a storage account with the given account name and a resource group
        DeleteStorageAccount(rgName, accountName, storageMgmtClient);
    }
    catch(Exception e)
    {
        System.out.println(e.getMessage());
    }
}
 
开发者ID:mjeelanimsft,项目名称:storage-java-resource-provider-getting-started,代码行数:62,代码来源:StorageResourceProviderSample.java


注:本文中的com.microsoft.windowsazure.management.configuration.ManagementConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。