Changeset 7565 for branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddAzureServiceDialog.cs
- Timestamp:
- 03/06/12 16:04:29 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddAzureServiceDialog.cs
r7551 r7565 2 2 using System.Collections.Generic; 3 3 using System.ComponentModel; 4 using System.IO; 5 using System.Net; 4 6 using System.Text.RegularExpressions; 5 7 using System.Windows.Forms; … … 171 173 bool newHostedServiceChecked = cbNewHostedService.Checked; 172 174 bool regionChecked = rbRegion.Checked; 175 HostedService hostedService = null; 176 if (cbNewHostedService.Checked) { 177 hostedService = new HostedService(); 178 hostedService.ServiceName = tbServiceName.Text; 179 HostedServiceProperties properties = new HostedServiceProperties(); 180 181 if (regionChecked) { 182 properties.AffinityGroup = string.Empty; 183 properties.Location = (string)cmbLocation.SelectedItem; 184 } else { 185 properties.AffinityGroup = ((AffinityGroup)cmbAffinityGroup.SelectedItem).Name; 186 properties.Location = string.Empty; 187 } 188 189 if (cmbAffinityGroup.SelectedItem != null) { 190 properties.AffinityGroup = ((AffinityGroup)cmbAffinityGroup.SelectedItem).Name; 191 } 192 properties.Label = tbLabel.Text; 193 properties.Location = (string)cmbLocation.SelectedItem; 194 hostedService.HostedServiceProperties = properties; 195 } else { 196 hostedService = (HostedService)cmbChooseHostedService.SelectedItem; 197 } 198 199 173 200 string certFile = certificateFile; 174 201 string certPw = certificatePassword; 175 202 int instanceCount = Convert.ToInt32(tbInstanceCount.Text); 176 HostedService hostedService = new HostedService(); 177 hostedService.ServiceName = tbServiceName.Text; 178 HostedServiceProperties properties = new HostedServiceProperties(); 179 if (regionChecked) { 180 properties.AffinityGroup = string.Empty; 181 properties.Location = (string)cmbLocation.SelectedItem; 182 } else { 183 properties.AffinityGroup = ((AffinityGroup)cmbAffinityGroup.SelectedItem).Name; 184 properties.Location = string.Empty; 203 204 205 206 string packagefilepath = string.Empty; 207 if (rbVMSizeSmall.Checked) { 208 packagefilepath = Constants.DeploymentPackagePathSmall; 209 } else if (rbVMSizeMedium.Checked) { 210 packagefilepath = Constants.DeploymentPackagePathMedium; 211 } else if (rbVMSizeLarge.Checked) { 212 packagefilepath = Constants.DeploymentPackagePathLarge; 213 } else if (rbVMSizeExtraLarge.Checked) { 214 packagefilepath = Constants.DeploymentPackagePathExtraLarge; 185 215 } 186 216 187 if (cmbAffinityGroup.SelectedItem != null) { 188 properties.AffinityGroup = ((AffinityGroup)cmbAffinityGroup.SelectedItem).Name; 217 string deploymentSlot = string.Empty; 218 if (rbDeployToProduction.Checked) { 219 deploymentSlot = Constants.DeploymentSlotProduction; 220 } else if (rbDeployToStaging.Checked) { 221 deploymentSlot = Constants.DeploymentSlotStaging; 189 222 } 190 properties.Label = tbLabel.Text;191 properties.Location = (string)cmbLocation.SelectedItem;192 hostedService.HostedServiceProperties = properties;193 223 194 224 //var parameters1 = Tuple.Create<Subscription, bool, bool, string, string, HostedService, int> … … 203 233 parameters.InstanceCount = instanceCount; 204 234 parameters.StorageService = (StorageService)cmbStorageServices.SelectedItem; 235 parameters.CreateContainerIfNotExists = cbCreateBlobIfNotExists.Checked; 205 236 parameters.BlobContainerName = tbBlobContainer.Text; 237 parameters.DeploymentPackageFilePath = packagefilepath; 238 parameters.DeploymentSlot = deploymentSlot; 206 239 207 240 bwCompleted = false; … … 258 291 string blobContainerName = parameters.BlobContainerName; 259 292 bool createContainerIfNotExists = parameters.CreateContainerIfNotExists; 260 261 CloudStorageAccount storageAccount; 262 CloudBlobClient blobClient; 263 CloudBlobContainer blobContainer; 293 string packageFilePath = parameters.DeploymentPackageFilePath; 294 FileInfo packageFile = new FileInfo(packageFilePath); 295 string deploymentSlot = parameters.DeploymentSlot; 296 297 int defaultCollectionLimit = ServicePointManager.DefaultConnectionLimit; 298 299 CloudStorageAccount storageAccount = null; ; 300 CloudBlobClient blobClient = null; 301 CloudBlobContainer blobContainer = null; 264 302 265 303 // STEP 1 - Initialize storage account 266 304 try { 267 // get access key to storage service268 305 StorageServiceKeys keys = CloudManagerClient.Instance.AzureProvider.GetStorageKeys(sub, storageService.ServiceName); 269 306 storageAccount = CloudStorageAccount.Parse(string.Format(Constants.StorageServiceConnectionFormat, storageService.ServiceName, keys.Primary)); … … 283 320 } 284 321 322 // STEP 2 - Copy service package file to storage account 323 CloudBlockBlob blobPackage = null; 324 try { 325 blobPackage = blobContainer.GetBlockBlobReference(packageFile.Name); 326 if (!blobPackage.Exists()) { 327 ServicePointManager.DefaultConnectionLimit = 64; 328 blobPackage.UploadParallel(packageFile.FullName); 329 } 330 331 } 332 catch (Exception ex) { 333 errorOccured = true; 334 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 335 } 336 285 337 286 338 // STEP 1 - Create Hosted Service … … 317 369 try { 318 370 if (!errorOccured) { 319 CloudManagerClient.Instance.AzureProvider.CreateDeployment(sub, hostedService.ServiceName, Guid.NewGuid().ToString(), Constants.DeploymentSlotStaging, Constants.DeploymentPackageUrl, Constants.DeploymentConfigurationUrl, Constants.DeploymentLabel, instanceCount); 371 //CloudManagerClient.Instance.AzureProvider.CreateDeployment(sub, hostedService.ServiceName, Guid.NewGuid().ToString(), Constants.DeploymentSlotStaging, Constants.DeploymentPackageUrl, Constants.DeploymentConfigurationUrl, Constants.DeploymentLabel, instanceCount); 372 CloudManagerClient.Instance.AzureProvider.CreateDeployment(sub, hostedService.ServiceName, Guid.NewGuid().ToString(), deploymentSlot, blobPackage.Uri.ToString(), new FileInfo(Constants.DeploymentConfigurationPath), Constants.DeploymentLabel, instanceCount); 320 373 } 321 374 } … … 328 381 } 329 382 383 ServicePointManager.DefaultConnectionLimit = defaultCollectionLimit; 330 384 e.Result = errorOccured; 331 385 } … … 403 457 if (instanceCount > subscription.MaxCoreCount - subscription.CurrentCoreCount) { 404 458 errorProvider.SetError(tbInstanceCount, "Instance count must be less or equal than the difference between maximum and available cores."); 459 e.Cancel = true; 405 460 } else { 406 e.Cancel = true;407 461 errorProvider.SetError(tbInstanceCount, ""); 408 462 } … … 464 518 public string BlobContainerName { get; set; } 465 519 public bool CreateContainerIfNotExists { get; set; } 520 public string DeploymentPackageFilePath { get; set; } 521 public string DeploymentSlot { get; set; } 466 522 } 467 523 }
Note: See TracChangeset
for help on using the changeset viewer.