Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7326 for branches


Ignore:
Timestamp:
01/13/12 16:01:39 (13 years ago)
Author:
spimming
Message:

#1680:

  • New model classes
  • New service operation methods added
  • License information added
Location:
branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3
Files:
7 added
5 edited

Legend:

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

    r7299 r7326  
    7272    }
    7373
     74    public static List<AffinityGroup> ListAffinityGroups(string subscriptionId, string thumbprint) {
     75      string uri = String.Format(Constants.URIAffinityGroupFormat, subscriptionId);
     76      ServiceWebRequest operation = new ServiceWebRequest(thumbprint);
     77      XDocument response = operation.Invoke(uri);
     78      List<AffinityGroup> result = null;
     79      if (response.Root.HasElements) {
     80        result = (from s in response.Elements()
     81                  select new AffinityGroup() {
     82                    Name = s.Descendants(wa + "Name").Single().Value,
     83                    Label = Utils.ConvertFromBase64String(s.Descendants(wa + "Label").Single().Value),
     84                    Description = s.Descendants(wa + "Description").Single().Value,
     85                    Location = s.Descendants(wa + "Location").Single().Value
     86                  }).ToList();
     87      }
     88      return result;
     89    }
     90
     91    public static List<HostedService> ListHostedServices(string subscriptionId, string thumbprint) {
     92      string uri = String.Format(Constants.URIHostedServiceFormat, subscriptionId);
     93      ServiceWebRequest operation = new ServiceWebRequest(thumbprint);
     94      XDocument response = operation.Invoke(uri);
     95      List<HostedService> result = null;
     96      if (response.Root.HasElements) {
     97
     98        result = (from s in response.Elements()
     99                  select new HostedService() {
     100                    ServiceName = s.Descendants(wa + "ServiceName").Single().Value,
     101                    Url = s.Descendants(wa + "Url").Single().Value
     102                  }).ToList();
     103      }
     104
     105      if (result != null)
     106        return result;
     107      else
     108        return new List<HostedService>();
     109    }
     110
     111    public static HostedService GetHostedService(string subscriptionId, string thumbprint, string serviceName) {
     112      string uri = String.Format(Constants.URISpecificHostedServiceFormat, subscriptionId, serviceName);
     113      ServiceWebRequest operation = new ServiceWebRequest(thumbprint);
     114      XDocument response = operation.Invoke(uri);
     115      HostedService service = new HostedService();
     116      service.ServiceName = response.Descendants(wa + "ServiceName").Single().Value;
     117      service.Url = response.Descendants(wa + "Url").Single().Value;
     118      return service;
     119    }
     120
     121    public static HostedService GetHostedServiceDetailed(string subscriptionId, string thumbprint, string serviceName) {
     122      string uri = String.Format(Constants.URISpecificHostedServiceFormat + "?embed-detail=true", subscriptionId, serviceName);
     123      ServiceWebRequest operation = new ServiceWebRequest(thumbprint);
     124      XDocument response = operation.Invoke(uri);
     125      HostedService service = new HostedService();
     126      service.ServiceName = response.Descendants(wa + "ServiceName").Single().Value;
     127      service.Url = response.Descendants(wa + "Url").First().Value;
     128      if (response.Root.Elements(wa + "HostedServiceProperties").Any()) {
     129        XElement xHostedServiceProperties = response.Descendants(wa + "HostedServiceProperties").Single();
     130        string loc = string.Empty, affgroup = string.Empty;
     131        if (xHostedServiceProperties.HasElements) {
     132          string desc = xHostedServiceProperties.Descendants(wa + "Description").Single().Value;
     133          if (xHostedServiceProperties.Descendants(wa + "Location").Any()) {
     134            loc = xHostedServiceProperties.Descendants(wa + "Location").Single().Value;
     135          } else {
     136            affgroup = xHostedServiceProperties.Descendants(wa + "AffinityGroup").Single().Value;
     137          }
     138          string lbl = Utils.ConvertFromBase64String(xHostedServiceProperties.Descendants(wa + "Label").Single().Value);
     139          HostedServiceProperties props = new HostedServiceProperties() {
     140            Description = desc,
     141            Location = loc,
     142            AffinityGroup = affgroup,
     143            Label = lbl
     144          };
     145          service.HostedServiceProperties = props;
     146        }
     147      }
     148
     149      if (response.Root.Elements(wa + "Deployments").Any()) {
     150        XElement xDeployments = response.Descendants(wa + "Deployments").Single();
     151        if (xDeployments.HasElements) {
     152          IEnumerable<Deployment> deps = (from s in xDeployments.Elements()
     153                                          select GetDeploymentFromXml(s)).ToList();
     154          service.Deployments = new List<Deployment>(deps);
     155        } else {
     156          service.Deployments = new List<Deployment>();
     157        }
     158      }
     159
     160      return service;
     161    }
     162
     163    private static Deployment GetDeploymentFromXml(XElement xDeployment) {
     164      Deployment deployment = new Deployment();
     165      deployment.Name = xDeployment.Descendants(wa + "Name").Single().Value;
     166      deployment.DeploymentSlot = xDeployment.Descendants(wa + "DeploymentSlot").Single().Value;
     167      deployment.PrivateID = xDeployment.Descendants(wa + "PrivateID").Single().Value;
     168      deployment.Status = xDeployment.Descendants(wa + "Status").Single().Value;
     169      deployment.Label = Utils.ConvertFromBase64String(xDeployment.Descendants(wa + "Label").Single().Value);
     170      if (xDeployment.Descendants(wa + "Url").Any()) {
     171        deployment.Url = xDeployment.Descendants(wa + "Url").Single().Value;
     172      }
     173      deployment.Configuration = Utils.ConvertFromBase64String(xDeployment.Descendants(wa + "Configuration").Single().Value);
     174
     175      XElement xRoleInstanceList = xDeployment.Descendants(wa + "RoleInstanceList").Single();
     176      if (xRoleInstanceList.HasElements) {
     177        IEnumerable<RoleInstance> instances = (from s in xRoleInstanceList.Elements()
     178                                               select new RoleInstance() {
     179                                                 RoleName = s.Descendants(wa + "RoleName").Single().Value,
     180                                                 InstanceName = s.Descendants(wa + "InstanceName").Single().Value,
     181                                                 InstanceStatus = s.Descendants(wa + "InstanceStatus").Single().Value
     182                                               }).ToList();
     183        deployment.RoleInstanceList = new List<RoleInstance>(instances);
     184      }
     185      if (xDeployment.Descendants(wa + "RoleList").Any()) {
     186        XElement xRoleList = xDeployment.Descendants(wa + "RoleList").Single();
     187        if (xRoleList.HasElements) {
     188
     189          IEnumerable<Role> roles = (from s in xRoleList.Elements()
     190                                     select new Role() {
     191                                       RoleName = s.Descendants(wa + "RoleName").Single().Value,
     192                                       OsVersion = s.Descendants(wa + "OsVersion").Single().Value
     193                                     }).ToList();
     194          deployment.RoleList = new List<Role>(roles);
     195        }
     196      }
     197
     198      if (xDeployment.Descendants(wa + "UpgradeDomainCount").Any()) {
     199        deployment.UpgradeDomainCount = Convert.ToInt32(xDeployment.Descendants(wa + "UpgradeDomainCount").Single().Value);
     200      }
     201
     202      if (xDeployment.Elements("UpgradeStatus").Any()) {
     203        XElement xUpgradeStatus = xDeployment.Descendants(wa + "UpgradeStatus").Single();
     204        if (xUpgradeStatus.HasElements) {
     205          UpgradeStatus upgradestatus = new UpgradeStatus() {
     206            UpgradeType = xUpgradeStatus.Descendants(wa + "RoleName").Single().Value,
     207            CurrentUpgradeDomain = Convert.ToInt32(xUpgradeStatus.Descendants(wa + "RoleName").Single().Value),
     208            CurrentUpgradeDomainState = xUpgradeStatus.Descendants(wa + "RoleName").Single().Value
     209          };
     210          deployment.UpgradeStatus = upgradestatus;
     211        }
     212      }
     213      return deployment;
     214    }
     215
     216
     217
    74218    #endregion
    75219
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/ServiceWebRequest.cs

    r7299 r7326  
    165165      catch (Exception e) {
    166166        if (e is CryptographicException)
    167           Debug.WriteLine("Error: The sotre is unreadable.");
     167          throw new SystemException("Error: The certificate store is unreadable.");
    168168        else if (e is SecurityException)
    169           Debug.WriteLine("Error: You don't have the required permission.");
     169          throw new SystemException("Error: You don't have the required permission.");
    170170        else if (e is ArgumentException)
    171           Debug.WriteLine("Error: Invalid values in the store.");
     171          throw new SystemException("Error: Invalid values in the certificate store.");
    172172        else
    173           throw;
     173          throw new SystemException(e.Message, e);
    174174      }
    175175      finally {
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/CloudManagerClient.cs

    r7324 r7326  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using HeuristicLab.Clients.Hive.CloudManager.Azure;
    324using HeuristicLab.Clients.Hive.CloudManager.Model;
     
    6384      try {
    6485        IItemList<Subscription> subs = new ItemList<Subscription>(Subscriptions);
    65         // TODO ...
     86        foreach (Subscription subscription in subs) {
     87          if (subscription.DiscoverServices) {
     88            //Discover
     89          }
     90        }
    6691      }
    6792      catch {
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/HeuristicLab.Clients.Hive.CloudManager-3.3.csproj

    r7324 r7326  
    6161    <Compile Include="CloudManagerClient.cs" />
    6262    <Compile Include="MenuItems\CloudManagerMenuItem.cs" />
     63    <Compile Include="Model\AffinityGroup.cs" />
     64    <Compile Include="Model\Deployment.cs" />
     65    <Compile Include="Model\HostedService.cs" />
     66    <Compile Include="Model\HostedServiceProperties.cs" />
     67    <Compile Include="Model\Role.cs" />
     68    <Compile Include="Model\RoleInstance.cs" />
    6369    <Compile Include="Model\Subscription.cs" />
     70    <Compile Include="Model\UpgradeStatus.cs" />
    6471    <Compile Include="Plugin.cs" />
    6572    <Compile Include="Properties\AssemblyInfo.cs" />
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Model/Subscription.cs

    r7299 r7326  
    1 using System;
     1#region License Information
     2/* HeuristicLab
     3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     4 *
     5 * This file is part of HeuristicLab.
     6 *
     7 * HeuristicLab is free software: you can redistribute it and/or modify
     8 * it under the terms of the GNU General Public License as published by
     9 * the Free Software Foundation, either version 3 of the License, or
     10 * (at your option) any later version.
     11 *
     12 * HeuristicLab is distributed in the hope that it will be useful,
     13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 * GNU General Public License for more details.
     16 *
     17 * You should have received a copy of the GNU General Public License
     18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
     19 */
     20#endregion
     21
     22using System;
    223using System.Text;
    324using HeuristicLab.Common;
Note: See TracChangeset for help on using the changeset viewer.