Changeset 7374


Ignore:
Timestamp:
01/19/12 17:45:21 (8 years ago)
Author:
spimming
Message:

#1680:

  • Methods to create a deployment added
  • Download blob block from public blob container
  • Constants for deployment and storage api version added
Location:
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3
Files:
5 edited

Legend:

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

    r7354 r7374  
    103103    }
    104104
     105    public string CreateDeployment(Subscription subscription, string serviceName, string deploymentName, string deploymentSlot, string packageUrl, string configurationUrl, string label) {
     106      return CreateDeployment(subscription, serviceName, deploymentName, deploymentSlot, packageUrl, configurationUrl, label, 1);
     107    }
     108
     109    public string CreateDeployment(Subscription subscription, string serviceName, string deploymentName, string deploymentSlot, string packageUrl, string configurationUrl, string label, int instanceCount) {
     110      if (subscription == null) {
     111        throw new ArgumentNullException("Subscription must not be null.", "subscription");
     112      }
     113      if (instanceCount <= 0) {
     114        throw new ArgumentException("Instance count must be greater than zero.", "instanceCount");
     115      }
     116
     117      string configuration = ServiceManagementOperation.DownloadBlobAsString(new Uri(Constants.DeploymentConfigurationUrl));
     118      return ServiceManagementOperation.CreateDeployment(subscription.SubscriptionID, subscription.CertificateThumbprint, serviceName, deploymentName, deploymentSlot, packageUrl, configuration, label, instanceCount);
     119
     120    }
    105121  }
    106122}
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/Constants.cs

    r7366 r7374  
    3535    public const string APIVersion20111001 = "2011-10-01";
    3636    public const string APIVersion20110225 = "2011-02-25";
     37    public const string APIVersion20110818 = "2011-08-18";
    3738
    3839    #endregion
     
    8081    public const string DeploymentSlotProduction = "production";
    8182    public const string DeploymentPackageUrl = "https://hivestorage.blob.core.windows.net/hiveslave/HeuristicLab.Clients.Hive.Slave.Azure.cspkg";
    82     public const string DeploymentConfigurationUrl = "files/ServiceConfiguration.Cloud.cscfg";
     83    public const string DeploymentConfigurationUrl = "https://hivestorage.blob.core.windows.net/hiveslave/ServiceConfiguration.Cloud.cscfg";
     84    public const string DeploymentConfigurationPath = "files/ServiceConfiguration.Cloud.cscfg";
    8385    public const string DeploymentLabel = "HeuristicLab.Hive.Slave";
    8486
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/IAzureProvider.cs

    r7354 r7374  
    3232    string CreateHostedService(Subscription subscription, string serviceName, string label, string description, string location);
    3333    string AddCertificate(Subscription subscription, HostedService service, string certficateFilePath, string certificatePassword);
     34    string CreateDeployment(Subscription subscription, string serviceName, string deploymentName, string deploymentSlot, string packageUrl, string configurationUrl, string label);
     35    string CreateDeployment(Subscription subscription, string serviceName, string deploymentName, string deploymentSlot, string packageUrl, string configurationUrl, string label, int instanceCount);
    3436  }
    3537}
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/ServiceManagementOperation.cs

    r7354 r7374  
    2424using System.IO;
    2525using System.Linq;
     26using System.Net;
    2627using System.Xml.Linq;
    2728using HeuristicLab.Clients.Hive.CloudManager.Model;
     
    185186    }
    186187
    187 
     188    public static string CreateDeployment(string subscriptionId, string thumbprint, string serviceName, string deploymentName, string deploymentSlot, string packageUrl, string configuration, string label, int instanceCount) {
     189      string uri = String.Format(Constants.URIDeploymentFormat, subscriptionId, serviceName, deploymentSlot);
     190      XElement xConfig = XElement.Parse(configuration);
     191      SetInstanceCount(xConfig, Constants.HLSlaveRoleName, instanceCount);
     192
     193      XDocument payload = CreateDeploymentPayload(deploymentName, packageUrl, xConfig, label);
     194      ServiceWebRequest operation = new ServiceWebRequest(thumbprint);
     195      string requestId = operation.Invoke(uri, payload);
     196      return requestId;
     197    }
     198
     199    public static string DownloadBlobAsString(Uri uri) {
     200      HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
     201      request.Headers.Add(Constants.HeaderVersionName, Constants.APIVersion20110818);
     202      request.Method = Constants.HttpMethodGET;
     203      request.ContentType = Constants.ContentTypeAppXml;
     204      string result = string.Empty;
     205      WebResponse response = request.GetResponse();
     206      using (StreamReader reader = new StreamReader(response.GetResponseStream())) {
     207        result = reader.ReadToEnd();
     208      }
     209      return result;
     210    }
    188211
    189212    #endregion
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddAzureServiceDialog.cs

    r7366 r7374  
    33using System.ComponentModel;
    44using System.Windows.Forms;
     5using HeuristicLab.Clients.Hive.CloudManager.Azure;
    56using HeuristicLab.Clients.Hive.CloudManager.Model;
    67using HeuristicLab.Core;
     
    4142        SetGroupBoxControlsEnabled(gbNewHostedService, cbNewHostedService.Checked);
    4243      }
     44
     45      certificateFile = string.Empty;
     46      certificatePassword = string.Empty;
    4347
    4448      workerUpdate = new BackgroundWorker();
     
    224228      int instanceCount = parameters.Item7;
    225229
    226       //STEP 1 - Create Hosted Service
     230      // STEP 1 - Create Hosted Service
    227231      if (newHostedServiceChecked) {
    228232        if (regionChecked) {
     
    232236        }
    233237      }
     238
     239      // STEP 2 - Add Certificate
     240      if (certFile != string.Empty) {
     241        CloudManagerClient.Instance.AzureProvider.AddCertificate(sub, hostedService, certFile, certPw);
     242      }
     243
     244      // STEP 3 - Create Deployment
     245      CloudManagerClient.Instance.AzureProvider.CreateDeployment(sub, hostedService.ServiceName, Guid.NewGuid().ToString(), Constants.DeploymentSlotStaging, Constants.DeploymentPackageUrl, Constants.DeploymentConfigurationUrl, Constants.DeploymentLabel, instanceCount);
    234246
    235247    }
Note: See TracChangeset for help on using the changeset viewer.