[7326] | 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 |
|
---|
| 22 | using System;
|
---|
[7299] | 23 | using System.Text;
|
---|
[7281] | 24 | using HeuristicLab.Common;
|
---|
| 25 | using HeuristicLab.Core;
|
---|
| 26 |
|
---|
| 27 | namespace HeuristicLab.Clients.Hive.CloudManager.Model {
|
---|
[7299] | 28 | public class Subscription : Item {
|
---|
[7281] | 29 | public string SubscriptionID { get; set; }
|
---|
| 30 | public string SubscriptionName { get; set; }
|
---|
[7299] | 31 | public string SubscriptionStatus { get; set; }
|
---|
[7281] | 32 | public int MaxCoreCount { get; set; }
|
---|
| 33 | public int MaxHostedServices { get; set; }
|
---|
[7299] | 34 | public int MaxStorageAccounts { get; set; }
|
---|
[7281] | 35 | public int CurrentCoreCount { get; set; }
|
---|
| 36 | public int CurrentHostedServices { get; set; }
|
---|
[7299] | 37 | public int CurrentStorageAccounts { get; set; }
|
---|
[7281] | 38 | public string CertificateThumbprint { get; set; }
|
---|
| 39 | public bool SaveToConfig { get; set; }
|
---|
| 40 | public bool DiscoverServices { get; set; }
|
---|
| 41 |
|
---|
| 42 | public Subscription() {
|
---|
| 43 |
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | public Subscription(Subscription original, Cloner cloner) {
|
---|
[7299] | 47 | this.SubscriptionID = original.SubscriptionID;
|
---|
| 48 | this.SubscriptionName = original.SubscriptionName;
|
---|
| 49 | this.SubscriptionStatus = original.SubscriptionStatus;
|
---|
| 50 | this.MaxCoreCount = original.MaxCoreCount;
|
---|
| 51 | this.MaxHostedServices = original.MaxHostedServices;
|
---|
| 52 | this.MaxStorageAccounts = original.MaxStorageAccounts;
|
---|
| 53 | this.CurrentCoreCount = original.CurrentCoreCount;
|
---|
| 54 | this.CurrentHostedServices = original.CurrentHostedServices;
|
---|
| 55 | this.CurrentStorageAccounts = original.CurrentStorageAccounts;
|
---|
| 56 | this.CertificateThumbprint = original.CertificateThumbprint;
|
---|
| 57 | this.SaveToConfig = original.SaveToConfig;
|
---|
| 58 | this.DiscoverServices = original.DiscoverServices;
|
---|
[7281] | 59 | }
|
---|
| 60 |
|
---|
| 61 | //public Subscription(Subscription original, Cloner cloner) {}
|
---|
| 62 |
|
---|
| 63 | public override string ToString() {
|
---|
| 64 | StringBuilder sb = new StringBuilder();
|
---|
| 65 | sb.AppendFormat("AzureSubscription: Id={0}, Name={1}, CoreCount={2}/{3}, HostedServices={4}/{5};", SubscriptionID, SubscriptionName, CurrentCoreCount, MaxCoreCount, CurrentHostedServices, MaxHostedServices);
|
---|
| 66 | return sb.ToString();
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | public override int GetHashCode() {
|
---|
| 70 | return base.GetHashCode();
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | public override bool Equals(object obj) {
|
---|
| 74 | if (obj == null)
|
---|
| 75 | return false;
|
---|
| 76 | Subscription sub = obj as Subscription;
|
---|
| 77 | if ((this.SubscriptionID == sub.SubscriptionID))
|
---|
| 78 | return true;
|
---|
| 79 | else
|
---|
| 80 | return false;
|
---|
| 81 | }
|
---|
| 82 |
|
---|
| 83 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 84 | return new Subscription(this, cloner);
|
---|
| 85 | }
|
---|
[7299] | 86 |
|
---|
| 87 | public void Merge(Subscription subscription) {
|
---|
| 88 | if (!this.Equals(subscription)) {
|
---|
| 89 | throw new ArgumentException("Objects must be equal to be merged.", "subscription");
|
---|
| 90 | }
|
---|
| 91 | this.SubscriptionName = subscription.SubscriptionName;
|
---|
| 92 | this.SubscriptionStatus = subscription.SubscriptionStatus;
|
---|
| 93 | this.MaxCoreCount = subscription.MaxCoreCount;
|
---|
| 94 | this.MaxHostedServices = subscription.MaxHostedServices;
|
---|
| 95 | this.MaxStorageAccounts = subscription.MaxStorageAccounts;
|
---|
| 96 | this.CurrentCoreCount = subscription.CurrentCoreCount;
|
---|
| 97 | this.CurrentHostedServices = subscription.CurrentHostedServices;
|
---|
| 98 | this.CurrentStorageAccounts = subscription.CurrentStorageAccounts;
|
---|
| 99 | this.CertificateThumbprint = subscription.CertificateThumbprint;
|
---|
| 100 | this.SaveToConfig = subscription.SaveToConfig;
|
---|
| 101 | this.DiscoverServices = subscription.DiscoverServices;
|
---|
| 102 | }
|
---|
[7655] | 103 |
|
---|
| 104 | public string GetSettingString() {
|
---|
| 105 | return SubscriptionID + ";" + CertificateThumbprint;
|
---|
| 106 | }
|
---|
| 107 |
|
---|
| 108 | public static Subscription ParseSettingString(string settingString) {
|
---|
| 109 | int idxSeparator = settingString.IndexOf(';');
|
---|
| 110 | string subId = settingString.Substring(0, idxSeparator);
|
---|
[7668] | 111 | int length = settingString.Length - 1 - idxSeparator;
|
---|
| 112 | string certThumbprint = settingString.Substring(idxSeparator + 1, length);
|
---|
[7655] | 113 | Subscription sub = new Subscription();
|
---|
| 114 | sub.SubscriptionID = subId;
|
---|
| 115 | sub.CertificateThumbprint = certThumbprint;
|
---|
| 116 | return sub;
|
---|
| 117 | }
|
---|
[7281] | 118 | }
|
---|
| 119 | }
|
---|