Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7354


Ignore:
Timestamp:
01/18/12 09:41:57 (13 years ago)
Author:
spimming
Message:

#1680:

  • Methods to create hosted services added
  • Method to add a certificate to a hosted service
  • update bindinglist from worker
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

    r7339 r7354  
    4040    public List<string> ListLocations(Subscription subscription) {
    4141      if (subscription == null) {
    42         throw new ArgumentException("Subscription must not be null.", "subscription");
     42        throw new ArgumentNullException("Subscription must not be null.", "subscription");
    4343      }
    4444      return ServiceManagementOperation.ListLocations(subscription.SubscriptionID, subscription.CertificateThumbprint);
     
    4747    public List<HostedService> ListHostedServices(Subscription subscription) {
    4848      if (subscription == null) {
    49         throw new ArgumentException("Subscription must not be null.", "subscription");
     49        throw new ArgumentNullException("Subscription must not be null.", "subscription");
    5050      }
    5151      return ServiceManagementOperation.ListHostedServices(subscription.SubscriptionID, subscription.CertificateThumbprint);
     
    5454    public List<AffinityGroup> ListAffinityGroups(Subscription subscription) {
    5555      if (subscription == null) {
    56         throw new ArgumentException("Subscription must not be null.", "subscription");
     56        throw new ArgumentNullException("Subscription must not be null.", "subscription");
    5757      }
    5858      return ServiceManagementOperation.ListAffinityGroups(subscription.SubscriptionID, subscription.CertificateThumbprint);
    5959    }
     60
     61    public string CreateHostedService(Subscription subscription, string serviceName, string label, string description, AffinityGroup affinityGroup) {
     62      if (subscription == null) {
     63        throw new ArgumentNullException("Subscription must not be null.", "subscription");
     64      }
     65      if (serviceName.Length == 0) {
     66        throw new ArgumentException("Servicename is not valid.", "serviceName");
     67      }
     68      if (label.Length == 0) {
     69        throw new ArgumentException("Label is not valid.", "label");
     70      }
     71      if (affinityGroup == null) {
     72        throw new ArgumentNullException("AffinityGroup must not be null.", "affinityGroup");
     73      }
     74
     75      return ServiceManagementOperation.CreateHostedServiceWithAffinityGroup(subscription.SubscriptionID, subscription.CertificateThumbprint, serviceName, label, description, affinityGroup.Name);
     76    }
     77
     78    public string CreateHostedService(Subscription subscription, string serviceName, string label, string description, string location) {
     79      if (subscription == null) {
     80        throw new ArgumentNullException("Subscription must not be null.", "subscription");
     81      }
     82      if (serviceName.Length == 0) {
     83        throw new ArgumentException("Servicename is not valid.", "serviceName");
     84      }
     85      if (label.Length == 0) {
     86        throw new ArgumentException("Label is not valid.", "label");
     87      }
     88      if (location.Length == 0) {
     89        throw new ArgumentException("Location is not valid.", "location");
     90      }
     91
     92      return ServiceManagementOperation.CreateHostedServiceWithLocation(subscription.SubscriptionID, subscription.CertificateThumbprint, serviceName, label, description, location);
     93    }
     94
     95    public string AddCertificate(Subscription subscription, HostedService service, string certficateFilePath, string certificatePassword) {
     96      if (subscription == null) {
     97        throw new ArgumentNullException("Subscription must not be null.", "subscription");
     98      }
     99      if (service == null) {
     100        throw new ArgumentNullException("HostedService must not be null.", "service");
     101      }
     102      return ServiceManagementOperation.AddCertificate(subscription.SubscriptionID, subscription.CertificateThumbprint, service.ServiceName, certficateFilePath, certificatePassword);
     103    }
     104
    60105  }
    61106}
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/IAzureProvider.cs

    r7339 r7354  
    2929    List<HostedService> ListHostedServices(Subscription subscription);
    3030    List<AffinityGroup> ListAffinityGroups(Subscription subscription);
    31 
     31    string CreateHostedService(Subscription subscription, string serviceName, string label, string description, AffinityGroup affinityGroup);
     32    string CreateHostedService(Subscription subscription, string serviceName, string label, string description, string location);
     33    string AddCertificate(Subscription subscription, HostedService service, string certficateFilePath, string certificatePassword);
    3234  }
    3335}
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/ServiceManagementOperation.cs

    r7339 r7354  
    169169    }
    170170
     171    public static string AddCertificate(string subscriptionId, string thumbprint, string serviceName, string certificateFilePath, string password) {
     172      string uri = String.Format(Constants.URICertificateFormat, subscriptionId, serviceName);
     173      XDocument payload = CreateAddCertificatePayload(certificateFilePath, password);
     174      ServiceWebRequest operation = new ServiceWebRequest(thumbprint);
     175      string requestId = operation.Invoke(uri, payload);
     176      return requestId;
     177    }
     178
     179    public static string CreateHostedServiceWithLocation(string subscriptionId, string thumbprint, string serviceName, string label, string description, string location) {
     180      return CreateHostedService(subscriptionId, thumbprint, serviceName, label, description, location, String.Empty);
     181    }
     182
     183    public static string CreateHostedServiceWithAffinityGroup(string subscriptionId, string thumbprint, string serviceName, string label, string description, string affinityGroup) {
     184      return CreateHostedService(subscriptionId, thumbprint, serviceName, label, description, String.Empty, affinityGroup);
     185    }
     186
     187
     188
    171189    #endregion
    172190
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddAzureServiceDialog.Designer.cs

    r7339 r7354  
    3030      this.gbNewHostedService = new System.Windows.Forms.GroupBox();
    3131      this.cmbAffinityGroup = new System.Windows.Forms.ComboBox();
    32       this.cmbRegion = new System.Windows.Forms.ComboBox();
     32      this.cmbLocation = new System.Windows.Forms.ComboBox();
    3333      this.rbAffinitGroup = new System.Windows.Forms.RadioButton();
    3434      this.rbRegion = new System.Windows.Forms.RadioButton();
    3535      this.label6 = new System.Windows.Forms.Label();
    3636      this.label5 = new System.Windows.Forms.Label();
    37       this.tbURLPrefix = new System.Windows.Forms.TextBox();
     37      this.tbServiceName = new System.Windows.Forms.TextBox();
    3838      this.label4 = new System.Windows.Forms.Label();
    39       this.tbServiceName = new System.Windows.Forms.TextBox();
     39      this.tbLabel = new System.Windows.Forms.TextBox();
    4040      this.label3 = new System.Windows.Forms.Label();
    4141      this.cbNewHostedService = new System.Windows.Forms.CheckBox();
    4242      this.label7 = new System.Windows.Forms.Label();
    4343      this.panelDeploymentOptions = new System.Windows.Forms.Panel();
     44      this.rbDeployToProduction = new System.Windows.Forms.RadioButton();
    4445      this.rbDeployToStaging = new System.Windows.Forms.RadioButton();
    45       this.rbDeployToProduction = new System.Windows.Forms.RadioButton();
    4646      this.btnAddCertificate = new System.Windows.Forms.Button();
    4747      this.label9 = new System.Windows.Forms.Label();
     
    9494      //
    9595      this.gbNewHostedService.Controls.Add(this.cmbAffinityGroup);
    96       this.gbNewHostedService.Controls.Add(this.cmbRegion);
     96      this.gbNewHostedService.Controls.Add(this.cmbLocation);
    9797      this.gbNewHostedService.Controls.Add(this.rbAffinitGroup);
    9898      this.gbNewHostedService.Controls.Add(this.rbRegion);
    9999      this.gbNewHostedService.Controls.Add(this.label6);
    100100      this.gbNewHostedService.Controls.Add(this.label5);
    101       this.gbNewHostedService.Controls.Add(this.tbURLPrefix);
     101      this.gbNewHostedService.Controls.Add(this.tbServiceName);
    102102      this.gbNewHostedService.Controls.Add(this.label4);
    103       this.gbNewHostedService.Controls.Add(this.tbServiceName);
     103      this.gbNewHostedService.Controls.Add(this.tbLabel);
    104104      this.gbNewHostedService.Controls.Add(this.label3);
    105105      this.gbNewHostedService.Location = new System.Drawing.Point(15, 115);
     
    118118      this.cmbAffinityGroup.TabIndex = 9;
    119119      //
    120       // cmbRegion
    121       //
    122       this.cmbRegion.FormattingEnabled = true;
    123       this.cmbRegion.Location = new System.Drawing.Point(29, 110);
    124       this.cmbRegion.Name = "cmbRegion";
    125       this.cmbRegion.Size = new System.Drawing.Size(200, 21);
    126       this.cmbRegion.TabIndex = 8;
     120      // cmbLocation
     121      //
     122      this.cmbLocation.FormattingEnabled = true;
     123      this.cmbLocation.Location = new System.Drawing.Point(29, 110);
     124      this.cmbLocation.Name = "cmbLocation";
     125      this.cmbLocation.Size = new System.Drawing.Size(200, 21);
     126      this.cmbLocation.TabIndex = 8;
    127127      //
    128128      // rbAffinitGroup
     
    164164      this.label5.Text = ".cloudapp.net";
    165165      //
    166       // tbURLPrefix
    167       //
    168       this.tbURLPrefix.Location = new System.Drawing.Point(9, 71);
    169       this.tbURLPrefix.Name = "tbURLPrefix";
    170       this.tbURLPrefix.Size = new System.Drawing.Size(377, 20);
    171       this.tbURLPrefix.TabIndex = 3;
     166      // tbServiceName
     167      //
     168      this.tbServiceName.Location = new System.Drawing.Point(9, 71);
     169      this.tbServiceName.Name = "tbServiceName";
     170      this.tbServiceName.Size = new System.Drawing.Size(377, 20);
     171      this.tbServiceName.TabIndex = 3;
    172172      //
    173173      // label4
     
    180180      this.label4.Text = "Enter a URL prefix for your service";
    181181      //
    182       // tbServiceName
    183       //
    184       this.tbServiceName.Location = new System.Drawing.Point(9, 32);
    185       this.tbServiceName.Name = "tbServiceName";
    186       this.tbServiceName.Size = new System.Drawing.Size(453, 20);
    187       this.tbServiceName.TabIndex = 1;
     182      // tbLabel
     183      //
     184      this.tbLabel.Location = new System.Drawing.Point(9, 32);
     185      this.tbLabel.Name = "tbLabel";
     186      this.tbLabel.Size = new System.Drawing.Size(453, 20);
     187      this.tbLabel.TabIndex = 1;
    188188      //
    189189      // label3
     
    225225      this.panelDeploymentOptions.TabIndex = 10;
    226226      //
    227       // rbDeployToStaging
    228       //
    229       this.rbDeployToStaging.AutoSize = true;
    230       this.rbDeployToStaging.Location = new System.Drawing.Point(0, 4);
    231       this.rbDeployToStaging.Name = "rbDeployToStaging";
    232       this.rbDeployToStaging.Size = new System.Drawing.Size(168, 17);
    233       this.rbDeployToStaging.TabIndex = 0;
    234       this.rbDeployToStaging.TabStop = true;
    235       this.rbDeployToStaging.Text = "Deploy to staging environment";
    236       this.rbDeployToStaging.UseVisualStyleBackColor = true;
    237       //
    238227      // rbDeployToProduction
    239228      //
     
    246235      this.rbDeployToProduction.Text = "Deyploy to production environment";
    247236      this.rbDeployToProduction.UseVisualStyleBackColor = true;
     237      //
     238      // rbDeployToStaging
     239      //
     240      this.rbDeployToStaging.AutoSize = true;
     241      this.rbDeployToStaging.Checked = true;
     242      this.rbDeployToStaging.Location = new System.Drawing.Point(0, 4);
     243      this.rbDeployToStaging.Name = "rbDeployToStaging";
     244      this.rbDeployToStaging.Size = new System.Drawing.Size(168, 17);
     245      this.rbDeployToStaging.TabIndex = 0;
     246      this.rbDeployToStaging.TabStop = true;
     247      this.rbDeployToStaging.Text = "Deploy to staging environment";
     248      this.rbDeployToStaging.UseVisualStyleBackColor = true;
    248249      //
    249250      // btnAddCertificate
     
    360361    private System.Windows.Forms.GroupBox gbNewHostedService;
    361362    private System.Windows.Forms.ComboBox cmbAffinityGroup;
    362     private System.Windows.Forms.ComboBox cmbRegion;
     363    private System.Windows.Forms.ComboBox cmbLocation;
    363364    private System.Windows.Forms.RadioButton rbAffinitGroup;
    364365    private System.Windows.Forms.RadioButton rbRegion;
    365366    private System.Windows.Forms.Label label6;
    366367    private System.Windows.Forms.Label label5;
    367     private System.Windows.Forms.TextBox tbURLPrefix;
     368    private System.Windows.Forms.TextBox tbServiceName;
    368369    private System.Windows.Forms.Label label4;
    369     private System.Windows.Forms.TextBox tbServiceName;
     370    private System.Windows.Forms.TextBox tbLabel;
    370371    private System.Windows.Forms.Label label3;
    371372    private System.Windows.Forms.CheckBox cbNewHostedService;
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Views/AddAzureServiceDialog.cs

    r7339 r7354  
    1414    private BindingList<AffinityGroup> affinityGroups;
    1515
    16     private BackgroundWorker worker = new BackgroundWorker();
     16    private BackgroundWorker worker;
     17
     18    private bool isInitializing;
     19    private bool bwCompleted;
     20    private bool closePending;
    1721
    1822    public AddAzureServiceDialog(IItemList<Subscription> subs) {
    1923      InitializeComponent();
     24      isInitializing = true;
    2025
    2126      this.subscriptions = new BindingList<Subscription>(subs);
     27      this.hostedServices = new BindingList<HostedService>();
     28      this.locations = new BindingList<string>();
     29      this.affinityGroups = new BindingList<AffinityGroup>();
    2230
     31      SetLookupBinding(cmbLocation, locations, "", "");
     32      SetLookupBinding(cmbAffinityGroup, affinityGroups, "Label", "Name");
     33      SetLookupBinding(cmbChooseHostedService, hostedServices, "ServiceName", "ServiceName");
    2334      SetLookupBinding(cmbChooseSubscription, subscriptions, "SubscriptionName", "SubscriptionID");
    24       SetLookupBinding(cmbChooseHostedService, hostedServices, "ServiceName", "ServiceName");
    25       SetLookupBinding(cmbRegion, locations, "", "");
    26       SetLookupBinding(cmbAffinityGroup, affinityGroups, "Label", "Name");
    2735
    2836      if (!cbNewHostedService.Checked) {
     
    3038      }
    3139
     40      worker = new BackgroundWorker();
    3241      worker.DoWork += new DoWorkEventHandler(UpdateTask);
    3342      worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(WorkerCompleted);
     43
     44
     45      isInitializing = false;
     46      cmbChooseSubscription_SelectedValueChanged(this, EventArgs.Empty);
     47    }
     48
     49    protected override void OnFormClosing(FormClosingEventArgs e) {
     50      if (!bwCompleted) {
     51        worker.CancelAsync();
     52        this.Enabled = false;
     53        e.Cancel = true;
     54        closePending = true;
     55      }
    3456    }
    3557
     
    6183    }
    6284
     85    private void UpdateBindingList<T>(BindingList<T> bindinglist, List<T> list) {
     86      if (list != null) {
     87        bindinglist.Clear();
     88        foreach (T item in list)
     89          bindinglist.Add(item);
     90      }
     91    }
     92
    6393    private void cbNewHostedService_CheckedChanged(object sender, EventArgs e) {
    6494      if (cbNewHostedService.Checked) {
     
    81111
    82112    private void cmbChooseSubscription_SelectedValueChanged(object sender, EventArgs e) {
    83       Subscription item = (Subscription)cmbChooseSubscription.SelectedItem;
    84       if (item != null) {
    85         progressBar.Visible = true;
    86         worker.RunWorkerAsync(item);
     113      if (!isInitializing) {
     114        Subscription item = (Subscription)cmbChooseSubscription.SelectedItem;
     115        if (item != null) {
     116          progressBar.Visible = true;
     117          worker.RunWorkerAsync(item);
     118        }
    87119      }
    88120    }
     
    101133    private void btnOk_Click(object sender, EventArgs e) {
    102134      if (cmbChooseSubscription.SelectedItem != null) {
    103         // TODO
     135        if (cbNewHostedService.Checked) {
     136          if (rbRegion.Checked) {
     137            string serviceName = tbServiceName.Text;
     138            string label = tbLabel.Text;
     139            string location = (string)cmbLocation.SelectedItem;
     140            Subscription sub = (Subscription)cmbChooseSubscription.SelectedItem;
     141            CloudManagerClient.Instance.AzureProvider.CreateHostedService(sub, serviceName, label, "Hosted service for hive slave", location);
     142          } else {
     143            // rbAffinitGroup.Checked
     144          }
     145        }
     146
    104147      }
    105148    }
     
    113156        this.Invoke((MethodInvoker)delegate { lblCores.Text = item.CurrentCoreCount + " / " + item.MaxCoreCount; });
    114157
    115         SetBindingList<HostedService>(ref hostedServices, CloudManagerClient.Instance.AzureProvider.ListHostedServices(item));
    116         SetBindingList<string>(ref locations, CloudManagerClient.Instance.AzureProvider.ListLocations(item));
    117         SetBindingList<AffinityGroup>(ref affinityGroups, CloudManagerClient.Instance.AzureProvider.ListAffinityGroups(item));
     158        List<HostedService> services = CloudManagerClient.Instance.AzureProvider.ListHostedServices(item);
     159        List<string> locs = CloudManagerClient.Instance.AzureProvider.ListLocations(item);
     160        List<AffinityGroup> groups = CloudManagerClient.Instance.AzureProvider.ListAffinityGroups(item);
     161
     162        this.Invoke((MethodInvoker)delegate { UpdateBindingList<HostedService>(hostedServices, services); });
     163        this.Invoke((MethodInvoker)delegate { UpdateBindingList<string>(locations, locs); });
     164        this.Invoke((MethodInvoker)delegate { UpdateBindingList<AffinityGroup>(affinityGroups, groups); });
    118165
    119166        SetAllControlsEnabled(this, true);
     
    126173    private void WorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
    127174      this.Invoke((MethodInvoker)delegate { progressBar.Visible = false; });
     175      bwCompleted = true;
     176      if (closePending) {
     177        this.Close();
     178      }
    128179    }
    129180  }
Note: See TracChangeset for help on using the changeset viewer.