Changeset 7545


Ignore:
Timestamp:
03/05/12 13:38:48 (7 years ago)
Author:
spimming
Message:

#1680:

  • Storage service operations added:
  • list storage services
  • get keys for storage service
Location:
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/AzureProvider.cs

    r7429 r7545  
    5353    }
    5454
     55    public StorageServiceKeys GetStorageKeys(Subscription subscription, string serviceName) {
     56      if (subscription == null) {
     57        throw new ArgumentNullException("Subscription must not be null.", "subscription");
     58      }
     59      if (serviceName.Length == 0) {
     60        throw new ArgumentException("Servicename is not valid.", "serviceName");
     61      }
     62      return ServiceManagementOperation.GetStorageKeys(subscription.SubscriptionID, subscription.CertificateThumbprint, serviceName);
     63    }
     64
    5565    public List<string> ListLocations(Subscription subscription) {
    5666      if (subscription == null) {
     
    8191      }
    8292      return ServiceManagementOperation.ListAffinityGroups(subscription.SubscriptionID, subscription.CertificateThumbprint);
     93    }
     94
     95    public List<StorageService> ListStorageServices(Subscription subscription) {
     96      if (subscription == null) {
     97        throw new ArgumentNullException("Subscription must not be null.", "subscription");
     98      }
     99      return ServiceManagementOperation.ListStorageServices(subscription.SubscriptionID, subscription.CertificateThumbprint);
    83100    }
    84101
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/Constants.cs

    r7441 r7545  
    6565    public const string URIHostedServiceFormat = "https://management.core.windows.net/{0}/services/hostedservices";
    6666    public const string URISpecificHostedServiceFormat = "https://management.core.windows.net/{0}/services/hostedservices/{1}";
     67    public const string URIStorageServiceFormat = "https://management.core.windows.net/{0}/services/storageservices";
     68    public const string URISpecificStorageServiceFormat = "https://management.core.windows.net/{0}/services/storageservices/{1}";
     69    public const string URIStorageServiceKeys = "https://management.core.windows.net/{0}/services/storageservices/{1}/keys";
    6770    public const string URILocationsFormat = "https://management.core.windows.net/{0}/locations";
    6871    public const string URIAffinityGroupFormat = "https://management.core.windows.net/{0}/affinitygroups";
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/IAzureProvider.cs

    r7429 r7545  
    2727    Subscription GetSubscriptionInfo(string subscriptionId, string thumbprint);
    2828    HostedService GetHostedService(Subscription subscription, string serviceName);
     29    StorageServiceKeys GetStorageKeys(Subscription subscription, string serviceName);
    2930    List<string> ListLocations(Subscription subscription);
    3031    List<HostedService> ListHostedServices(Subscription subscription);
    3132    List<AffinityGroup> ListAffinityGroups(Subscription subscription);
     33    List<StorageService> ListStorageServices(Subscription subscription);
    3234    string CreateHostedService(Subscription subscription, string serviceName, string label, string description, AffinityGroup affinityGroup);
    3335    string CreateHostedService(Subscription subscription, string serviceName, string label, string description, string location);
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/ServiceManagementOperation.cs

    r7429 r7545  
    108108      else
    109109        return new List<HostedService>();
     110    }
     111
     112    public static List<StorageService> ListStorageServices(string subscriptionId, string thumbprint) {
     113      string uri = string.Format(Constants.URIStorageServiceFormat, subscriptionId);
     114      ServiceWebRequest operation = new ServiceWebRequest(thumbprint);
     115      XDocument response = operation.Invoke(uri);
     116      List<StorageService> result = null;
     117      if (response.Root.HasElements) {
     118        result = (from s in response.Elements()
     119                  select new StorageService() {
     120                    Url = s.Descendants(wa + "Url").Single().Value,
     121                    ServiceName = s.Descendants(wa + "ServiceName").Single().Value
     122                  }).ToList();
     123      }
     124      if (result != null)
     125        return result;
     126      else
     127        return new List<StorageService>();
    110128    }
    111129
     
    170188    }
    171189
     190    public static StorageServiceKeys GetStorageKeys(string subscriptionId, string thumbprint, string serviceName) {
     191      string uri = string.Format(Constants.URIStorageServiceKeys, subscriptionId, serviceName);
     192      ServiceWebRequest operation = new ServiceWebRequest(thumbprint);
     193      XDocument response = operation.Invoke(uri);
     194      StorageServiceKeys keys = new StorageServiceKeys();
     195      keys.Primary = response.Descendants(wa + "Primary").Single().Value;
     196      keys.Secondary = response.Descendants(wa + "Secondary").Single().Value;
     197      return keys;
     198    }
     199
    172200    public static string AddCertificate(string subscriptionId, string thumbprint, string serviceName, string certificateFilePath, string password) {
    173201      string uri = String.Format(Constants.URICertificateFormat, subscriptionId, serviceName);
Note: See TracChangeset for help on using the changeset viewer.