- Timestamp:
- 03/05/12 17:13:58 (13 years ago)
- Location:
- branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddAzureServiceDialog.Designer.cs
r7547 r7551 55 55 this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); 56 56 this.gbStorageService = new System.Windows.Forms.GroupBox(); 57 this.cbCreateBlobIfNotExists = new System.Windows.Forms.CheckBox(); 58 this.tbBlobContainer = new System.Windows.Forms.TextBox(); 59 this.label11 = new System.Windows.Forms.Label(); 60 this.cmbStorageServices = new System.Windows.Forms.ComboBox(); 57 61 this.label8 = new System.Windows.Forms.Label(); 58 this.comboBox1 = new System.Windows.Forms.ComboBox();59 this.label11 = new System.Windows.Forms.Label();60 this.tbBlobContainer = new System.Windows.Forms.TextBox();61 this.cbCreateBlobIfNotExists = new System.Windows.Forms.CheckBox();62 62 this.rbVMSizeMedium = new System.Windows.Forms.RadioButton(); 63 63 this.rbVMSizeSmall = new System.Windows.Forms.RadioButton(); … … 108 108 this.cmbChooseHostedService.Size = new System.Drawing.Size(486, 21); 109 109 this.cmbChooseHostedService.TabIndex = 6; 110 this.cmbChooseHostedService.Validating += new System.ComponentModel.CancelEventHandler(this.cmbChooseHostedService_Validating); 110 111 // 111 112 // gbNewHostedService … … 341 342 this.gbStorageService.Controls.Add(this.tbBlobContainer); 342 343 this.gbStorageService.Controls.Add(this.label11); 343 this.gbStorageService.Controls.Add(this.c omboBox1);344 this.gbStorageService.Controls.Add(this.cmbStorageServices); 344 345 this.gbStorageService.Controls.Add(this.label8); 345 346 this.gbStorageService.Location = new System.Drawing.Point(15, 267); … … 350 351 this.gbStorageService.Text = "Set storage service"; 351 352 // 353 // cbCreateBlobIfNotExists 354 // 355 this.cbCreateBlobIfNotExists.AutoSize = true; 356 this.cbCreateBlobIfNotExists.Checked = true; 357 this.cbCreateBlobIfNotExists.CheckState = System.Windows.Forms.CheckState.Checked; 358 this.cbCreateBlobIfNotExists.Location = new System.Drawing.Point(9, 98); 359 this.cbCreateBlobIfNotExists.Name = "cbCreateBlobIfNotExists"; 360 this.cbCreateBlobIfNotExists.Size = new System.Drawing.Size(182, 17); 361 this.cbCreateBlobIfNotExists.TabIndex = 21; 362 this.cbCreateBlobIfNotExists.Text = "Create blob container if not exists"; 363 this.cbCreateBlobIfNotExists.UseVisualStyleBackColor = true; 364 // 365 // tbBlobContainer 366 // 367 this.tbBlobContainer.Location = new System.Drawing.Point(9, 72); 368 this.tbBlobContainer.Name = "tbBlobContainer"; 369 this.tbBlobContainer.Size = new System.Drawing.Size(452, 20); 370 this.tbBlobContainer.TabIndex = 10; 371 this.tbBlobContainer.Validating += new System.ComponentModel.CancelEventHandler(this.tbBlobContainer_Validating); 372 // 373 // label11 374 // 375 this.label11.AutoSize = true; 376 this.label11.Location = new System.Drawing.Point(6, 56); 377 this.label11.Name = "label11"; 378 this.label11.Size = new System.Drawing.Size(96, 13); 379 this.label11.TabIndex = 11; 380 this.label11.Text = "Set blob container:"; 381 // 382 // cmbStorageServices 383 // 384 this.cmbStorageServices.FormattingEnabled = true; 385 this.cmbStorageServices.Location = new System.Drawing.Point(9, 32); 386 this.cmbStorageServices.Name = "cmbStorageServices"; 387 this.cmbStorageServices.Size = new System.Drawing.Size(452, 21); 388 this.cmbStorageServices.TabIndex = 10; 389 this.cmbStorageServices.Validating += new System.ComponentModel.CancelEventHandler(this.cmbStorageServices_Validating); 390 // 352 391 // label8 353 392 // … … 358 397 this.label8.TabIndex = 10; 359 398 this.label8.Text = "Select storage account:"; 360 //361 // comboBox1362 //363 this.comboBox1.FormattingEnabled = true;364 this.comboBox1.Location = new System.Drawing.Point(9, 32);365 this.comboBox1.Name = "comboBox1";366 this.comboBox1.Size = new System.Drawing.Size(452, 21);367 this.comboBox1.TabIndex = 10;368 //369 // label11370 //371 this.label11.AutoSize = true;372 this.label11.Location = new System.Drawing.Point(6, 56);373 this.label11.Name = "label11";374 this.label11.Size = new System.Drawing.Size(96, 13);375 this.label11.TabIndex = 11;376 this.label11.Text = "Set blob container:";377 //378 // tbBlobContainer379 //380 this.tbBlobContainer.Location = new System.Drawing.Point(9, 72);381 this.tbBlobContainer.Name = "tbBlobContainer";382 this.tbBlobContainer.Size = new System.Drawing.Size(452, 20);383 this.tbBlobContainer.TabIndex = 10;384 //385 // cbCreateBlobIfNotExists386 //387 this.cbCreateBlobIfNotExists.AutoSize = true;388 this.cbCreateBlobIfNotExists.Location = new System.Drawing.Point(9, 98);389 this.cbCreateBlobIfNotExists.Name = "cbCreateBlobIfNotExists";390 this.cbCreateBlobIfNotExists.Size = new System.Drawing.Size(182, 17);391 this.cbCreateBlobIfNotExists.TabIndex = 21;392 this.cbCreateBlobIfNotExists.Text = "Create blob container if not exists";393 this.cbCreateBlobIfNotExists.UseVisualStyleBackColor = true;394 399 // 395 400 // rbVMSizeMedium … … 490 495 this.Controls.Add(this.cmbChooseSubscription); 491 496 this.Controls.Add(this.label1); 497 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; 492 498 this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); 499 this.MaximizeBox = false; 500 this.MinimizeBox = false; 493 501 this.Name = "AddAzureServiceDialog"; 494 502 this.Text = "Create New Azure Slave"; … … 545 553 private System.Windows.Forms.TextBox tbBlobContainer; 546 554 private System.Windows.Forms.Label label11; 547 private System.Windows.Forms.ComboBox c omboBox1;555 private System.Windows.Forms.ComboBox cmbStorageServices; 548 556 private System.Windows.Forms.Label label8; 549 557 private System.Windows.Forms.ToolTip toolTip; -
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddAzureServiceDialog.cs
r7429 r7551 7 7 using HeuristicLab.Clients.Hive.CloudManager.Model; 8 8 using HeuristicLab.Core; 9 using Microsoft.WindowsAzure; 10 using Microsoft.WindowsAzure.StorageClient; 9 11 10 12 namespace HeuristicLab.Clients.Hive.CloudManager.Views { … … 14 16 private BindingList<string> locations; 15 17 private BindingList<AffinityGroup> affinityGroups; 18 private BindingList<StorageService> storageServices; 16 19 17 20 private BackgroundWorker workerUpdate; … … 34 37 this.locations = new BindingList<string>(); 35 38 this.affinityGroups = new BindingList<AffinityGroup>(); 39 this.storageServices = new BindingList<StorageService>(); 36 40 37 41 SetLookupBinding(cmbLocation, locations, "", ""); … … 39 43 SetLookupBinding(cmbChooseHostedService, hostedServices, "ServiceName", "ServiceName"); 40 44 SetLookupBinding(cmbChooseSubscription, subscriptions, "SubscriptionName", "SubscriptionID"); 45 SetLookupBinding(cmbStorageServices, storageServices, "ServiceName", "Url"); 41 46 42 47 if (!cbNewHostedService.Checked) { … … 52 57 53 58 workerCreate = new BackgroundWorker(); 54 workerCreate.DoWork += new DoWorkEventHandler(CreateD oploymentTask);59 workerCreate.DoWork += new DoWorkEventHandler(CreateDeploymentTask); 55 60 workerCreate.RunWorkerCompleted += new RunWorkerCompletedEventHandler(CreateDeploymentCompleted); 56 61 … … 187 192 hostedService.HostedServiceProperties = properties; 188 193 189 var parameters = Tuple.Create<Subscription, bool, bool, string, string, HostedService, int>(sub, newHostedServiceChecked, regionChecked, certificateFile, certificatePassword, hostedService, instanceCount); 194 //var parameters1 = Tuple.Create<Subscription, bool, bool, string, string, HostedService, int> 195 // (sub, newHostedServiceChecked, regionChecked, certificateFile, certificatePassword, hostedService, instanceCount); 196 CreateDeploymentData parameters = new CreateDeploymentData(); 197 parameters.Subscription = sub; 198 parameters.CreateNewHosteService = newHostedServiceChecked; 199 parameters.UseRegion = regionChecked; 200 parameters.CertificateFilePath = certificateFile; 201 parameters.CertificatePassword = certificatePassword; 202 parameters.HostedService = hostedService; 203 parameters.InstanceCount = instanceCount; 204 parameters.StorageService = (StorageService)cmbStorageServices.SelectedItem; 205 parameters.BlobContainerName = tbBlobContainer.Text; 190 206 191 207 bwCompleted = false; … … 206 222 List<string> locs = CloudManagerClient.Instance.AzureProvider.ListLocations(item); 207 223 List<AffinityGroup> groups = CloudManagerClient.Instance.AzureProvider.ListAffinityGroups(item); 224 List<StorageService> storage = CloudManagerClient.Instance.AzureProvider.ListStorageServices(item); 208 225 209 226 this.Invoke((MethodInvoker)delegate { UpdateSubscriptionItem(subscriptions, item); }); … … 211 228 this.Invoke((MethodInvoker)delegate { UpdateBindingList<string>(locations, locs); }); 212 229 this.Invoke((MethodInvoker)delegate { UpdateBindingList<AffinityGroup>(affinityGroups, groups); }); 230 this.Invoke((MethodInvoker)delegate { UpdateBindingList<StorageService>(storageServices, storage); }); 213 231 } 214 232 catch (Exception ex) { … … 226 244 } 227 245 228 private void CreateD oploymentTask(object sender, DoWorkEventArgs e) {246 private void CreateDeploymentTask(object sender, DoWorkEventArgs e) { 229 247 bool errorOccured = false; 230 Tuple<Subscription, bool, bool, string, string, HostedService, int> parameters = (Tuple<Subscription, bool, bool, string, string, HostedService, int>)e.Argument; 231 232 Subscription sub = parameters.Item1; 233 bool newHostedServiceChecked = parameters.Item2; 234 bool regionChecked = parameters.Item3; 235 string certFile = parameters.Item4; 236 string certPw = parameters.Item5; 237 HostedService hostedService = parameters.Item6; 238 int instanceCount = parameters.Item7; 248 CreateDeploymentData parameters = (CreateDeploymentData)e.Argument; 249 250 Subscription sub = parameters.Subscription; 251 bool newHostedServiceChecked = parameters.CreateNewHosteService; 252 bool regionChecked = parameters.UseRegion; 253 string certFile = parameters.CertificateFilePath; 254 string certPw = parameters.CertificatePassword; 255 HostedService hostedService = parameters.HostedService; 256 int instanceCount = parameters.InstanceCount; 257 StorageService storageService = parameters.StorageService; 258 string blobContainerName = parameters.BlobContainerName; 259 bool createContainerIfNotExists = parameters.CreateContainerIfNotExists; 260 261 CloudStorageAccount storageAccount; 262 CloudBlobClient blobClient; 263 CloudBlobContainer blobContainer; 264 265 // STEP 1 - Initialize storage account 266 try { 267 // get access key to storage service 268 StorageServiceKeys keys = CloudManagerClient.Instance.AzureProvider.GetStorageKeys(sub, storageService.ServiceName); 269 storageAccount = CloudStorageAccount.Parse(string.Format(Constants.StorageServiceConnectionFormat, storageService.ServiceName, keys.Primary)); 270 blobClient = storageAccount.CreateCloudBlobClient(); 271 blobContainer = blobClient.GetContainerReference(blobContainerName); 272 if (createContainerIfNotExists) { 273 blobContainer.CreateIfNotExist(); 274 } else { 275 if (!blobContainer.Exists()) { 276 throw new ApplicationException("Specified blob container doesn't exist."); 277 } 278 } 279 } 280 catch (Exception ex) { 281 errorOccured = true; 282 MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 283 } 284 239 285 240 286 // STEP 1 - Create Hosted Service 241 287 try { 242 if ( newHostedServiceChecked) {288 if ((!errorOccured) && (newHostedServiceChecked)) { 243 289 if (regionChecked) { 244 290 CloudManagerClient.Instance.AzureProvider.CreateHostedService(sub, hostedService.ServiceName, hostedService.HostedServiceProperties.Label, hostedService.HostedServiceProperties.Description, hostedService.HostedServiceProperties.Location); … … 337 383 } 338 384 385 private bool isValidStorageContainerName(string name) { 386 string regexString = @"[a-z0-9]+[a-z0-9-]{0,61}[a-z0-9]+"; //TODO 387 Regex regex = new Regex(regexString); 388 if (regex.IsMatch(name)) { 389 return true; 390 } else { 391 return false; 392 } 393 } 394 339 395 private void tbInstanceCount_Validating(object sender, CancelEventArgs e) { 340 396 if (!isValidInstanceCount(tbInstanceCount.Text)) { … … 363 419 } 364 420 } 421 422 private void tbBlobContainer_Validating(object sender, CancelEventArgs e) { 423 string name = tbBlobContainer.Text.Trim(); 424 if (name == string.Empty) { 425 errorProvider.SetError(tbBlobContainer, "A name is required for the blob container."); 426 e.Cancel = true; 427 } else if (!isValidStorageContainerName(name)) { 428 errorProvider.SetError(tbBlobContainer, "A blob container name must be between 1 and 63 " + 429 "characters long, and be composed of lowercase letters, numbers " + 430 "and hyphens. Hyphens shouldn't be first or last letter."); 431 e.Cancel = true; 432 } else { 433 errorProvider.SetError(tbBlobContainer, ""); 434 } 435 } 436 437 private void cmbChooseHostedService_Validating(object sender, CancelEventArgs e) { 438 if ((!cbNewHostedService.Checked) && (cmbChooseHostedService.SelectedItem == null)) { 439 errorProvider.SetError(cmbChooseHostedService, "A hoste service is required."); 440 e.Cancel = true; 441 } else { 442 errorProvider.SetError(cmbChooseHostedService, ""); 443 } 444 } 445 446 private void cmbStorageServices_Validating(object sender, CancelEventArgs e) { 447 if (cmbStorageServices.SelectedItem == null) { 448 errorProvider.SetError(cmbStorageServices, "A storage service is required."); 449 e.Cancel = true; 450 } else { 451 errorProvider.SetError(cmbStorageServices, ""); 452 } 453 } 454 455 private class CreateDeploymentData { 456 public Subscription Subscription { get; set; } 457 public bool CreateNewHosteService { get; set; } 458 public bool UseRegion { get; set; } 459 public string CertificateFilePath { get; set; } 460 public string CertificatePassword { get; set; } 461 public HostedService HostedService { get; set; } 462 public int InstanceCount { get; set; } 463 public StorageService StorageService { get; set; } 464 public string BlobContainerName { get; set; } 465 public bool CreateContainerIfNotExists { get; set; } 466 } 365 467 } 366 468 }
Note: See TracChangeset
for help on using the changeset viewer.