code
stringlengths 1
2.01M
| repo_name
stringlengths 3
62
| path
stringlengths 1
267
| language
stringclasses 231
values | license
stringclasses 13
values | size
int64 1
2.01M
|
|---|---|---|---|---|---|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using Lokad.Cloud.Application;
namespace Lokad.Cloud.Console.WebRole.Models.Queues
{
public class QueuesModel
{
public AzureQueue[] Queues { get; set; }
public AzureQuarantineQueue[] Quarantine { get; set; }
public bool HasQuarantinedMessages { get; set; }
}
public class AzureQueue
{
public string QueueName { get; set; }
public int MessageCount { get; set; }
public string Latency { get; set; }
public QueueServiceDefinition[] Services { get; set; }
}
public class AzureQuarantineQueue
{
public string QueueName { get; set; }
public AzureQuarantineMessage[] Messages { get; set; }
}
public class AzureQuarantineMessage
{
public string Inserted { get; set; }
public string Persisted { get; set; }
public string Reason { get; set; }
public string Content { get; set; }
public string Key { get; set; }
public bool HasData { get; set; }
public bool HasXml { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Models/Queues/QueuesModel.cs
|
C#
|
bsd
| 1,239
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
namespace Lokad.Cloud.Console.WebRole.Models.Shared
{
public class DiscoveryModel
{
public bool IsAvailable { get; set; }
public bool ShowLastDiscoveryUpdate { get; set; }
public string LastDiscoveryUpdate { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Models/Shared/DiscoveryModel.cs
|
C#
|
bsd
| 422
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
namespace Lokad.Cloud.Console.WebRole.Models.Shared
{
public class NavigationModel
{
public string CurrentController { get; set; }
public string ControllerAction { get; set; }
public bool ShowDeploymentSelector { get; set; }
public string CurrentHostedServiceName { get; set; }
public string[] HostedServiceNames { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Models/Shared/NavigationModel.cs
|
C#
|
bsd
| 547
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
namespace Lokad.Cloud.Console.WebRole.Models.Logs
{
public class LogsModel
{
public string NewestToken { get; set; }
public bool NewerAvailable { get; set; }
public LogGroup[] Groups { get; set; }
}
public class LogGroup
{
public int Key { get; set; }
public string Title { get; set; }
public string NewestToken { get; set; }
public string OldestToken { get; set; }
public bool OlderAvailable { get; set; }
public LogItem[] Entries { get; set; }
}
public class LogItem
{
public string Token { get; set; }
public string Time { get; set; }
public string Level { get; set; }
public string Message { get; set; }
public string Error { get; set; }
public bool ShowDetails { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Models/Logs/LogsModel.cs
|
C#
|
bsd
| 1,022
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using Lokad.Cloud.Management.Api10;
namespace Lokad.Cloud.Console.WebRole.Models.Scheduler
{
public class SchedulerModel
{
public CloudServiceSchedulingInfo[] Schedules { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Models/Scheduler/SchedulerModel.cs
|
C#
|
bsd
| 368
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using Lokad.Cloud.Management.Api10;
using Lokad.Cloud.Application;
namespace Lokad.Cloud.Console.WebRole.Models.Services
{
public class ServicesModel
{
public QueueServiceModel[] QueueServices { get; set; }
public CloudServiceInfo[] ScheduledServices { get; set; }
public CloudServiceInfo[] CloudServices { get; set; }
public CloudServiceInfo[] UnavailableServices { get; set; }
}
public class QueueServiceModel
{
public string ServiceName { get; set; }
public bool IsStarted { get; set; }
public QueueServiceDefinition Definition { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Models/Services/ServicesModel.cs
|
C#
|
bsd
| 802
|
<%@ Application Codebehind="Global.asax.cs" Inherits="Lokad.Cloud.Console.WebRole.MvcApplication" Language="C#" %>
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Global.asax
|
ASP.NET
|
bsd
| 119
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Web;
using System.Web.Mvc;
using Lokad.Cloud.Console.WebRole.Framework.Discovery;
using Ninject.Modules;
using Ninject.Web.Mvc.FilterBindingSyntax;
namespace Lokad.Cloud.Console.WebRole.Behavior
{
public sealed class RequireDiscoveryFilter : IActionFilter
{
private readonly AzureDiscoveryInfo _discoveryInfo;
public RequireDiscoveryFilter(AzureDiscoveryInfo discoveryInfo)
{
_discoveryInfo = discoveryInfo;
}
public void OnActionExecuting(ActionExecutingContext filterContext)
{
if (_discoveryInfo.IsAvailable)
{
return;
}
// do not use 'filterContext.RequestContext.HttpContext.Request.Url' because of Azure port forwarding
// http://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/9142db8d-0f85-47a2-91f7-418bb5a0c675/
var scheme = filterContext.RequestContext.HttpContext.Request.Url.Scheme;
var host = filterContext.RequestContext.HttpContext.Request.Headers["Host"];
var path = filterContext.RequestContext.HttpContext.Request.RawUrl;
var returnUrl = scheme + @"://" + host + path;
filterContext.Result = new RedirectResult("~/Discovery/Index?returnUrl=" + HttpUtility.UrlEncode(returnUrl));
}
public void OnActionExecuted(ActionExecutedContext filterContext)
{
}
}
[AttributeUsage(AttributeTargets.Class)]
public sealed class RequireDiscoveryAttribute : Attribute { }
public sealed class RequireDiscoveryModule : NinjectModule
{
public override void Load()
{
this.BindFilter<RequireDiscoveryFilter>(FilterScope.Controller, 0).WhenControllerHas<RequireDiscoveryAttribute>();
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Behavior/RequireDiscovery.cs
|
C#
|
bsd
| 2,033
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Linq;
namespace Lokad.Cloud.Console.WebRole.Behavior
{
public static class Users
{
public static bool IsAdministrator(string identifier)
{
return CloudConfiguration.Admins
.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
.Contains(identifier);
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Behavior/Users.cs
|
C#
|
bsd
| 536
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Web;
using System.Web.Mvc;
namespace Lokad.Cloud.Console.WebRole.Behavior
{
public sealed class RequireAuthorizationAttribute : AuthorizeAttribute
{
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
// do not use 'filterContext.RequestContext.HttpContext.Request.Url' because of Azure port forwarding
// http://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/9142db8d-0f85-47a2-91f7-418bb5a0c675/
var request = filterContext.RequestContext.HttpContext.Request;
var returnUrl = request.Url.Scheme + @"://" + request.Headers["Host"] + request.RawUrl;
filterContext.Result = new RedirectResult("~/Account/Login?returnUrl=" + HttpUtility.UrlEncode(returnUrl));
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Behavior/RequireAuthorization.cs
|
C#
|
bsd
| 992
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Configuration;
using System.Security.Cryptography.X509Certificates;
using Microsoft.WindowsAzure.ServiceRuntime;
namespace Lokad.Cloud.Console.WebRole
{
public class CloudConfiguration
{
public static string Admins
{
get { return GetSetting("Admins"); }
}
public static string SubscriptionId
{
get { return GetSetting("SubscriptionId"); }
}
public static X509Certificate2 GetManagementCertificate()
{
var thumbprint = GetSetting("ManagementCertificateThumbprint");
var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
try
{
return store.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, false)[0];
}
finally
{
store.Close();
}
}
private static string GetSetting(string name)
{
return RoleEnvironment.IsAvailable
? RoleEnvironment.GetConfigurationSettingValue(name)
: ConfigurationManager.AppSettings[name];
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/CloudConfiguration.cs
|
C#
|
bsd
| 1,410
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Lokad.Cloud.Management.Azure;
using Lokad.Cloud.Management.Azure.InputParameters;
namespace Lokad.Cloud.Console.WebRole.Framework.Discovery
{
public sealed class AzureUpdater
{
private readonly X509Certificate2 _certificate;
private readonly string _subscriptionId;
private readonly ManagementClient _client;
private readonly AzureDiscoveryInfo _info;
public AzureUpdater(AzureDiscoveryInfo discoveryInfo)
{
_info = discoveryInfo;
_subscriptionId = CloudConfiguration.SubscriptionId;
_certificate = CloudConfiguration.GetManagementCertificate();
_client = new ManagementClient(_certificate);
}
public Task UpdateInstanceCountAsync(string hostedServiceName, string slot, int instanceCount)
{
var hostedService = _info.LokadCloudDeployments.Single(hs => hs.ServiceName == hostedServiceName);
var deployment = hostedService.Deployments.Single(d => d.Slot == slot);
var config = deployment.Configuration;
var instanceCountAttribute = config
.Descendants()
.Single(d => d.Name.LocalName == "Role" && d.Attributes().Single(a => a.Name.LocalName == "name").Value == "Lokad.Cloud.WorkerRole")
.Elements()
.Single(e => e.Name.LocalName == "Instances")
.Attributes()
.Single(a => a.Name.LocalName == "count");
// Note: The side effect on the cached discovery info is intended/by design
instanceCountAttribute.Value = instanceCount.ToString();
deployment.IsRunning = false;
deployment.IsTransitioning = true;
return Task.Factory.StartNew(() =>
{
var proxy = _client.CreateChannel();
try
{
proxy.ChangeConfiguration(_subscriptionId, hostedService.ServiceName, deployment.DeploymentName, new ChangeConfigurationInput
{
Configuration = Base64Encode(config.ToString(SaveOptions.DisableFormatting))
});
}
finally
{
_client.CloseChannel(proxy);
}
});
}
private static string Base64Encode(string value)
{
var bytes = Encoding.UTF8.GetBytes(value);
return Convert.ToBase64String(bytes);
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Framework/Discovery/AzureUpdater.cs
|
C#
|
bsd
| 2,967
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Collections.Generic;
using System.Xml.Linq;
using Microsoft.WindowsAzure;
namespace Lokad.Cloud.Console.WebRole.Framework.Discovery
{
public class LokadCloudHostedService
{
public string ServiceName { get; set; }
public string ServiceLabel { get; set; }
public string Description { get; set; }
public List<LokadCloudDeployment> Deployments { get; set; }
public XElement Configuration { get; set; }
public CloudStorageAccount StorageAccount { get; set; }
public string StorageAccountName { get; set; }
public string StorageAccountKeyPrefix { get; set; }
}
public class LokadCloudDeployment
{
public string DeploymentName { get; set; }
public string DeploymentLabel { get; set; }
public string Status { get; set; }
public string Slot { get; set; }
public int InstanceCount { get; set; }
public bool IsRunning { get; set; }
public bool IsTransitioning { get; set; }
public XElement Configuration { get; set; }
public CloudStorageAccount StorageAccount { get; set; }
public string StorageAccountName { get; set; }
public string StorageAccountKeyPrefix { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Framework/Discovery/LokadCloudHostedService.cs
|
C#
|
bsd
| 1,445
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Collections.Generic;
namespace Lokad.Cloud.Console.WebRole.Framework.Discovery
{
public class AzureDiscoveryInfo
{
public bool IsAvailable { get; set; }
public DateTimeOffset Timestamp { get; set; }
public DateTimeOffset FinishedTimestamp { get; set; }
public List<LokadCloudHostedService> LokadCloudDeployments { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Framework/Discovery/AzureDiscoveryInfo.cs
|
C#
|
bsd
| 566
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Lokad.Cloud.Management.Azure;
using Lokad.Cloud.Management.Azure.Entities;
using Lokad.Cloud.Storage;
using Microsoft.WindowsAzure;
namespace Lokad.Cloud.Console.WebRole.Framework.Discovery
{
public sealed class AzureDiscoveryFetcher
{
private readonly X509Certificate2 _certificate;
private readonly string _subscriptionId;
private readonly ManagementClient _client;
public AzureDiscoveryFetcher()
{
_subscriptionId = CloudConfiguration.SubscriptionId;
_certificate = CloudConfiguration.GetManagementCertificate();
_client = new ManagementClient(_certificate);
}
public Task<AzureDiscoveryInfo> FetchAsync()
{
return Task.Factory.StartNew(() =>
{
var started = DateTimeOffset.UtcNow;
var proxy = _client.CreateChannel();
try
{
return new AzureDiscoveryInfo
{
LokadCloudDeployments = FetchLokadCloudHostedServices(proxy)
.Select(MapHostedService).OrderBy(hs => hs.ServiceName).ToList(),
IsAvailable = true,
Timestamp = started,
FinishedTimestamp = DateTimeOffset.UtcNow
};
}
finally
{
_client.CloseChannel(proxy);
}
});
}
private IEnumerable<HostedService> FetchLokadCloudHostedServices(IAzureServiceManagement proxy)
{
return proxy
.ListHostedServices(_subscriptionId)
.AsParallel()
.Select(service => proxy.GetHostedServiceWithDetails(_subscriptionId, service.ServiceName, true))
.Where(hs => hs.Deployments.Any(d => d.RoleInstanceList.Exists(ri => ri.RoleName == "Lokad.Cloud.WorkerRole")));
}
private static LokadCloudHostedService MapHostedService(HostedService hostedService)
{
var lokadCloudDeployments = hostedService.Deployments.Select(d =>
{
var config = XElement.Parse(Base64Decode(hostedService.Deployments.First().Configuration));
var nn = config.Name.NamespaceName;
var xmlWorkerRole = config.Elements().Single(x => x.Attribute("name").Value == "Lokad.Cloud.WorkerRole");
var xmlConfigSettings = xmlWorkerRole.Element(XName.Get("ConfigurationSettings", nn));
var xmlDataConnectionString = xmlConfigSettings.Elements().Single(x => x.Attribute("name").Value == "DataConnectionString").Attribute("value").Value;
var storageAccount = CloudStorageAccount.Parse(xmlDataConnectionString);
var accountAndKey = storageAccount.Credentials as StorageCredentialsAccountAndKey;
return new LokadCloudDeployment
{
DeploymentName = d.Name,
DeploymentLabel = Base64Decode(d.Label),
Status = d.Status.ToString(),
Slot = d.DeploymentSlot.ToString(),
InstanceCount = d.RoleInstanceList.Count(ri => ri.RoleName == "Lokad.Cloud.WorkerRole"),
IsRunning = d.Status == DeploymentStatus.Running,
IsTransitioning =
d.Status != DeploymentStatus.Running && d.Status != DeploymentStatus.Suspended,
Configuration = config,
StorageAccount = storageAccount,
StorageAccountName = storageAccount.Credentials.AccountName,
StorageAccountKeyPrefix = accountAndKey != null ? accountAndKey.Credentials.ExportBase64EncodedKey().Substring(0, 4) : null,
};
}).ToList();
return new LokadCloudHostedService
{
ServiceName = hostedService.ServiceName,
ServiceLabel = Base64Decode(hostedService.HostedServiceProperties.Label),
Description = hostedService.HostedServiceProperties.Description,
Deployments = lokadCloudDeployments,
Configuration = lokadCloudDeployments[0].Configuration,
StorageAccount = lokadCloudDeployments[0].StorageAccount,
StorageAccountName = lokadCloudDeployments[0].StorageAccountName,
StorageAccountKeyPrefix = lokadCloudDeployments[0].StorageAccountKeyPrefix,
};
}
private static string Base64Decode(string value)
{
var bytes = Convert.FromBase64String(value);
return Encoding.UTF8.GetString(bytes);
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Framework/Discovery/AzureDiscoveryFetcher.cs
|
C#
|
bsd
| 5,527
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using Ninject;
using Ninject.Modules;
namespace Lokad.Cloud.Console.WebRole.Framework.Discovery
{
public class DiscoveryNinjectModule : NinjectModule
{
public override void Load()
{
Bind<AzureDiscoveryFetcher>().ToSelf().InSingletonScope();
Bind<AzureDiscoveryProvider>().ToSelf();
Bind<AzureUpdater>().ToSelf();
Bind<AzureDiscoveryInfo>()
.ToMethod(c => c.Kernel.Get<AzureDiscoveryProvider>().GetDiscoveryInfo())
.InRequestScope();
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Framework/Discovery/DiscoveryNinjectModule.cs
|
C#
|
bsd
| 739
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using System.Web.Caching;
namespace Lokad.Cloud.Console.WebRole.Framework.Discovery
{
public class AzureDiscoveryProvider
{
private readonly AzureDiscoveryFetcher _fetcher;
public AzureDiscoveryProvider(AzureDiscoveryFetcher fetcher)
{
_fetcher = fetcher;
}
public AzureDiscoveryInfo GetDiscoveryInfo()
{
// Hardcoded against HttpRuntime Cache for simplicity
return HttpRuntime.Cache.Get("lokadcloud-DiscoveryInfo") as AzureDiscoveryInfo
?? new AzureDiscoveryInfo
{
IsAvailable = false,
Timestamp = DateTimeOffset.UtcNow,
LokadCloudDeployments = new List<LokadCloudHostedService>()
};
}
public Task<AzureDiscoveryInfo> UpdateAsync()
{
var fetchTask = _fetcher.FetchAsync();
// Insert into HttpRuntime Cache once finished
fetchTask.ContinueWith(discoveryInfo => HttpRuntime.Cache.Insert(
"lokadcloud-DiscoveryInfo", discoveryInfo.Result,
null, DateTime.UtcNow.AddMinutes(60), Cache.NoSlidingExpiration),
TaskContinuationOptions.OnlyOnRanToCompletion);
return fetchTask;
}
public void StartAutomaticCacheUpdate(CancellationToken cancellationToken)
{
// Handler is reentrant. Doesn't make sense in practice but we don't prevent it technically.
var timer = new Timer(state => UpdateAsync(), null, TimeSpan.Zero, TimeSpan.FromMinutes(5));
cancellationToken.Register(timer.Dispose);
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Framework/Discovery/AzureDiscoveryProvider.cs
|
C#
|
bsd
| 2,036
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Linq;
using System.Text;
using System.Web;
using System.Xml;
using Lokad.Cloud.Application;
using Lokad.Cloud.Console.WebRole.Helpers;
using Lokad.Cloud.Console.WebRole.Models.Queues;
using Lokad.Cloud.Console.WebRole.Models.Services;
using Lokad.Cloud.Management;
using Lokad.Cloud.Management.Api10;
using Lokad.Cloud.Runtime;
using Lokad.Cloud.Storage;
using Lokad.Cloud.Storage.Shared;
namespace Lokad.Cloud.Console.WebRole.Framework.Services
{
public class AppDefinitionWithLiveDataProvider
{
const string FailingMessagesStoreName = "failing-messages";
private readonly RuntimeProviders _runtimeProviders;
public AppDefinitionWithLiveDataProvider(RuntimeProviders runtimeProviders)
{
_runtimeProviders = runtimeProviders;
}
public ServicesModel QueryServices()
{
var serviceManager = new CloudServices(_runtimeProviders);
var services = serviceManager.GetServices();
var inspector = new CloudApplicationInspector(_runtimeProviders);
var applicationDefinition = inspector.Inspect();
if (!applicationDefinition.HasValue)
{
return new ServicesModel
{
QueueServices = new QueueServiceModel[0],
ScheduledServices = new CloudServiceInfo[0],
CloudServices = new CloudServiceInfo[0],
UnavailableServices = new CloudServiceInfo[0]
};
}
var appDefinition = applicationDefinition.Value;
var queueServices = services.Join(
appDefinition.QueueServices,
s => s.ServiceName,
d => d.TypeName,
(s, d) => new QueueServiceModel { ServiceName = s.ServiceName, IsStarted = s.IsStarted, Definition = d }).ToArray();
var scheduledServices = services.Where(s => appDefinition.ScheduledServices.Any(ads => ads.TypeName.StartsWith(s.ServiceName))).ToArray();
var otherServices = services.Where(s => appDefinition.CloudServices.Any(ads => ads.TypeName.StartsWith(s.ServiceName))).ToArray();
var unavailableServices = services
.Where(s => !queueServices.Any(d => d.ServiceName == s.ServiceName))
.Except(scheduledServices).Except(otherServices).ToArray();
return new ServicesModel
{
QueueServices = queueServices,
ScheduledServices = scheduledServices,
CloudServices = otherServices,
UnavailableServices = unavailableServices
};
}
public QueuesModel QueryQueues()
{
var queueStorage = _runtimeProviders.QueueStorage;
var inspector = new CloudApplicationInspector(_runtimeProviders);
var applicationDefinition = inspector.Inspect();
var failingMessages = queueStorage.ListPersisted(FailingMessagesStoreName)
.Select(key => queueStorage.GetPersisted(FailingMessagesStoreName, key))
.Where(m => m.HasValue)
.Select(m => m.Value)
.OrderByDescending(m => m.PersistenceTime)
.Take(50)
.ToList();
return new QueuesModel
{
Queues = queueStorage.List(null).Select(queueName => new AzureQueue
{
QueueName = queueName,
MessageCount = queueStorage.GetApproximateCount(queueName),
Latency = queueStorage.GetApproximateLatency(queueName).Convert(ts => ts.PrettyFormat(), string.Empty),
Services = applicationDefinition.Convert(cd => cd.QueueServices.Where(d => d.QueueName == queueName).ToArray(), new QueueServiceDefinition[0])
}).ToArray(),
HasQuarantinedMessages = failingMessages.Count > 0,
Quarantine = failingMessages
.GroupBy(m => m.QueueName)
.Select(group => new AzureQuarantineQueue
{
QueueName = group.Key,
Messages = group.OrderByDescending(m => m.PersistenceTime)
.Select(m => new AzureQuarantineMessage
{
Inserted = FormatUtil.TimeOffsetUtc(m.InsertionTime.UtcDateTime),
Persisted = FormatUtil.TimeOffsetUtc(m.PersistenceTime.UtcDateTime),
Reason = HttpUtility.HtmlEncode(m.Reason),
Content = FormatQuarantinedLogEntryXmlContent(m),
Key = m.Key,
HasData = m.IsDataAvailable,
HasXml = m.DataXml.HasValue
})
.ToArray()
})
.ToArray()
};
}
static string FormatQuarantinedLogEntryXmlContent(PersistedMessage message)
{
if (!message.IsDataAvailable || !message.DataXml.HasValue)
{
return string.Empty;
}
var sb = new StringBuilder();
var settings = new XmlWriterSettings
{
Indent = true,
IndentChars = " ",
NewLineChars = Environment.NewLine,
NewLineHandling = NewLineHandling.Replace,
OmitXmlDeclaration = true
};
using (var writer = XmlWriter.Create(sb, settings))
{
message.DataXml.Value.WriteTo(writer);
writer.Flush();
}
return HttpUtility.HtmlEncode(sb.ToString());
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Framework/Services/AppDefinitionWithLiveDataProvider.cs
|
C#
|
bsd
| 6,343
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Web.Mvc;
using System.Web.Mvc.Html;
using Lokad.Cloud.Console.WebRole.Models.Shared;
namespace Lokad.Cloud.Console.WebRole.Helpers
{
public static class MenuHtmlExtensions
{
public static MvcHtmlString NavigationMenuEntry(this HtmlHelper htmlHelper, NavigationModel navigationModel, string text, string controller)
{
if (controller == navigationModel.CurrentController || string.IsNullOrEmpty(navigationModel.CurrentHostedServiceName))
{
return BuildMenuEntry(
controller == navigationModel.CurrentController,
htmlHelper.MenuIndexLink(text, controller));
}
return BuildMenuEntry(false, htmlHelper.MenuByHostedServiceLink(text, controller, navigationModel.CurrentHostedServiceName));
}
public static MvcHtmlString DeploymentMenuEntry(this HtmlHelper htmlHelper, NavigationModel navigationModel, string text, string hostedServiceName)
{
return BuildMenuEntry(
navigationModel.CurrentHostedServiceName == hostedServiceName,
htmlHelper.MenuByHostedServiceLink(text, navigationModel.CurrentController, hostedServiceName));
}
private static MvcHtmlString BuildMenuEntry(bool isActive, MvcHtmlString linkHtml)
{
return MvcHtmlString.Create(string.Format("<li{0}>{1}</li>", isActive ? @" class=""active""" : string.Empty, linkHtml));
}
public static MvcHtmlString MenuIndexLink(this HtmlHelper htmlHelper, string text, string controller)
{
return htmlHelper.RouteLink(text, "MenuIndex", new { controller, action = "Index" });
}
public static MvcHtmlString MenuByHostedServiceLink(this HtmlHelper htmlHelper, string text, string controller, string hostedServiceName)
{
return htmlHelper.RouteLink(text, "MenuByHostedService", new { controller, hostedServiceName, action = "ByHostedService" });
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Helpers/MenuHtmlExtensions.cs
|
C#
|
bsd
| 2,222
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using Lokad.Cloud.Storage.Shared.Logging;
namespace Lokad.Cloud.Console.WebRole.Helpers
{
public static class IconMap
{
public const string Loading = "icon-loading";
public const string GoodBad = "icon-GoodBad";
public static string GoodBadOf(bool isGood)
{
return string.Concat(GoodBad, (isGood ? "-Good" : "-VeryBad"));
}
public const string LogLevels = "icon-LogLevels";
public static string LogLevelsOf(LogLevel level)
{
return string.Concat(LogLevels, "-", level.ToString());
}
public static string LogLevelsOf(string level)
{
return string.Concat(LogLevels, "-", level);
}
public const string OkCancel = "icon-OkCancel";
public static string OkCancelOf(bool isOk)
{
return string.Concat(OkCancel, (isOk ? "-Ok" : "-Cancel"));
}
public const string PlusMinus = "icon-PlusMinus";
public static string PlusMinusOf(bool isOk)
{
return string.Concat(PlusMinus, (isOk ? "-Plus" : "-Minus"));
}
public const string StartStop = "icon-StartStop";
public static string StartStopOf(StartStopState level)
{
return string.Concat(StartStop, "-", level.ToString());
}
public static string StartStopOf(bool isStart)
{
return StartStopOf(isStart ? StartStopState.Start : StartStopState.Stop);
}
}
public enum StartStopState
{
Start,
Stop,
Pause,
Standby
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Helpers/IconMap.cs
|
C#
|
bsd
| 1,816
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Web.Mvc;
namespace Lokad.Cloud.Console.WebRole.Helpers
{
public static class IconHtmlExtensions
{
private const string InlineImageHtml = @"<span class=""{0} {1}""></span>";
private const string InlineImageHtmlClientScript = @"<span class=""{0} {0}-' + {1} + '""></span>";
private const string InlineImageHtmlButton = @"<span id=""{2}"" class=""{0} {1} icon-button""></span>";
public static MvcHtmlString GoodBadIcon(this HtmlHelper htmlHelper, bool isGood)
{
return MvcHtmlString.Create(string.Format(InlineImageHtml, IconMap.GoodBad, IconMap.GoodBadOf(isGood)));
}
public static MvcHtmlString LogLevelIcon(this HtmlHelper htmlHelper, string logLevel)
{
return MvcHtmlString.Create(string.Format(InlineImageHtml, IconMap.LogLevels, IconMap.LogLevelsOf(logLevel)));
}
public static MvcHtmlString LogLevelIconClientScript(this HtmlHelper htmlHelper, string logLevelExpression)
{
return MvcHtmlString.Create(string.Format(InlineImageHtmlClientScript, IconMap.LogLevels, logLevelExpression));
}
public static MvcHtmlString OkCancelIcon(this HtmlHelper htmlHelper, bool isOk)
{
return MvcHtmlString.Create(string.Format(InlineImageHtml, IconMap.OkCancel, IconMap.OkCancelOf(isOk)));
}
public static MvcHtmlString PlusMinusIcon(this HtmlHelper htmlHelper, bool isPlus)
{
return MvcHtmlString.Create(string.Format(InlineImageHtml, IconMap.PlusMinus, IconMap.PlusMinusOf(isPlus)));
}
public static MvcHtmlString StartStopIcon(this HtmlHelper htmlHelper, bool isStart)
{
return MvcHtmlString.Create(string.Format(InlineImageHtml, IconMap.StartStop, IconMap.StartStopOf(isStart)));
}
public static MvcHtmlString StartStopIconButton(this HtmlHelper htmlHelper, bool isStart, string id)
{
return MvcHtmlString.Create(string.Format(InlineImageHtmlButton, IconMap.StartStop, IconMap.StartStopOf(isStart), id));
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Helpers/IconHtmlExtensions.cs
|
C#
|
bsd
| 2,305
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
namespace Lokad.Cloud.Console.WebRole.Helpers
{
using System.Text;
using System.Web.Mvc;
public static class JavascriptHtmlExtensions
{
public static MvcHtmlString Enquote(this HtmlHelper htmlHelper, string text)
{
if (string.IsNullOrEmpty(text))
{
return MvcHtmlString.Create(@"""""");
}
var sb = new StringBuilder(text.Length + 4);
sb.Append('"');
var tokens = text.ToCharArray();
for (int i = 0; i < tokens.Length; i++)
{
char c = tokens[i];
switch(tokens[i])
{
case '\\':
case '"':
case '>':
sb.Append('\\');
sb.Append(c);
break;
case '\b':
sb.Append("\\b");
break;
case '\t':
sb.Append("\\t");
break;
case '\n':
sb.Append("\\n");
break;
case '\f':
sb.Append("\\f");
break;
case '\r':
sb.Append("\\r");
break;
default:
if (c >= ' ')
{
sb.Append(c);
}
break;
}
}
sb.Append('"');
return MvcHtmlString.Create(sb.ToString());
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Helpers/JavascriptHtmlExtensions.cs
|
C#
|
bsd
| 1,917
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using Lokad.Cloud.Management.Api10;
namespace Lokad.Cloud.Console.WebRole.Helpers
{
public static class PresentationHelpers
{
public static string PrettyFormat(this TimeSpan timeSpan)
{
// TODO: Reuse Lokad.Shared FormatUtil, once it supports this scenario (implemented but currently internal)
const int second = 1;
const int minute = 60 * second;
const int hour = 60 * minute;
const int day = 24 * hour;
const int month = 30*day;
double delta = timeSpan.TotalSeconds;
if (delta < 1) return timeSpan.Milliseconds + " ms";
if (delta < 1 * minute) return timeSpan.Seconds == 1 ? "one second" : timeSpan.Seconds + " seconds";
if (delta < 2 * minute) return "a minute";
if (delta < 50 * minute) return timeSpan.Minutes + " minutes";
if (delta < 70 * minute) return "an hour";
if (delta < 2 * hour) return (int)timeSpan.TotalMinutes + " minutes";
if (delta < 24 * hour) return timeSpan.Hours + " hours";
if (delta < 48 * hour) return (int)timeSpan.TotalHours + " hours";
if (delta < 30 * day) return timeSpan.Days + " days";
if (delta < 12 * month)
{
var months = (int)Math.Floor(timeSpan.Days / 30.0);
return months <= 1 ? "one month" : months + " months";
}
var years = (int)Math.Floor(timeSpan.Days / 365.0);
return years <= 1 ? "one year" : years + " years";
}
public static string PrettyFormatLease(CloudServiceSchedulingInfo info)
{
if (!info.LeasedSince.HasValue || !info.LeasedUntil.HasValue)
{
return "available";
}
var now = DateTimeOffset.UtcNow;
if (info.LeasedUntil.Value < now)
{
return "expired";
}
if (!info.LeasedBy.HasValue || String.IsNullOrEmpty(info.LeasedBy.Value))
{
return String.Format(
"{0} ago, expires in {1}",
now.Subtract(info.LeasedSince.Value).PrettyFormat(),
info.LeasedUntil.Value.Subtract(now).PrettyFormat());
}
return String.Format(
"by {0} {1} ago, expires in {2}",
info.LeasedBy.Value,
now.Subtract(info.LeasedSince.Value).PrettyFormat(),
info.LeasedUntil.Value.Subtract(now).PrettyFormat());
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Helpers/PresentationHelpers.cs
|
C#
|
bsd
| 2,828
|
/*NEW SLIDER STYLES FOR SCALE, ETC*/
/* slider widget */
.ui-slider {
text-decoration: none !important;
}
.ui-slider .ui-slider-handle {
overflow: visible !important;
}
.ui-slider .ui-slider-tooltip {
display: none;
}
.ui-slider .screenReaderContext {
position: absolute;
width: 0;
height: 0;
overflow: hidden;
left: -999999999px;
}
.ui-slider .ui-state-active .ui-slider-tooltip, .ui-slider .ui-state-focus .ui-slider-tooltip, .ui-slider .ui-state-hover .ui-slider-tooltip {
display: block;
position: absolute;
bottom: 2.5em;
text-align: center;
padding: .3em .2em .4em;
font-size: .9em;
width: 8em;
margin-left: -3.7em;
}
.ui-slider .ui-slider-tooltip .ui-tooltip-pointer-down, .ui-slider .ui-slider-tooltip .ui-tooltip-pointer-down-inner {
position: absolute;
display: block;
width:0;
height:0;
border-bottom-width: 0;
background: none;
}
.ui-slider .ui-slider-tooltip .ui-tooltip-pointer-down {
border-left: 7px dashed transparent;
border-right: 7px dashed transparent;
border-top-width: 8px;
bottom: -8px;
right: auto;
left: 50%;
margin-left: -7px;
}
.ui-slider .ui-slider-tooltip .ui-tooltip-pointer-down-inner {
border-left: 6px dashed transparent;
border-right: 6px dashed transparent;
border-top: 7px solid #fff;
bottom: auto;
top: -9px;
left: -6px;
}
.ui-slider a {
text-decoration: none;
}
.ui-slider ol, .ui-slider li, .ui-slider dl, .ui-slider dd, .ui-slider dt {
list-style: none;
margin: 0;
padding: 0;
}
.ui-slider ol, .ui-slider dl {
position: relative;
top: 1.3em;
width: 100%;
}
.ui-slider dt {
top: 1.5em;
position: absolute;
padding-top: .2em;
text-align: center;
border-bottom: 1px dotted #ddd;
height: .7em;
color: #999;
}
.ui-slider dt span {
background: #fff;
padding: 0 .5em;
}
.ui-slider li, .ui-slider dd {
position: absolute;
overflow: visible;
color: #666;
}
.ui-slider span.ui-slider-label {
position: absolute;
}
.ui-slider li span.ui-slider-label, .ui-slider dd span.ui-slider-label {
display: none;
}
.ui-slider li span.ui-slider-label-show, .ui-slider dd span.ui-slider-label-show {
display: block;
}
.ui-slider span.ui-slider-tic {
position: absolute;
left: 0;
height: .8em;
top: -1.3em;
}
.ui-slider li span.ui-widget-content, .ui-slider dd span.ui-widget-content {
border-right: 0;
border-left-width: 1px;
border-left-style: solid;
border-top: 0;
border-bottom: 0;
}
.ui-slider .first .ui-slider-tic, .ui-slider .last .ui-slider-tic {
display: none;
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Content/ui.slider.extras.css
|
CSS
|
bsd
| 2,466
|
/* Copyright (c) Lokad 2009 - All rights reserved */
/* When updating this file do not forget about Lokad.App overrides at the bottom */
body { padding: 0; margin: 0; font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 62.5%; color: #565656; background: #2B2B2B; }
table, img, div, form{ padding:0; margin:0; border:none; }
p { font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; color: #555555; padding: 0; margin: 0; }
h1, h2, h3, h4 { font-family: Arial, Helvetica, sans-serif; font-size: 24px; color: #686868; padding: 0; margin: 0 0 10px 0; font-weight: normal; }
h2 { font-size: 16px; padding: 0px; margin: 0px; font-weight: bold; padding-bottom: 2px; margin-bottom: 0.3em; padding-top: 2px; margin-top: 1em; }
h3 { font-size: 14px; padding: 0px; margin: 0px; font-weight: bold; padding-bottom: 2px; margin-bottom: 0.3em; padding-top: 2px; margin-top: 1em; }
h4 { padding: 0px; margin: 0px; font-weight: normal; font-style: italic; padding-bottom: 2px; margin-bottom: 0.3em; padding-top: 2px; margin-top: 1em; }
ul, ol { font-size:1em; margin: 0px; padding-top: 0px; padding-bottom: 0px; padding-left: 28px; padding-right: 8px; }
li { margin: 2px 0px 0px 0px; padding: 0px; }
a:active{outline: none;}
.hidden{ display:none; }
.resulterror, .resulterror * { color: #FF0000; }
.resultok, .resultok * { color: #009900; }
input, label { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; padding: 2px; margin: 4px; }
button { color: #000000; padding: 1px; margin: 0px; }
select { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; margin: 0px; }
input.tab { background-color: #DDDDDD; border: solid 3px #DDDDDD; color: #000000; font-size: 11px; width: auto; overflow: visible; padding: 0px; }
input.tabselected { background-color: #214C9A; border: solid 3px #214C9A; color: #FFFFFF; font-size: 11px; width: auto; overflow: visible; font-weight: bold; padding: 0px; }
#TabDiv { border-bottom: solid 6px #214C9A; margin-bottom: 10px; }
/* Contains the date picks in the Edit.aspx page */
#DatePickDiv { font-size: 11px; border: solid 1px #999999; background-color: #FFFFFF; padding: 2px; }
a.datepicklink { display: block; }
/* Small text */
p.small, small { font-size: 11px; }
/* Big text */
p.big, big { font-size: 15px; }
/* Description/legend for images */
p.imagedescription { font-size: 11px; font-style: italic; margin-top: 4px; }
/* General purpose links */
a, a:link, a:active { color: #C7180F; text-decoration: underline; }
a:hover { color: #E80C00; text-decoration: underline; }
a:visited { color: #660000; text-decoration: underline; }
/* Link to an external URL */
a.externallink { background-image: url(Images/ExternalLink.gif); background-position: right; background-repeat: no-repeat; padding-right: 14px; }
/* Link to an internal file */
a.internallink {}
/* Link to a Wiki page */
a.pagelink {}
/* Link to unknown/inexistent pages */
a.unknownlink, a.unknownlink:link, a.unknownlink:active { color: #990000; text-decoration: none; }
a.unknownlink:hover { color: #D9671E; text-decoration: underline; }
/* Email Link */
a.emaillink {}
h1.pagetitle { font-size: 22px; margin-bottom: 2px; }
a.editsectionlink { float: right; font-size: 11px; margin: 4px 0px 0px 0px; }
/* Class for general purpose images (contained in Wiki pages) */
img.image { border: solid 1px #F5F5F5; }
/* Class of the formatting Buttons in Edit.aspx */
img.format { border: solid 1px; padding: 2px; }
/* Div used for clearing floats */
.clear { clear: both; height:1px; line-height:1px; font-size:1px; overflow: hidden;}
/* Div containing images alighed to the left */
div.imageleft { border: 1px solid #E0DAC8; background-color: #FFFFFF; padding: 4px; margin-left: 0px; margin-right: 8px; margin-top: 4px; margin-bottom: 4px; float: left; }
/* Div containing images alighed to the right */
div.imageright { border: 1px solid #E0DAC8; background-color: #FFFFFF; padding: 4px; margin-left: 8px; margin-right: 0px; margin-top: 4px; margin-bottom: 4px; float: right; }
/* Table containing images not aligned */
table.imageauto { border: 1px solid #E0DAC8; background-color: #FFFFFF; padding: 4px; margin: 4px 4px 4px 0px; }
/* Div acting like a box */
div.box { border: 1px solid #CCCCCC; background-color: #F9F9F9; display: block; padding: 7px; margin: 0em 0em 1em 0em; }
div.groupbox { border: 1px solid #CCCCCC; background-color: #FCF9F0; padding: 7px; margin: 0em 0em 1em 0em; }
div.warning { border: solid 1px #FFCF10; background-color: #FEF693; display: inline-block; padding: 7px; margin: 0em 0em 1em 0em; }
code, pre { font-family: Consolas, Courier New, Monospace; color: #000000; padding: 0px; margin: 0px; }
pre { border: dashed 1px #999999; background-color: #FFFFF0; margin: 0px 0px 10px 0px; padding: 7px; overflow: auto; font-size: small; }
/* Contains the Header */
#HeaderDiv { width:100%; float:left; background: #F2EDD9 url(Images/bg_body.gif) repeat-x; }
#AuthBar{ width: 780px; margin:0 auto; height:13px; padding:4px 0 4px 0; }
#AuthBar ul{ list-style: none; float:right; padding:0; margin:0;}
#AuthBar li{ display: block; padding:0; margin:0 0 0 9px; float:left; background-repeat: no-repeat; }
#AuthBar a:hover{ font-weight: bold; }
#TopBarBackground{ position:absolute; left:0; top:21px; width:50%; height:51px; background-color: #F2EDD9; }
#TopBar{ position:relative; width: 780px; margin:0 auto; height:51px; }
#Logo{ position:absolute; top:0; left: 0; width:390px; height:51px; background-image: url(Images/bg_logo.gif); background-color: #FBF7EC; background-position: left; background-repeat: no-repeat; }
#Logo h1{ padding: 0 157px 0 0; display:block; width:223px; height:51px; overflow: hidden; background: url(Images/logo.gif) no-repeat; margin: 0; }
#TopControls{ position:absolute; top: 0; right: 0; width: 390px; height: 51px; margin:0 auto; background-color: #FBF7EC; }
#LogoLine{ }
.logo{ position:absolute; left:0; top:21px; width:50%; height:51px; background-image: url(Images/bg_logo.png); background-color: #F2EDD9; background-position: left; background-repeat: no-repeat; }
.logo a{ display:block; width:223px; height:51px; }
.logo h1{ padding: 0 157px 0 0; float:right; display:block; width:223px; height:51px; overflow: hidden; background: url(Images/logo.gif) no-repeat; margin: 0; }
#LogoBar{ width: 780px; height: 51px; margin:0 auto; }
#LogoBar div.btn{ font-size:1.1em; font-weight:bold; padding: 0 9px 0 0; float: right; margin: 13px 0 0 0px; display: block; height: 30px; background-image: url(Images/bt_btntop_right.gif); background-position: right; background-repeat: no-repeat; background-color: #FCBC5D; font-family: Arial, Helvetica, sans-serif; }
#LogoBar div.btn a{ color: #A11603; text-decoration: none; padding-top:5px; display:block; height:18px; overflow: hidden; float: left; }
#LogoBar div.btn a:hover{ color: #E81D00; text-decoration: none; cursor: pointer; }
#LogoBar div.btn span{ float:left; display:block; height:30px; padding:0 0 0 27px; background-image: url(Images/bt_btntop_left.gif); background-position: left; background-repeat: no-repeat; }
.searchbox{position:relative; float: right; width:139px; height:30px; margin:13px 0 0 5px; background-image: url(Images/bg_searchbox.gif); background-repeat: no-repeat; }
#TxtSearchBox { font-size: 11px; width: 100px; margin:5px 0 0 22px; padding: 1px 3px 1px 3px; height: 12px; background:none; border: none; color: #912711; }
#TitleBar{ margin:0 auto; width:780px; height: 60px; overflow: hidden; background: #AB1B11; }
#TitleBar h2{ height:104px; overflow: hidden; display: block; margin:0 auto; padding: 18px 0 0 0; color: #E6AA94; font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 1.8em; font-weight:normal; }
#NavBar{ text-align:center; width: 780px; height:30px; margin:0 auto; }
#NavBar ul{ list-style: none; padding:0; margin:0; font-size:1.3em; }
#NavBar li{ height: 30px; float: left; padding: 0; margin: 0 0 0 1px; background: #E25333 url(Images/bg_nav.gif) repeat-x bottom; }
#NavBar li.active{ background: #FAFAFA url(Images/bg_nav_active.gif) repeat-x; }
#NavBar li.home{ padding:0 3px; }
#NavBar a{ color: white; margin: 0; text-decoration: none; display: block; padding: 6px 0 0 0; width: 85px; text-align: center; font-weight: bold; font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; }
#NavBar li.active a{ color: #AB0B00; }
#NavBar a:hover{ position: relative; top: -1px; }
#SubNavBar{ text-align:center; width: 780px; height:20px; margin: 0 auto 1px auto;}
#SubNavBar ul{ list-style: none; padding: 0 0 0 0px; margin: 0; font-size:1.3em; }
#SubNavBar li{ height: 20px; float: left; padding: 0; margin: 0 0 0 1px; background: #E25333 url(Images/bg_nav.gif) repeat-x bottom; }
#SubNavBar li.active{ background: #FAFAFA url(Images/bg_nav_active.gif) repeat-x; }
#SubNavBar li.home{ padding:0 3px; }
#SubNavBar a{ color: white; margin: 0; text-decoration: none; display: block; padding: 1px 6px 0 6px; width: auto; text-align: center; font-weight: bold; font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; }
#SubNavBar li.active a{ color: #AB0B00; }
#SubNavBar a:hover{ position: relative; top: -1px; }
/* Contains the SidebarDiv and the MainDiv */
#ContentWrapper{ width:100%; padding: 0 0 50px 0; float:left; background: White url(Images/bg_content.gif) repeat-x; }
#ContainerDiv { width: 780px; padding: 0; margin: 0 auto; }
/* Contains the Sidebar */
#SidebarDiv { display:none; }
#SidebarContentDiv{}
#Side{ float:right; font-size:1.2em; width: 180px; margin: 0; padding: 36px 0 0px 40px; background: url(Images/bg_SidebarDiv.gif) no-repeat 0 6px; /* min-height: 460px; */ position: relative; }
#Side h3{ font-size: 1.38em; text-transform: uppercase; color: #727272; font-family: "Trebuchet MS"; font-weight: bold; }
#GetStarted ul{ list-style: none; padding: 0; margin: 1em 0 1.5em 0; font-size: 1.1em; }
#GetStarted li{ display: block; margin:0 0 8px 0; background-repeat: no-repeat; padding:0;}
#GetStarted li a{ display: block; height: 30px; width: 128px; padding: 9px 0 0 52px; background: url(Images/start_tour.gif); overflow: hidden; color: #545454; text-decoration: none; }
#GetStarted li.tour a{ background: url(Images/start_tour.gif); }
#GetStarted li.try a{ background: url(Images/start_trylokad.gif); }
#GetStarted li.download a{ background: url(Images/start_download.gif); }
#GetStarted li.save a{ background: url(Images/start_save.gif); }
#GetStarted li.ecommerce a{ background: url(Images/industry_ecommerce.gif); }
#GetStarted li.retail a{ background: url(Images/industry_retail.gif); }
#GetStarted li.manufacturing a{ background: url(Images/industry_manufacturing.gif); }
#GetStarted li.call a{ background: url(Images/industry_call.gif); }
#GetStarted li a:hover{ text-decoration: underline; background-position: 0 -39px; }
#GetStarted li.active a{ color: #cc0000; background-position: 0 -78px; }
#GetStarted li.active a:hover{ background-position: 0 -78px; }
#Side .fromprice{ width:180px; margin: 0 0 1.5em 0; padding:0; height: 59px; background: #A5C7EB url(Images/from_price.gif); }
#Side .fromprice a{ display:block; text-decoration:none; width:110px; padding:21px 60px 0 10px; height: 25px; color: White; font-size: 1.2em; font-weight:bold; overflow: hidden; }
#Side .fromprice a:hover{ text-decoration: underline; }
#Side .news ul{ list-style:none; font-weight: bold; font-size:0.9em; color: #DE4338; margin:0.8em 0 20px 0; padding:0; font-family: Arial, Helvetica, sans-serif; }
#Side .news li{ margin:0 0 10px 0; }
#Side .news a{ font-style: normal; font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; line-height:1.4em; font-size: 1.2em; font-weight: normal; text-decoration: none; color: #515151; }
#Side .news a:hover{ text-decoration: underline; }
/* Contains the contents of a Page */
#MainDiv { float:left; width:780px; margin: 0; padding:0;}
#Text { float:left; width:780px; line-height:1.4em; margin: 0; padding:40px 0 0 0; font-size:1.4em; }
#Text .large{ font-size: 1.17em; color: #777777; }
#Text .frontlist{ margin:10px 0 15px 0; }
#Text .frontlist ul{ list-style:none; margin:0; padding:3px 0 0 20px; }
#Text .frontlist li{ padding:0 0 0 30px; margin:0 0 6px 0; background-image: url(Images/ico_frontlist.gif); background-position: left; background-repeat: no-repeat;}
ul.listorange{ padding: 0 0 0 18px; }
ul.listorange li{ list-style: url(Images/bullet_orange.gif); }
ul.listred li{ list-style: url(Images/bullet_red.gif); }
ul.listred li.empty{ list-style: none none; }
/* 2-columns 'table' */
.col2{ float:left; width:100%; list-style: none; margin: 0; padding: 0; background: url(Images/bg_col2.gif) repeat-y 255px 0; }
.col2 li.left{ list-style: none; margin: 0; padding: 0; width: 250px; padding: 0 15px 0 0; }
.col2 li.right{ list-style: none; margin: 0; padding: 0; width: 250px; padding: 0 0 0 15px; }
.col2 li li{ list-style: disc; }
/* decorated list */
ul.tick{ margin: 0; padding: 0; }
ul.tick li{ list-style: none; margin: 0 0 5px 0; padding: 0 0 0 20px; background: url(Images/bullet_tick.gif) no-repeat 0 4px; }
/* LSSC page */
h1.lssc{ background: url(Images/icon_ssc.gif) no-repeat left; line-height: 33px; padding: 0 0 0 40px; }
/* screenshots */
.screenshot{ float: left; margin: 0 60px 15px 0; padding: 2px; border: 1px solid #e1e1e1; position: relative; }
.screenshot img{ float: left; width:131px; }
.screenshot a{ position: absolute; text-indent: -5000px; bottom: 0; left: 0; width: 135px; height: 95px; background: url(Images/icon_zoom.gif) no-repeat bottom right; }
.rightscreenshot{ margin: 0 0 15px 0; }
/* Contains the Page Header (title, last modify, etc.) */
#PageTop{ display: none; }
#PageHeaderDiv { display:none;}
#PageInternalHeaderDiv { }
#PageInternalFooterDiv { }
/* Contains the Footer */
#FooterWrapper{ width:100%; margin: 0; padding: 18px 0 0px 0; border-top: 13px solid #E6E6E6; background-color: #2B2B2B; color: #D5D5D5; clear: both; position: relative; }
#Footer{ width:780px; margin:0 auto; padding:0; line-height:1.6em; font-size:1.1em; font-family: "MS Sans Serif", Geneva, sans-serif; }
#Footer .left{ float: left; width: 530px; padding-bottom:30px; }
#Footer .right{ float: right; width: 225px; text-align: right; }
#Footer .right a{ text-decoration: none; color:#dddddd; }
#Footer .left a{ color: #8A8A8A; text-decoration: none;}
#Footer a:hover{ color:#EEEEEE; border-bottom:1px solid #CCCCCC; }
#Footer .left ul{ list-style: none; padding: 0; margin: 0; }
#Footer .left li{ display:block; float:left; border-left: 1px solid #222222; border-right: 1px solid #414141; padding: 0 14px 0 14px; }
#Footer .left li.first{ border-left:none; padding-left:0;}
#Footer .left li.last{ border-right:none; padding-right:0; }
#Footer .admin{ float: right; width: 225px; text-align: right; color: #666666; margin: 0; padding: 0; }
#Footer .admin a{ text-decoration: none; color:#666666; }
#AjaxLoading { display: none; margin-top: 5px; margin-right: -7px; }
/* Contains the link to the page editing form (Edit.aspx) and history */
#EditHistoryLinkDiv { float: right; font-size: 11px; padding-top: 4px; padding-bottom: 4px; }
#EditLink, #HistoryLink, #ViewCodeLink, #DiscussLink, #BackLink, #PostReplyLink { margin-left: 4px; padding: 2px; border: solid 1px #999999; display: none; }
#EditLink:hover, #HistoryLink:hover, #ViewCodeLink:hover, #DiscussLink:hover, #BackLink:hover, #PostReplyLink:hover { border: solid 1px #214C9A; text-decoration: none; background-color: #FFFFEE; }
/* Class of the P containing the Edit Link */
p.editlink { font-size: 11px; }
.editsectionlink{ font-size: 8px; /* display:none; */ }
/* Shown when a page is Locked */
#PageLockedDiv { float: left; width: 12px; height: 12px; margin-right: 4px; background-image: url(Images/Lock.png); background-repeat: no-repeat; background-position: center; text-indent: -3000px; position: relative; }
/* Shown when a page is Public */
#PagePublicDiv { float: left; width: 12px; height: 12px; margin-right: 4px; background-image: url(Images/Public.png); background-repeat: no-repeat; background-position: center; text-indent: -3000px; position: relative; }
#PageInfoDiv { font-size: 11px; }
#BreadcrumbsDiv { font-size: 11px; margin-top: 2px; padding-bottom: 1px; border-bottom: solid 1px #F0F0F0; border-top: solid 1px #F0F0F0; /*background-color: #FFFEDF;*/ overflow: hidden; }
/* Contains the link to the Page RSS */
#RssLinkDiv { float: right; position: relative; }
/* The link to the Page RSS */
#RssLink { background-image: url(Images/RSS.png); background-repeat: no-repeat; text-indent: -2500px; display: block; height: 13px; width: 24px; }
#PrintLinkDiv { float: right; position: relative; }
#PrintLink { background-image: url(Images/Print.png); background-repeat: no-repeat; text-indent: -2500px; display: block; margin-left: 4px; height: 16px; width: 16px; }
/* Contains the Page Content */
#PageContentDiv { margin: 0; }
/* Contains the page preview in the Edit.aspx page */
#PreviewDiv {}
/* Contains the special tags in the Edit.aspx page */
#SpecialTagsDiv { font-size: 11px; border: solid 1px #999999; background-color: #FFFFFF; padding: 0px; }
a.specialtaglink { display: block; }
#PageListDiv { font-size: 11px; border: solid 1px #999999; background-color: #FFFFFF; padding: 0px; }
#FileListDiv { font-size: 11px; border: solid 1px #999999; background-color: #FFFFFF; padding: 4px; }
a.pagelistlink { display: block; }
#SnippetListDiv { font-size: 11px; border: solid 1px #999999; background-color: #FFFFFF; padding: 0px; }
a.snippetlistlink { display: block; }
/* Contains the anchors in the Edit.aspx page */
#AnchorsDiv { font-size: 11px; border: solid 1px #999999; background-color: #FFFFFF; padding: 0px; }
a.anchorlink { display: block; }
/* Contains the anchors in the Edit.aspx page */
#ImagesDiv { font-size: 11px; border: solid 1px #999999; background-color: #FFFFFF; padding: 0px; }
a.imagelink { display: block; }
#SpecialTagsDiv *, #AnchorsDiv *, #ImagesDiv *, #PageListDiv *, #SnippetListDiv * { padding: 2px; }
#SpecialTagsDiv a:hover, #AnchorsDiv a:hover, #ImagesDiv a:hover, #PageListDiv a:hover, #SnippetListDiv a:hover { color: #FFFFFF; background-color: #214C9A; text-decoration: none; }
/* Contains the Special characters in the Edit.aspx page */
#SpecialCharsDiv { margin-top: 8px; border: solid 1px #888888; padding: 4px; }
.queueNameWithMessages { color: #AB0B00; }
.queueMessageNumberWithMessages { font-weight: bold; font-size:1.5em; color: #AB0B00; }
#FormatUl { margin: 0px; padding: 0px; }
#FormatUl li { display: inline; list-style-image: none; margin: 0px; padding: 0px; }
/* Formatting Button in Edit.aspx */
a.formatlink { background-position: center; background-repeat: no-repeat; width: 20px; height: 20px; border: solid 1px #214C9A; text-indent: -2000px; margin-right: 2px; float: left; }
/* Formatting Button in Edit.aspx */
a.formatlink:hover { text-decoration: none; border: solid 1px #D9671E; }
#BoldLink { background-image: url(Images/Bold.png); }
#ItalicLink { background-image: url(Images/Italic.png); }
#UnderlineLink { background-image: url(Images/Underline.png); }
#StrikeLink { background-image: url(Images/Strike.png); }
#H1Link { background-image: url(Images/H1.png); }
#H2Link { background-image: url(Images/H2.png); }
#H3Link { background-image: url(Images/H3.png); }
#H4Link { background-image: url(Images/H4.png); }
#SubLink { background-image: url(Images/Sub.png); }
#SupLink { background-image: url(Images/Sup.png); }
#PageListLink { background-image: url(Images/PageLink.png); }
#FileLink { background-image: url(Images/File.png); }
#LinkLink { background-image: url(Images/Link.png); }
#ImageLink { background-image: url(Images/Image.png); }
#AnchorLink { background-image: url(Images/Anchor.png); }
#CodeLink { background-image: url(Images/Code.png); }
#PreLink { background-image: url(Images/Pre.png); }
#BoxLink { background-image: url(Images/Box.png); }
#BrLink { background-image: url(Images/BR.png); }
#SnippetListLink { background-image: url(Images/Snippet.png); }
#SpecialTagsLink { background-image: url(Images/SpecialTags.png); }
#NoWikiLink { background-image: url(Images/NoWiki.png); }
#CommentLink { background-image: url(Images/Comment.png); }
#EscapeLink { background-image: url(Images/Escape.png); }
#PageListTable { width: 90%; margin: 0px 10px 0px 10px; }
#PageListHeader { background-color: #DDDDDD; }
.pagelistcelleven { border-bottom: solid 1px #CCCCCC; }
.pagelistcellodd { border-bottom: solid 1px #CCCCCC; background-color: #F4F4F4; }
#PageTreeP { margin: 0px 0px 0px 10px; padding: 0px 0px 0px 6px; border-left: 4px solid #CCCCCC; }
#FileListTable { width: 98%; margin: 0px; }
#FileListHeader { background-color: #DDDDDD; }
.filelistcelleven { border-bottom: solid 1px #CCCCCC; }
.filelistcellodd { border-bottom: solid 1px #CCCCCC; background-color: #F4F4F4; }
#RevisionListTable { width: 98%; margin: 0px; }
#RevisionListHeader { background-color: #DDDDDD; }
.revisionlistcelleven { border-bottom: solid 1px #CCCCCC; }
.revisionlistcellodd { border-bottom: solid 1px #CCCCCC; background-color: #F4F4F4; }
#PreviewDivExternal { }
#PreviewDiv { padding: 10px; border: solid 4px #CCCCCC; }
blockquote { border-left: solid 8px #DDDDDD; margin-left: 16px; padding: 0px 0px 2px 6px; }
div.messagecontainer { margin: 0px 0px 0px 16px; }
div.rootmessagecontainer { border-top: solid 4px #214C9A; }
div.messageheader { font-size: 10px; background-color: #F0F0F0; padding: 2px; }
span.messagesubject { font-weight: bold; font-size: 12px;}
div.messagebody { border-bottom: solid 1px #F0F0F0; border-left: solid 1px #F0F0F0; border-right: solid 1px #F0F0F0; margin: 0px 0px 6px 0px; padding: 4px;}
div.reply { float: right; margin: 6px 10px 0px 0px; font-size: 11px; font-weight: bold;}
a.reply { background-image: url(Images/MessageReply.png); background-repeat: no-repeat; background-position: left center; padding: 0px 0px 0px 12px;}
a.edit { background-image: url(Images/MessageEdit.png); background-repeat: no-repeat; background-position: left center; padding: 0px 0px 0px 13px; margin-left: 16px; }
a.delete { background-image: url(Images/MessageDelete.png); background-repeat: no-repeat; background-position: left center; padding: 0px 0px 0px 10px; margin-left: 16px; }
#ConcurrentEditingDiv { padding: 6px; background-color: #FEF693; border: solid 1px #FFCF10; }
span.signature { font-style: italic; }
#TocContainer { border: solid 1px #CCCCCC; display: table-cell; padding: 7px; border-collapse: collapse; background-color: #F9F9F9; }
#AttachmentsDiv { margin-top: 6px; padding: 4px; border: solid 1px #559955; background-color: #D6EED2; }
a.attachment { padding-left: 14px; background-image: url(Images/Attachment.png); background-repeat: no-repeat; background-position: left center; }
#RedirectionInfoDiv { font-size: 11px; padding-left: 10px; padding-top: 4px; color: #999999; }
#RedirectionDiv { margin-bottom: 16px; padding-left: 24px; margin-left: 10px; font-size: 14px; background-image: url(Images/Redirect.png); background-repeat: no-repeat; background-position: left center; }
/* JsFileTree control begin */
div.subtreediv { margin: 0px 0px 0px 10px; }
a.subdirlink { background-image: url(../../Images/Dir.png); background-repeat: no-repeat; background-position: left center; padding: 0px 0px 0px 18px; }
a.filelink { background-image: url(../../Images/File.png); background-repeat: no-repeat; background-position: left center; padding: 0px 0px 0px 18px; }
/* JsFileTree control end */
/* JsImageBrowser control begin */
#ImageBrowserDiv { background-color: #FFFFFF; border: solid 1px #999999; width: 616px; }
#MainContainerDiv { overflow: auto; height: 286px; }
div.container { float: left; width: 96px; height: 126px; background-color: #FFFFFF; margin: 4px; }
#UpLevelLink, #UpLevelLink:hover { display: block; width: 96px; height: 96px; vertical-align: bottom; text-align: center; text-decoration: none; }
a.dirlink, a.dirlink:hover { display: block; width: 96px; height: 96px; vertical-align: bottom; text-align: center; text-decoration: none; }
a.itemlink, a.itemlink:hover { display: block; width: 96px; height: 116px; vertical-align: bottom; text-align: center; text-decoration: none; }
span.itemtext { color: #000000; background-color: #FFFFFF; padding: 0px; width: 96px; height: 96px; vertical-align: bottom; font-size: 10px; }
#ImagePreviewDiv { float: right; width: 256px; height: 268px; border: solid 1px #CCCCCC; margin: 4px; padding: 4px; text-align: center; vertical-align: middle; background-color: #FFFFFF; }
#PreviewImg { height: 248px; vertical-align: middle; }
img.thumb { border: solid 1px #CCCCCC; }
#ImageDescriptionSpan { font-size: 11px; font-style: italic; }
/* JsImageBrowser control end */
.table
{
border: 1px solid #FCD396;
border-spacing: 0px;
border-collapse: collapse;
empty-cells: show;
}
.table th{ border-style: solid; border-width: 0 0 1px 1px; border-color: #FCE7C5; padding: 4px 10px 4px 4px; margin: 0; background-color: #FCF0DA; text-align: left; vertical-align: top; }
.table td{ border-style: solid; border-width: 0 0 1px 1px; border-color: #FCE7C5; padding: 4px 10px 4px 4px; margin: 0; background-color: #FCF9F0; text-align: left; vertical-align: top; }
.table pre { width: 600px; }
.tableseparator td{ background-color: #FFFFFF; border-width: 0 0 1px 0; }
.loadMore { border: solid 1px #FFCF10; background-color: #FEF693; display: inline-block; padding: 0.2em 0em 0.2em 0em; margin: 1em 0em 1em 0em; text-align: center; width: 780px; cursor: pointer; }
.updatedText{ text-align: right; font-style: italic; font-size: 0.8em; padding: 2em 0 0 0; }
/*.table th{ background-color: #FCF9F0; color: #312104; }
.table td{ background-color: #FCF9F0; }*/
.small { font-size: 0.85em; }
/* NEW FRONTPAGE */
.linelist{ padding:0; margin:7px 0 36px 0; float:left; width:100%; list-style:none; }
.linelist li{ float: left; padding: 0 30px 0 30px; width:125px; background-image: url(Images/ico_frontlist.gif); background-position: left top; background-repeat: no-repeat; color: #535353; }
#Side .btndownload{ cursor: pointer; position:relative; width: 180px; margin: 0 0 1.5em 0; height: 59px; background: #A5C7EB url(Images/bg_download.gif); }
#Side .btndownload a{ padding: 16px 22px 0 0; height: 43px; width:158px; display:block; text-align: right; color: white; letter-spacing:2px; font: bold 1.2em Arial, Helvetica, sans-serif; text-decoration: none; }
#Side .btndownload a:hover{ text-decoration: underline;}
#Side .btndownload span{ position:absolute; right:22px; top: 29px; color:white; display: block; font: bold 10px Arial, Helvetica, sans-serif; }
#Text .right{ float:right; }
#Text .left{ float:left; }
#Text img.left{ margin: 5px 15px 5px 0; }
#Text img.right{ margin: 5px 0 5px 15px; }
.textjustify{ text-align: justify; }
.textleft{ text-align: left; }
.textright{ text-align: right; }
.textcenter{ text-align: center; }
#Text .actions{ list-style:none; padding:0; margin:10px 0 15px 0; font-size:1.4em; }
#Text .actions li{ display:inline; }
#Text .actions li.arrow{ padding: 0 0 0 10px; margin: 0 0 0 6px; background: url(Images/ico_arrow.gif) no-repeat left; }
/* ------------------------------------------------- */
/* Local Overrides specific to the Lokad application */
/* Bigger Logo */
.logo a{ width:332px; }
.logo h1{ padding: 0 48px 0 0; width:332px; overflow: hidden; background:url(Images/bg_logo.png) no-repeat; }
.logo h1.Test { background:url(Images/logo_test.gif) no-repeat;}
#Visual { background-image: url(Images/bg_slogan.gif); }
/* Help styles */
#HelpHeader { width:100%; float:left; border-bottom: solid #F2EDD9 2px; background-color:White;}
#HelpLogo { background-image: url(Images/lokad-help.gif);background-repeat: no-repeat; height:51px; }
#HelpWrapper { line-height:1.4em; margin: 0; font-size:1.4em; background-color:White; padding-left:10px;padding-right:10px; padding-top:15px;}
#HelpWrapper h1 {padding-bottom: 2px; margin-bottom: 8px;}
#HelpWrapper h2 { margin-top: 20px;}
.CloseHelp {float: right; }
/* Main style overrides */
#TopControls div.btn { margin-left:5px;}
#Text p { padding: 0 0 1em 0; width:750px}
div.box { width:530px; }
div.warning { max-width:530px; }
span.warning { color: #ff0000; }
.statusenabled { font-weight: bold; }
.statusdisabled { color: #FF0000; }
/* Used for Lokad.skin */
.DefaultGrid
{
border-collapse: collapse;
border: solid 1px #BBBBBB;
}
.Centered
{
margin: 0em auto 1em auto;
}
fieldset { border:0; margin: 0em 4em 1em 4em; height: 2.5em;}
select {margin-right: 1em; float: left;}
.icon-GoodBad { display: inline-block; width: 16px; height: 16px; background-image: url(Icons/GoodBad16.png); background-repeat: no-repeat; vertical-align: middle; margin-right: 0.5em; }
.icon-GoodBad-Good { background-position: 0px 0px; }
.icon-GoodBad-Bad { background-position: -16px 0px; }
.icon-GoodBad-VeryBad { background-position: -32px 0px; }
.icon-LogLevels { display: block; width: 16px; height: 16px; background-image: url(Icons/LogLevels16.png); background-repeat: no-repeat; float: left; vertical-align: middle; margin-right: 0.5em; }
.icon-LogLevels-Debug { background-position: 0px 0px; }
.icon-LogLevels-Info { background-position: -16px 0px; }
.icon-LogLevels-Warn { background-position: -32px 0px; }
.icon-LogLevels-Error { background-position: -48px 0px; }
.icon-LogLevels-Fatal { background-position: -64px 0px; }
.icon-OkCancel { display: block; width: 16px; height: 16px; background-image: url(Icons/OkCancel16.png); background-repeat: no-repeat; float: left; vertical-align: middle; margin-right: 0.5em; }
.icon-OkCancel-Ok { background-position: 0px 0px; }
.icon-OkCancel-Cancel { background-position: -16px 0px; }
.icon-PlusMinus { display: block; width: 16px; height: 16px; background-image: url(Icons/PlusMinus16.png); background-repeat: no-repeat; float: left; vertical-align: middle; margin-right: 0.5em; }
.icon-PlusMinus-Plus { background-position: 0px 0px; }
.icon-PlusMinus-Minus { background-position: -16px 0px; }
.icon-StartStop { display: block; width: 16px; height: 16px; background-image: url(Icons/StartStop16.png); background-repeat: no-repeat; float: left; vertical-align: middle; margin-right: 0.5em; }
.icon-StartStop-Start { background-position: 0px 0px; }
.icon-StartStop-Stop { background-position: -16px 0px; }
.icon-StartStop-Pause { background-position: -32px 0px; }
.icon-StartStop-Standby { background-position: -48px 0px; }
.icon-button { cursor: pointer; }
.icon-loading { background-image: url(Icons/Loading16.png); background-position: 0px 0px; }
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Content/Lokad.css
|
CSS
|
bsd
| 31,857
|
/*----------------------------------------------------------
The base color for this template is #5c87b2. If you'd like
to use a different color start by replacing all instances of
#5c87b2 with your new color.
----------------------------------------------------------*/
body
{
background-color: #5c87b2;
font-size: 75%;
font-family: Verdana, Tahoma, Arial, "Helvetica Neue", Helvetica, Sans-Serif;
margin: 0;
padding: 0;
color: #696969;
}
a:link
{
color: #034af3;
text-decoration: underline;
}
a:visited
{
color: #505abc;
}
a:hover
{
color: #1d60ff;
text-decoration: none;
}
a:active
{
color: #12eb87;
}
p, ul
{
margin-bottom: 20px;
line-height: 1.6em;
}
/* HEADINGS
----------------------------------------------------------*/
h1, h2, h3, h4, h5, h6
{
font-size: 1.5em;
color: #000;
}
h1
{
font-size: 2em;
padding-bottom: 0;
margin-bottom: 0;
}
h2
{
padding: 0 0 10px 0;
}
h3
{
font-size: 1.2em;
}
h4
{
font-size: 1.1em;
}
h5, h6
{
font-size: 1em;
}
/* this rule styles <h2> tags that are the
first child of the left and right table columns */
.rightColumn > h1, .rightColumn > h2, .leftColumn > h1, .leftColumn > h2
{
margin-top: 0;
}
/* PRIMARY LAYOUT ELEMENTS
----------------------------------------------------------*/
/* you can specify a greater or lesser percentage for the
page width. Or, you can specify an exact pixel width. */
.page
{
width: 90%;
margin-left: auto;
margin-right: auto;
}
#header
{
position: relative;
margin-bottom: 0px;
color: #000;
padding: 0;
}
#header h1
{
font-weight: bold;
padding: 5px 0;
margin: 0;
color: #fff;
border: none;
line-height: 2em;
font-size: 32px !important;
}
#main
{
padding: 30px 30px 15px 30px;
background-color: #fff;
margin-bottom: 30px;
_height: 1px; /* only IE6 applies CSS properties starting with an underscore */
}
#footer
{
color: #999;
padding: 10px 0;
text-align: center;
line-height: normal;
margin: 0;
font-size: .9em;
}
/* TAB MENU
----------------------------------------------------------*/
ul#menu
{
border-bottom: 1px #5C87B2 solid;
padding: 0 0 2px;
position: relative;
margin: 0;
text-align: right;
}
ul#menu li
{
display: inline;
list-style: none;
}
ul#menu li#greeting
{
padding: 10px 20px;
font-weight: bold;
text-decoration: none;
line-height: 2.8em;
color: #fff;
}
ul#menu li a
{
padding: 10px 20px;
font-weight: bold;
text-decoration: none;
line-height: 2.8em;
background-color: #e8eef4;
color: #034af3;
}
ul#menu li a:hover
{
background-color: #fff;
text-decoration: none;
}
ul#menu li a:active
{
background-color: #a6e2a6;
text-decoration: none;
}
ul#menu li.selected a
{
background-color: #fff;
color: #000;
}
/* FORM LAYOUT ELEMENTS
----------------------------------------------------------*/
fieldset
{
border:1px solid #ddd;
padding:0 1.4em 1.4em 1.4em;
margin:0 0 1.5em 0;
}
legend
{
font-size:1.2em;
font-weight: bold;
}
textarea
{
min-height: 75px;
}
input[type="text"]
{
width: 200px;
border: 1px solid #CCC;
}
input[type="password"]
{
width: 200px;
border: 1px solid #CCC;
}
/* TABLE
----------------------------------------------------------*/
table
{
border: solid 1px #e8eef4;
border-collapse: collapse;
}
table td
{
padding: 5px;
border: solid 1px #e8eef4;
}
table th
{
padding: 6px 5px;
text-align: left;
background-color: #e8eef4;
border: solid 1px #e8eef4;
}
/* MISC
----------------------------------------------------------*/
.clear
{
clear: both;
}
.error
{
color:Red;
}
#menucontainer
{
margin-top:40px;
}
div#title
{
display:block;
float:left;
text-align:left;
}
#logindisplay
{
font-size:1.1em;
display:block;
text-align:right;
margin:10px;
color:White;
}
#logindisplay a:link
{
color: white;
text-decoration: underline;
}
#logindisplay a:visited
{
color: white;
text-decoration: underline;
}
#logindisplay a:hover
{
color: white;
text-decoration: none;
}
/* Styles for validation helpers
-----------------------------------------------------------*/
.field-validation-error
{
color: #ff0000;
}
.field-validation-valid
{
display: none;
}
.input-validation-error
{
border: 1px solid #ff0000;
background-color: #ffeeee;
}
.validation-summary-errors
{
font-weight: bold;
color: #ff0000;
}
.validation-summary-valid
{
display: none;
}
/* Styles for editor and display helpers
----------------------------------------------------------*/
.display-label,
.editor-label
{
margin: 1em 0 0 0;
}
.display-field,
.editor-field
{
margin:0.5em 0 0 0;
}
.text-box
{
width: 30em;
}
.text-box.multi-line
{
height: 6.5em;
}
.tri-state
{
width: 6em;
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Content/Site.css
|
CSS
|
bsd
| 5,324
|
/*
* --------------------------------------------------------------------
* jQuery-Plugin - selectToUISlider - creates a UI slider component from a select element(s)
* by Scott Jehl, scott@filamentgroup.com
* http://www.filamentgroup.com
* reference article: http://www.filamentgroup.com/lab/update_jquery_ui_16_slider_from_a_select_element/
* demo page: http://www.filamentgroup.com/examples/slider_v2/index.html
*
* Copyright (c) 2008 Filament Group, Inc
* Dual licensed under the MIT (filamentgroup.com/examples/mit-license.txt) and GPL (filamentgroup.com/examples/gpl-license.txt) licenses.
*
* Usage Notes: please refer to our article above for documentation
*
* --------------------------------------------------------------------
*/
jQuery.fn.selectToUISlider = function(settings){
var selects = jQuery(this);
//accessible slider options
var options = jQuery.extend({
labels: 3, //number of visible labels
tooltip: true, //show tooltips, boolean
tooltipSrc: 'text',//accepts 'value' as well
labelSrc: 'value',//accepts 'value' as well ,
sliderOptions: null
}, settings);
//handle ID attrs - selects each need IDs for handles to find them
var handleIds = (function(){
var tempArr = [];
selects.each(function(){
tempArr.push('handle_'+jQuery(this).attr('id'));
});
return tempArr;
})();
//array of all option elements in select element (ignores optgroups)
var selectOptions = (function(){
var opts = [];
selects.eq(0).find('option').each(function(){
opts.push({
value: jQuery(this).attr('value'),
text: jQuery(this).text()
});
});
return opts;
})();
//array of opt groups if present
var groups = (function(){
if(selects.eq(0).find('optgroup').size()>0){
var groupedData = [];
selects.eq(0).find('optgroup').each(function(i){
groupedData[i] = {};
groupedData[i].label = jQuery(this).attr('label');
groupedData[i].options = [];
jQuery(this).find('option').each(function(){
groupedData[i].options.push({text: jQuery(this).text(), value: jQuery(this).attr('value')});
});
});
return groupedData;
}
else return null;
})();
//check if obj is array
function isArray(obj) {
return obj.constructor == Array;
}
//return tooltip text from option index
function ttText(optIndex){
return (options.tooltipSrc == 'text') ? selectOptions[optIndex].text : selectOptions[optIndex].value;
}
//plugin-generated slider options (can be overridden)
var sliderOptions = {
step: 1,
min: 0,
orientation: 'horizontal',
max: selectOptions.length-1,
range: selects.length > 1,//multiple select elements = true
slide: function(e, ui) {//slide function
var thisHandle = jQuery(ui.handle);
//handle feedback
var textval = ttText(ui.value);
thisHandle
.attr('aria-valuetext', textval)
.attr('aria-valuenow', ui.value)
.find('.ui-slider-tooltip .ttContent')
.text( textval );
//control original select menu
var currSelect = jQuery('#' + thisHandle.attr('id').split('handle_')[1]);
currSelect.find('option').eq(ui.value).attr('selected', 'selected');
},
values: (function(){
var values = [];
selects.each(function(){
values.push( jQuery(this).get(0).selectedIndex );
});
return values;
})()
};
//slider options from settings
options.sliderOptions = (settings) ? jQuery.extend(sliderOptions, settings.sliderOptions) : sliderOptions;
//select element change event
selects.bind('change keyup click', function(){
var thisIndex = jQuery(this).get(0).selectedIndex;
var thisHandle = jQuery('#handle_'+ jQuery(this).attr('id'));
var handleIndex = thisHandle.data('handleNum');
thisHandle.parents('.ui-slider:eq(0)').slider("values", handleIndex, thisIndex);
});
//create slider component div
var sliderComponent = jQuery('<div></div>');
//CREATE HANDLES
selects.each(function(i){
var hidett = '';
//associate label for ARIA
var thisLabel = jQuery('label[for=' + jQuery(this).attr('id') +']');
//labelled by aria doesn't seem to work on slider handle. Using title attr as backup
var labelText = (thisLabel.size()>0) ? 'Slider control for '+ thisLabel.text()+'' : '';
var thisLabelId = thisLabel.attr('id') || thisLabel.attr('id', 'label_'+handleIds[i]).attr('id');
if( options.tooltip == false ){hidett = ' style="display: none;"';}
jQuery('<a '+
'href="#" tabindex="0" '+
'id="'+handleIds[i]+'" '+
'class="ui-slider-handle" '+
'role="slider" '+
'aria-labelledby="'+thisLabelId+'" '+
'aria-valuemin="'+options.sliderOptions.min+'" '+
'aria-valuemax="'+options.sliderOptions.max+'" '+
'aria-valuenow="'+options.sliderOptions.values[i]+'" '+
'aria-valuetext="'+ttText(options.sliderOptions.values[i])+'" '+
'><span class="screenReaderContext">' + labelText + '</span>' +
'<span class="ui-slider-tooltip ui-widget-content ui-corner-all"'+ hidett +'><span class="ttContent"></span>'+
'<span class="ui-tooltip-pointer-down ui-widget-content"><span class="ui-tooltip-pointer-down-inner"></span></span>'+
'</span></a>')
.data('handleNum',i)
.appendTo(sliderComponent);
});
//CREATE SCALE AND TICS
//write dl if there are optgroups
if(groups) {
var inc = 0;
var scale = sliderComponent.append('<dl class="ui-slider-scale ui-helper-reset" role="presentation"></dl>').find('.ui-slider-scale:eq(0)');
jQuery(groups).each(function(h){
scale.append('<dt style="width: ' + (100 / groups.length).toFixed(2) + '%' + '; left:' + (h / (groups.length - 1) * 100).toFixed(2) + '%' + '"><span>' + this.label + '</span></dt>'); //class name becomes camelCased label
var groupOpts = this.options;
jQuery(this.options).each(function(i){
var style = (inc == selectOptions.length-1 || inc == 0) ? 'style="display: none;"' : '' ;
var labelText = (options.labelSrc == 'text') ? groupOpts[i].text : groupOpts[i].value;
scale.append('<dd style="left:' + leftVal(inc) + '"><span class="ui-slider-label">' + labelText + '</span><span class="ui-slider-tic ui-widget-content"' + style + '></span></dd>');
inc++;
});
});
}
//write ol
else {
var scale = sliderComponent.append('<ol class="ui-slider-scale ui-helper-reset" role="presentation"></ol>').find('.ui-slider-scale:eq(0)');
jQuery(selectOptions).each(function(i){
var style = (i == selectOptions.length-1 || i == 0) ? 'style="display: none;"' : '' ;
var labelText = (options.labelSrc == 'text') ? this.text : this.value;
scale.append('<li style="left:' + leftVal(i) + '"><span class="ui-slider-label"><img src="/Content/Images/' + labelText + '16.png"/></span><span class="ui-slider-tic ui-widget-content"' + style + '></span></li>');
});
}
function leftVal(i){
return (i/(selectOptions.length-1) * 100).toFixed(2) +'%';
}
//show and hide labels depending on labels pref
//show the last one if there are more than 1 specified
if(options.labels > 1) sliderComponent.find('.ui-slider-scale li:last span.ui-slider-label, .ui-slider-scale dd:last span.ui-slider-label').addClass('ui-slider-label-show');
//set increment
var increm = Math.max(1, Math.round(selectOptions.length / options.labels));
//show em based on inc
for(var j=0; j<selectOptions.length; j+=increm){
if((selectOptions.length - j) > increm){//don't show if it's too close to the end label
sliderComponent.find('.ui-slider-scale li:eq('+ j +') span.ui-slider-label, .ui-slider-scale dd:eq('+ j +') span.ui-slider-label').addClass('ui-slider-label-show');
}
}
//style the dt's
sliderComponent.find('.ui-slider-scale dt').each(function(i){
jQuery(this).css({
'left': ((100 /( groups.length))*i).toFixed(2) + '%'
});
});
//inject and return
sliderComponent
.insertAfter(jQuery(this).eq(this.length-1))
.slider(options.sliderOptions)
.attr('role','application')
.find('.ui-slider-label')
.each(function(){
jQuery(this).css('marginLeft', -jQuery(this).width()/2);
});
//update tooltip arrow inner color
sliderComponent.find('.ui-tooltip-pointer-down-inner').each(function(){
var bWidth = jQuery('.ui-tooltip-pointer-down-inner').css('borderTopWidth');
var bColor = jQuery(this).parents('.ui-slider-tooltip').css('backgroundColor')
jQuery(this).css('border-top', bWidth+' solid '+bColor);
});
var values = sliderComponent.slider('values');
if(isArray(values)){
jQuery(values).each(function(i){
sliderComponent.find('.ui-slider-tooltip .ttContent').eq(i).text( ttText(this) );
});
}
else {
sliderComponent.find('.ui-slider-tooltip .ttContent').eq(0).text( ttText(values) );
}
return this;
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Scripts/selectToUISlider.jQuery.js
|
JavaScript
|
bsd
| 8,635
|
@model Lokad.Cloud.Console.WebRole.Models.Overview.OverviewModel
@{ ViewBag.Title = "Lokad.Cloud Administration Console - Overview"; }
<h1>Lokad.Cloud Hosted Services Overview</h1>
<p>The following Lokad.Cloud Hosted Services have been discovered in your Windows Azure subscription.</p>
@foreach (var item in Model.HostedServices) {
<table class="table">
<tr>
<th style="width: 180px;"><b>@item.ServiceName</b></th>
<th style="width: 500px;"><b>@item.ServiceLabel</b></th>
</tr>
@if (!String.IsNullOrEmpty(item.Description)) {
<tr>
<td colspan="2"><em>@item.Description</em></td>
</tr>
}
<tr>
<td style="text-align: right;">Storage Account:</td>
<td><code>@item.StorageAccountName</code>, with key <code>@item.StorageAccountKeyPrefix...</code></td>
</tr>
<tr>
<td style="text-align: right;">Deployments:</td>
<td>
@foreach (var deployment in item.Deployments) {
@: @Html.OkCancelIcon(deployment.IsRunning) @deployment.Slot @if (deployment.IsTransitioning) { <b>UPDATING</b> } with <b>@deployment.InstanceCount Worker Instances</b>: <em>@deployment.DeploymentLabel</em><br/>
}
</td>
</tr>
</table>
<p> </p>
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Overview/Index.cshtml
|
HTML+Razor
|
bsd
| 1,189
|
@model Lokad.Cloud.Console.WebRole.Models.Overview.DeploymentModel
@{ ViewBag.Title = "Lokad.Cloud Administration Console - Overview"; }
<h1>Lokad.Cloud Hosted Service Overview</h1>
<p>Details for the @Model.HostedService.ServiceLabel Hosted Service.</p>
<table class="table">
<tr>
<th style="text-align: right;">Name (Subdomain):</th>
<td><b>@Model.HostedService.ServiceName</b></td>
</tr>
<tr>
<th style="text-align: right;">Label:</th>
<td><b>@Model.HostedService.ServiceLabel</b></td>
</tr>
@if (!String.IsNullOrEmpty(Model.HostedService.Description)) {
<tr>
<th style="text-align: right;">Description:</th>
<td><em>@Model.HostedService.Description</em></td>
</tr>
}
<tr>
<th style="text-align: right;">Storage Account:</th>
<td><code>@Model.HostedService.StorageAccountName</code>, with key <code>@Model.HostedService.StorageAccountKeyPrefix...</code></td>
</tr>
</table>
<h2>Azure Deployments</h2>
<p>The following deployments have been discovered in the @Model.HostedService.ServiceLabel Hosted Service.</p>
<table class="table">
@foreach (var deployment in Model.HostedService.Deployments) {
<tr>
<td>
@Html.OkCancelIcon(deployment.IsRunning) <b>@deployment.Slot</b><br />
<br />
@if(deployment.IsTransitioning) { <b>UPDATING</b> }
else if(!deployment.IsRunning) { <b>SUSPENDED</b> }
</td>
<td>
@deployment.DeploymentLabel<br />
<br />
<b>@deployment.InstanceCount Worker Instances</b><br/><br />
@if (deployment.IsRunning) {
using (Html.BeginForm("InstanceCount", "Overview")) {
@Html.Hidden("slot", deployment.Slot)
<div class="warning">Update to @Html.TextBox("instanceCount", deployment.InstanceCount, new { style = "width:25px;" }) Worker Instances: <input type="submit" value="Request" /></div>
}
}
else if(deployment.IsTransitioning) { <div class="warning">An Azure deployment update is currently in progress.</div> }
else if(!deployment.IsRunning) { <div class="warning">The Azure deployment is suspended.</div> }
</td>
</tr>
}
</table>
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Overview/ByHostedService.cshtml
|
HTML+Razor
|
bsd
| 2,088
|
@model Lokad.Cloud.Console.WebRole.Models.Config.ConfigModel
@{ ViewBag.Title = "Lokad.Cloud Administration Console - Config"; }
<h1>Dependency Injection Configuration</h1>
<p>Optional XML application configuration to customize dependency injection for cloud services using an autofac configuration section.</p>
@using (Html.BeginForm("Configuration", "Config")) {
@Html.TextAreaFor(m => m.Configuration, 20, 80, null)
<input type="submit" value="Save" />
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Config/ByHostedService.cshtml
|
HTML+Razor
|
bsd
| 475
|
@model Lokad.Cloud.Console.WebRole.Models.Assemblies.AssembliesModel
@{ ViewBag.Title = "Lokad.Cloud Administration Console - Assemblies"; }
<h1>Assembly Manager</h1>
<p>Content of the assembly archive:</p>
@if (Model.ApplicationAssemblies.HasValue) {
<table class="table">
<tr>
<th>Assembly</th>
<th>Version</th>
<th>Created</th>
<th>Size</th>
<th>Symbols</th>
</tr>
@foreach (var item in Model.ApplicationAssemblies.Value)
{
<tr>
<td>@Html.OkCancelIcon(item.IsValid) @item.AssemblyName</td>
<td>@item.Version.ToString()</td>
<td>@String.Format("{0:g}", item.DateTime)</td>
<td>@String.Format("{0} KB", item.SizeBytes / 1024)</td>
<td>@Html.OkCancelIcon(item.HasSymbols) @(item.HasSymbols ? "Available" : "None")</td>
</tr>
}
</table>
} else {
<div class="warning">No Cloud Application Package was found</div>
}
<h2>Replace assembly package</h2>
<p>Upload a stand-alone .Net assembly (*.dll) or a Zip archive containing multiple assemblies. Matching symbol files (*.pdb) are supported but optional. The current assembly package will be deleted.</p>
@using (Html.BeginForm("UploadPackage", "Assemblies", new { hostedServiceName = ViewBag.Navigation.CurrentHostedServiceName }, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<p><input type="file" name="package" accept="application/octet-stream, application/zip" /><br /><input type="submit" value="Upload" /></p>
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Assemblies/ByHostedService.cshtml
|
HTML+Razor
|
bsd
| 1,458
|
@{ ViewBag.Title = "Lokad.Cloud Administration Console - Login"; }
<h2>Login</h2>
@if (ViewBag.Message != null) {
<div style="border: solid 1px red">@ViewBag.Message</div>
}
<p>You must log in before entering the Administration Console: </p>
<form action="Authenticate?ReturnUrl=@Html.Raw(HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]))" method="post">
<label for="openid_identifier">OpenID: </label>
<input id="openid_identifier" name="openid_identifier" size="40" />
<input type="submit" value="Login" />
</form>
<script type="text/javascript">
$(document).ready(function () {
$("#openid_identifier").focus();
});
</script>
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Account/Login.cshtml
|
HTML+Razor
|
bsd
| 667
|
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/_ViewStart.cshtml
|
HTML+Razor
|
bsd
| 52
|
@model Lokad.Cloud.Console.WebRole.Models.Queues.QueuesModel
@{ ViewBag.Title = "Lokad.Cloud Administration Console - Queues"; }
@section Header {
<script src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/knockout-1.1.2.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/knockout.mapping.js")" type="text/javascript"></script>
}
<h1>Queue Workload</h1>
<p>This table reports the workload in the various queues of the account</p>
<table class="table">
<tr>
<th></th>
<th>Queue</th>
<th>Messages</th>
<th>Latency</th>
</tr>
<tbody data-bind='template: {name: "queueRowTemplate", foreach: Queues, beforeRemove: function(e) { $(e).slideUp() }, afterAdd: function(e) { $(e).hide().slideDown() } }'></tbody>
</table>
<h2>Quarantine: Failing Messages</h2>
<p>
Messages which fail repeatedly are persisted and removed from the queue in order to keep it healthy.
</p>
<div data-bind="visible: Quarantine().length == 0">
No message has been considered as failing so far.
</div>
<div data-bind="visible: Quarantine().length > 0">
The following messages have been considered as failing. Note that persisted messages may become unrestorable if their originating queue is deleted. No more than 50 messsages are shown at a time.
</div>
<div data-bind='template: { name: "quarantineTemplate", foreach: Quarantine, beforeRemove: function(e) { $(e).slideUp() }, afterAdd: function(e) { $(e).hide().slideDown() } }'></div>
<script type="text/html" id="queueRowTemplate">
<tr>
<td><button data-bind="click: function() { removeQueue($data) }">Delete</button></td>
<td><b data-bind="css: { queueNameWithMessages: MessageCount() > 0 }">${QueueName}</b>
{{each Services}}
<br/><small>Consumed by: ${TypeName}</small>
{{/each}}
</td>
<td data-bind="css: { queueMessageNumberWithMessages: MessageCount() > 0 }">${MessageCount}</td>
<td>${Latency}</td>
</tr>
</script>
<script type="text/html" id="quarantineTemplate">
<h3>Queue: ${QueueName}
<button data-bind="click: function() { restoreQuarantineQueue($data) }">Restore All</button>
<button data-bind="click: function() { removeQuarantineQueue($data) }">Delete All</button>
</h3>
<div data-bind='template: { name: "messageTemplate", foreach: Messages, beforeRemove: function(e) { $(e).slideUp() }, afterAdd: function(e) { $(e).hide().slideDown() } }'></div>
</script>
<script type="text/html" id="messageTemplate">
<div class="groupbox">
<p>Inserted ${Inserted} but quarantined ${Persisted}
<button data-bind="click: function() { restoreQuarantineMessage($data) }">Restore</button>
<button data-bind="click: function() { removeQuarantineMessage($data) }">Delete</button>
</p>
<div class="warning" data-bind="visible: !HasData">The raw data was lost, the message is not restoreable. Maybe the queue has been deleted in the meantime.</div>
<div class="warning" data-bind="visible: HasData && !HasXml">The XML representation of this message is not available, but message is still restoreable in its raw representation.</div>
<pre data-bind="visible: HasXml">${Content}</pre>
<div data-bind="visible: Reason">
Reason:
<pre>${Reason}</pre>
</div>
</div>
</script>
<script type="text/javascript">
var viewModel = ko.mapping.fromJSON(@Html.Enquote(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(Model)));
removeQueue = function(queue) {
ajaxDeleteQueue(queue);
viewModel.Queues.remove(queue);
};
removeQuarantineQueue = function(queue) {
while(message = queue.Messages.pop()) {
ajaxDeleteQuarantineMessage(message);
}
viewModel.Quarantine.remove(queue);
};
removeQuarantineMessage = function(message) {
ajaxDeleteQuarantineMessage(message);
var queue = quarantineQueueOfMessage(message);
queue.Messages.remove(message);
if (queue.Messages().length == 0) {
viewModel.Quarantine.remove(queue);
}
};
restoreQuarantineQueue = function(queue) {
while(message = queue.Messages.pop()) {
ajaxRestoreQuarantineMessage(message);
}
viewModel.Quarantine.remove(queue);
};
restoreQuarantineMessage = function(message) {
ajaxRestoreQuarantineMessage(message);
var queue = quarantineQueueOfMessage(message);
queue.Messages.remove(message);
if (queue.Messages().length == 0) {
viewModel.Quarantine.remove(queue);
}
};
quarantineQueueOfMessage = function(message) {
var queue;
$.each(viewModel.Quarantine(), function(i,q) { if (q.Messages.indexOf(message) >= 0) { queue = q; } });
return queue;
};
ajaxDeleteQueue = function(queue) {
$.ajax({
url: '@ViewBag.TenantPath/Queue/' + queue.QueueName(),
type: 'DELETE',
dataType: 'json',
cache: false,
});
};
ajaxDeleteQuarantineMessage = function(message) {
$.ajax({
url: '@ViewBag.TenantPath/QuarantinedMessage/' + message.Key(),
type: 'DELETE',
dataType: 'json',
cache: false,
});
};
ajaxRestoreQuarantineMessage = function(message) {
$.ajax({
url: '@ViewBag.TenantPath/RestoreQuarantinedMessage/' + message.Key(),
type: 'POST',
dataType: 'json',
cache: false,
});
};
$(document).ready(function () {
ko.applyBindings(viewModel);
$('#AjaxLoading')
.bind("ajaxStart", function() { $(this).show() })
.bind("ajaxStop", function() { $(this).hide() });
});
</script>
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Queues/ByHostedService.cshtml
|
HTML+Razor
|
bsd
| 5,556
|
<ul>
@if (Request.IsAuthenticated) {
<li>Welcome <b>@HttpContext.Current.User.Identity.Name</b> @Html.ActionLink("Logout", "Logout", "Account")</li>
}
else {
<li>@Html.ActionLink("Login", "Login", "Account")</li>
}
</ul>
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Shared/AuthBarPartial.cshtml
|
HTML+Razor
|
bsd
| 259
|
@model Lokad.Cloud.Console.WebRole.Models.Shared.NavigationModel
<ul id="menu">
@foreach (var item in Model.HostedServiceNames) {
@Html.DeploymentMenuEntry(Model, item, item)
}
</ul>
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Shared/DeploymentMenuPartial.cshtml
|
HTML+Razor
|
bsd
| 196
|
@model Lokad.Cloud.Console.WebRole.Models.Shared.NavigationModel
<ul id="menu">
@Html.NavigationMenuEntry(Model, "Overview", "Overview")
@Html.NavigationMenuEntry(Model, "Assemblies", "Assemblies")
@Html.NavigationMenuEntry(Model, "Config", "Config")
@Html.NavigationMenuEntry(Model, "Services", "Services")
@Html.NavigationMenuEntry(Model, "Scheduler", "Scheduler")
@Html.NavigationMenuEntry(Model, "Queues", "Queues")
@Html.NavigationMenuEntry(Model, "Logs", "Logs")
</ul>
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Shared/NavigationMenuPartial.cshtml
|
HTML+Razor
|
bsd
| 495
|
@model System.Web.Mvc.HandleErrorInfo
@{ ViewBag.Title = "Error"; }
<h2>Sorry, an error occurred while processing your request.</h2>
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Shared/Error.cshtml
|
HTML+Razor
|
bsd
| 141
|
@using Lokad.Cloud.Console.WebRole.Models.Shared
<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Lokad.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/jquery-ui-1.7.1.custom.css")" rel="stylesheet" type="text/css" />
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.7/jquery-ui.min.js" type="text/javascript"></script>
@RenderSection("Header", required: false)
</head>
<body>
<div class="page">
<div id="HeaderDiv">
<div id="AuthBar">
@Html.Partial("AuthBarPartial")
</div>
<div id="TopBarBackground"></div>
<div id="TopBar">
<div id="Logo"><h1><a href="http://www.lokad.com/"><span class="hidden">Lokad.com</span></a></h1></div>
<div id="TopControls"></div>
</div>
<div id="TitleBar"><h2>Lokad.Cloud - Administration Console</h2></div>
@if (ViewBag.Navigation.ShowDeploymentSelector) {
<div id="SubNavBar">
@Html.Partial("DeploymentMenuPartial", (NavigationModel)ViewBag.Navigation)
</div>
}
<div id="NavBar">
@Html.Partial("NavigationMenuPartial", (NavigationModel)ViewBag.Navigation)
</div>
</div>
<div id="ContentWrapper">
<div id="ContainerDiv">
<div id="SidebarDiv">
<div id="SidebarHeaderDiv"></div>
<div id="SidebarContentDiv"></div>
<div id="SidebarFooterDiv"></div>
</div>
<div id="MainDiv">
<div id="MainHeaderDiv"></div>
<div id="Text">
@RenderBody()
</div>
<div id="MainFooterDiv"></div>
</div>
</div>
<div id="FooterDiv">
</div>
</div>
<div id="FooterWrapper">
<div id="Footer">
<div class="left">
<b>Lokad.Cloud</b>
<ul>
<li class="first"><a href="http://code.google.com/p/lokad-cloud/" class="pagelink">Project homepage</a><br />
<a href="http://code.google.com/p/lokad-cloud/issues/list" class="pagelink">Report an issue</a>
</li>
</ul>
</div>
<div class="right">
<a href="http://www.lokad.com/AboutUs.ashx" class="pagelink" title="About Us">About Us</a> |
<a href="http://www.lokad.com/ContactUs.ashx" class="pagelink" title="Contact Us">Contact Us</a> |
© 2011 Lokad<br />
<img id="AjaxLoading" src="/Content/Images/loading.gif" style="display: none;" /><br />
@if (IsSectionDefined("Timestamp")) {
@RenderSection("Timestamp")
}
else if (ViewBag.Discovery.ShowLastDiscoveryUpdate) {
@: Data shown is not older than @ViewBag.Discovery.LastDiscoveryUpdate
}
</div>
</div>
<br />
</div>
</div>
</body>
</html>
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Shared/_Layout.cshtml
|
HTML+Razor
|
bsd
| 2,794
|
@{ ViewBag.Title = "Lokad.Cloud Administration Console - Discovery"; }
<div class="warning">
The Lokad.Cloud Administration Console is currently discovering the Windows Azure subscription
for Lokad.Cloud deployments. This page automatically refreshes every 10 seconds.
Please wait or refresh manually.
</div>
<script type="text/javascript">
setTimeout("location.reload(true);", 10000);
</script>
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Discovery/Index.cshtml
|
HTML+Razor
|
bsd
| 416
|
@model Lokad.Cloud.Console.WebRole.Models.Logs.LogsModel
@{ ViewBag.Title = "Lokad.Cloud Administration Console - Logs"; }
@section Header {
<script src="http://ajax.aspnetcdn.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js" type="text/javascript"></script>
<link href="@Url.Content("~/Content/ui.slider.extras.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/selectToUISlider.jQuery.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/knockout-1.1.2.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/knockout.mapping.js")" type="text/javascript"></script>
}
<h1>Logs</h1>
<p>Use the slider below to choose the threshold level for filtering out less important log entries.</p>
<fieldset>
<select name="loglevel" id="loglevel">
<option value="Debug">Debug</option>
<option value="Info" selected="selected">Info</option>
<option value="Warn">Warning</option>
<option value="Error">Error</option>
<option value="Fatal">Fatal</option>
</select>
</fieldset>
<div class="loadMore" data-bind='visible: NewerAvailable, click: loadNewerEntries'>New Entries Available</div>
<div data-bind='template: { name: "logGroupTemplate", foreach: Groups }'></div>
<br />
<p data-bind="visible: Groups().length == 0">No log entries satisfy the chosen log level threshold. Use the level selector above to choose a different level.</p>
<script type="text/html" id="logGroupTemplate">
<h2>${Title}</h2>
<table class="table" id="datatable">
<thead>
<tr>
<th width="60">Time</th>
<th width="20"></th>
<th width="100%">Message</th>
</tr>
</thead>
<tbody data-bind='template: {name: "logEntryTemplate", foreach: Entries}'></tbody>
</table>
<div class="loadMore" data-bind='visible: OlderAvailable, click: function() { loadOlderEntries($data) }'>More Available</div>
</script>
<script type="text/html" id="logEntryTemplate">
<tr>
<td>${Time}</td>
<td><span class="icon-LogLevels icon-LogLevels-${Level}"></span></td>
<td>
${Message}<br />
<div data-bind="visible: Error">
<b>Exception Details and Stack:</b> (<a href="#" data-bind="click: function() { toggleShowDetails($data) }">Show/Hide</a>)<br />
<pre data-bind="visible: ShowDetails">${Error}</pre>
</div>
</td>
</tr>
</script>
<script type="text/javascript">
// inline to save a separate request
var viewModel = ko.mapping.fromJSON(@Html.Enquote(new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(Model)));
var updateMask = false;
var ajaxQueue = $({});
$.ajaxQueue = function(ajaxOpts) {
var oldComplete = ajaxOpts.complete;
ajaxQueue.queue(function(next) {
ajaxOpts.complete = function() {
if(oldComplete) { oldComplete.apply(this, arguments); }
next();
};
$.ajax(ajaxOpts);
});
};
toggleShowDetails = function(entry) {
entry.ShowDetails(!entry.ShowDetails());
};
loadOlderEntries = function(group) {
group.OlderAvailable(false);
var groupIndex = viewModel.Groups.indexOf(group);
var newerThanToken = groupIndex == (viewModel.Groups().length - 1) ? undefined : viewModel.Groups()[groupIndex + 1].NewestToken();
$.ajaxQueue({
url: '@ViewBag.TenantPath/Entries',
dataType: 'json',
data: { threshold: $('select#loglevel').val(), skip: group.Entries().length, count: 50, olderThanToken: group.OldestToken(), newerThanToken: newerThanToken },
cache: false,
success: function (data) {
$.each(data.Groups, function (i, g) { viewModel.Groups.push(ko.mapping.fromJS(g)); });
sortGroups();
joinGroups();
}
});
};
loadNewerEntries = function() {
viewModel.NewerAvailable(false);
$.ajaxQueue({
url: '@ViewBag.TenantPath/Entries',
dataType: 'json',
data: { threshold: $('select#loglevel').val(), count: 50, newerThanToken: viewModel.NewestToken() },
cache: false,
success: function (data) {
viewModel.NewerAvailable(false);
viewModel.NewestToken(data.NewestToken);
while(group = data.Groups.pop()) { viewModel.Groups.unshift(ko.mapping.fromJS(group)); }
joinGroups();
}
});
}
sortGroups = function() {
viewModel.Groups.sort(function (l,r) {
if(l.Key() != r.Key()) {
return l.Key() < r.Key() ? 1 : -1
}
if(l.NewestToken() != r.NewestToken()) {
return l.NewestToken() < r.NewestToken() ? 1 : -1
}
return 0;
});
}
joinGroups = function() {
var groups = viewModel.Groups();
for(index=groups.length-2; index >= 0; index--) {
var upper = groups[index];
var lower = groups[index+1];
if ((upper.Key() == lower.Key()) && !upper.OlderAvailable()) {
$.each(lower.Entries(), function (i,e) { upper.Entries.push(e); });
upper.OlderAvailable(lower.OlderAvailable());
upper.OldestToken(lower.OldestToken());
viewModel.Groups.remove(lower);
}
}
}
$(document).ready(function() {
ko.applyBindings(viewModel);
$('#AjaxLoading')
.bind("ajaxStart", function() { $(this).show(); updateMask = true; })
.bind("ajaxStop", function() { $(this).hide(); updateMask = false; })
$('select#loglevel').selectToUISlider({ labels: 5, sliderOptions: { change: function() {
$.ajaxQueue({
url: '@ViewBag.TenantPath/Entries',
dataType: 'json',
data: { threshold: $('select#loglevel').val() },
cache: false,
success: function (data) {
ko.mapping.updateFromJS(viewModel, data);
}
});
}}}).hide();
setInterval(function () {
if (updateMask || viewModel.NewerAvailable()) { return; }
$.ajaxQueue({
url: '@ViewBag.TenantPath/HasNewerEntries',
dataType: 'json',
data: { threshold: $('select#loglevel').val(), newerThanToken: viewModel.NewestToken() },
cache: false,
success: function (data) {
viewModel.NewerAvailable(data.HasMore);
}
});
}, 30000);
});
</script>
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Logs/ByHostedService.cshtml
|
HTML+Razor
|
bsd
| 5,971
|
@model Lokad.Cloud.Console.WebRole.Models.Scheduler.SchedulerModel
@{ ViewBag.Title = "Lokad.Cloud Administration Console - Scheduler"; }
<h1>Scheduler</h1>
<p>Manage scheduled execution of your services.</p>
<table class="table">
<tr>
<th>Name</th>
<th>Last Run</th>
<th>Period</th>
<th>Scope</th>
<th>Lease</th>
</tr>
@foreach (var item in Model.Schedules) {
<tr>
<td>@item.ServiceName</td>
<td>@(item.WorkerScoped ? "untracked" : Lokad.FormatUtil.TimeOffsetUtc(item.LastExecuted.UtcDateTime))</td>
<td>@item.TriggerInterval</td>
<td>@(item.WorkerScoped ? "Worker" : "Cloud")</td>
<td>@PresentationHelpers.PrettyFormatLease(item)</td>
</tr>
}
</table>
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Scheduler/ByHostedService.cshtml
|
HTML+Razor
|
bsd
| 722
|
@model Lokad.Cloud.Console.WebRole.Models.Services.ServicesModel
@{ ViewBag.Title = "Lokad.Cloud Administration Console - Services"; }
<h1>Service Manager</h1>
<p>All initialized cloud services are listed below. Enable or disable a service by clicking its status icon.</p>
@if (Model.QueueServices.Any()) {
<h2>Queue Services</h2>
<table class="table">
@foreach (var item in Model.QueueServices) {
<tr>
<td>@Html.StartStopIconButton(item.IsStarted, item.ServiceName)</td>
<td><b>@item.ServiceName</b><br />
<small>Messages: @item.Definition.MessageTypeName</small><br />
<small>Queue: @item.Definition.QueueName</small></td>
</tr>
}
</table>
}
@if (Model.ScheduledServices.Any()) {
<h2>Scheduled Services</h2>
<table class="table">
@foreach (var item in Model.ScheduledServices) {
<tr>
<td>@Html.StartStopIconButton(item.IsStarted, item.ServiceName)</td>
<td>@item.ServiceName</td>
</tr>
}
</table>
}
@if (Model.CloudServices.Any()) {
<h2>Other Services</h2>
<table class="table">
@foreach (var item in Model.CloudServices) {
<tr>
<td>@Html.StartStopIconButton(item.IsStarted, item.ServiceName)</td>
<td>@item.ServiceName</td>
</tr>
}
</table>
}
@if (Model.UnavailableServices.Any()) {
<h2>Unavailable Services</h2>
<table class="table">
@foreach (var item in Model.UnavailableServices) {
<tr>
<td>@Html.StartStopIconButton(item.IsStarted, item.ServiceName)</td>
<td>@item.ServiceName</td>
</tr>
}
</table>
}
<script type="text/javascript">
function statusToClass(status) {
if (status) return '@IconMap.StartStopOf(true)';
else return '@IconMap.StartStopOf(false)';
}
$(document).ready(function () {
$('.icon-button').click(function () {
$('#AjaxLoading').show();
me = $(this);
enable = me.hasClass(statusToClass(false));
me.removeClass(statusToClass(!enable));
me.addClass('@IconMap.Loading');
$.ajax({
url: '@ViewBag.TenantPath/Status/' + me.attr('id'),
type: 'PUT',
dataType: 'json',
data: { isStarted: enable },
cache: false,
success: function (data) {
element = $('span[id=' + data.serviceName + ']');
element.removeClass('@IconMap.Loading');
element.addClass(statusToClass(data.isStarted));
$('#AjaxLoading').hide();
}
});
});
});
</script>
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Views/Services/ByHostedService.cshtml
|
HTML+Razor
|
bsd
| 2,375
|
using System.Reflection;
using System.Threading;
using System.Web.Mvc;
using System.Web.Routing;
using Lokad.Cloud.Console.WebRole.Framework.Discovery;
using Ninject;
using Ninject.Web.Mvc;
namespace Lokad.Cloud.Console.WebRole
{
public class MvcApplication : NinjectHttpApplication
{
private CancellationTokenSource _discoveryCancellation;
private static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
}
private static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("Content/{*pathInfo}");
routes.MapRoute("Overview", "", new { controller = "Overview", action = "Index" });
routes.MapRoute("Account", "Account/{action}/{id}", new { controller = "Account", action = "Index", id = UrlParameter.Optional });
routes.MapRoute("Discovery", "Discovery/{action}/{id}", new { controller = "Discovery", action = "Index", id = UrlParameter.Optional });
routes.MapRoute("ByHostedService", "{controller}/{hostedServiceName}/{action}/{id}", new { action = "ByHostedService", id = UrlParameter.Optional });
routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "Overview", action = "Index", id = UrlParameter.Optional });
routes.MapRoute("MenuIndex", "{controller}/{action}", new { controller = "Overview", action = "Index" });
routes.MapRoute("MenuByHostedService", "{controller}/{hostedServiceName}/{action}", new { controller = "Overview", action = "ByHostedService" });
}
protected override IKernel CreateKernel()
{
var kernel = new StandardKernel();
kernel.Load(Assembly.GetExecutingAssembly());
return kernel;
}
protected override void OnApplicationStarted()
{
base.OnApplicationStarted();
AreaRegistration.RegisterAllAreas();
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
_discoveryCancellation = new CancellationTokenSource();
var discovery = (AzureDiscoveryProvider)DependencyResolver.Current.GetService(typeof(AzureDiscoveryProvider));
discovery.StartAutomaticCacheUpdate(_discoveryCancellation.Token);
}
protected override void OnApplicationStopped()
{
if (_discoveryCancellation != null)
{
_discoveryCancellation.Cancel();
_discoveryCancellation = null;
}
base.OnApplicationStopped();
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Global.asax.cs
|
C#
|
bsd
| 2,809
|
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Lokad.Cloud.Console.WebRole")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Lokad.Cloud.Console.WebRole")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("3302cbdf-398b-44de-bc2b-f4a3c604b05a")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Properties/AssemblyInfo.cs
|
C#
|
bsd
| 1,403
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Web.Mvc;
using Lokad.Cloud.Console.WebRole.Behavior;
using Lokad.Cloud.Console.WebRole.Controllers.ObjectModel;
using Lokad.Cloud.Console.WebRole.Framework.Discovery;
namespace Lokad.Cloud.Console.WebRole.Controllers
{
[RequireAuthorization]
public sealed class DiscoveryController : ApplicationController
{
public DiscoveryController(AzureDiscoveryInfo discoveryInfo)
: base(discoveryInfo)
{
}
[HttpGet]
public ActionResult Index(string returnUrl)
{
if (DiscoveryInfo.IsAvailable)
{
if (!string.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
return RedirectToAction("Index", "Overview");
}
ShowWaitingForDiscoveryInsteadOfContent = true;
HideDiscovery();
return View();
}
[HttpGet]
public ActionResult Status()
{
return Json(new
{
isAvailable = DiscoveryInfo.IsAvailable
});
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Controllers/DiscoveryController.cs
|
C#
|
bsd
| 1,361
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Lokad.Cloud.Console.WebRole.Behavior;
using Lokad.Cloud.Console.WebRole.Controllers.ObjectModel;
using Lokad.Cloud.Console.WebRole.Framework.Discovery;
using Lokad.Cloud.Console.WebRole.Models.Logs;
using Lokad.Cloud.Diagnostics;
namespace Lokad.Cloud.Console.WebRole.Controllers
{
using System.Collections.Generic;
[RequireAuthorization, RequireDiscovery]
public sealed class LogsController : TenantController
{
private const int InitialEntriesCount = 15;
public LogsController(AzureDiscoveryInfo discoveryInfo)
: base(discoveryInfo)
{
}
[HttpGet]
public override ActionResult ByHostedService(string hostedServiceName)
{
InitializeDeploymentTenant(hostedServiceName);
var entries = new CloudLogger(Providers.BlobStorage, string.Empty)
.GetLogsOfLevelOrHigher(Storage.Shared.Logging.LogLevel.Info)
.Take(InitialEntriesCount);
return View(LogEntriesToModel(entries.ToArray(), InitialEntriesCount));
}
[HttpGet]
public ActionResult Entries(string hostedServiceName, string threshold, int skip = 0, int count = InitialEntriesCount, string olderThanToken = null, string newerThanToken = null)
{
if(count < 1 || count > 100) throw new ArgumentOutOfRangeException("count", "Must be in range [1;100].");
InitializeDeploymentTenant(hostedServiceName);
var entries = new CloudLogger(Providers.BlobStorage, string.Empty)
.GetLogsOfLevelOrHigher(ParseLogLevel(threshold), skip);
if (!string.IsNullOrWhiteSpace(olderThanToken))
{
entries = entries.SkipWhile(entry => string.Compare(EntryToToken(entry), olderThanToken) >= 0);
}
if (!string.IsNullOrWhiteSpace(newerThanToken))
{
entries = entries.TakeWhile(entry => string.Compare(EntryToToken(entry), newerThanToken) > 0);
}
entries = entries.Take(count);
return Json(LogEntriesToModel(entries.ToArray(), count), JsonRequestBehavior.AllowGet);
}
[HttpGet]
public ActionResult HasNewerEntries(string hostedServiceName, string threshold, string newerThanToken)
{
InitializeDeploymentTenant(hostedServiceName);
var entry = new CloudLogger(Providers.BlobStorage, string.Empty)
.GetLogsOfLevelOrHigher(ParseLogLevel(threshold))
.FirstOrDefault();
if (null != entry && string.Compare(EntryToToken(entry), newerThanToken) > 0)
{
return Json(new { HasMore = true, NewestToken = EntryToToken(entry) }, JsonRequestBehavior.AllowGet);
}
return Json(new { HasMore = false }, JsonRequestBehavior.AllowGet);
}
private static LogsModel LogEntriesToModel(IList<LogEntry> entryList, int requestedCount)
{
if (entryList.Count == 0)
{
return new LogsModel { NewestToken = string.Empty, Groups = new LogGroup[0] };
}
var logsModel = new LogsModel
{
NewestToken = EntryToToken(entryList[0]),
Groups = entryList.GroupBy(EntryToGroupKey).Select(group => new LogGroup
{
Key = group.Key,
Title = group.First().DateTimeUtc.ToLongDateString(),
NewestToken = EntryToToken(group.First()),
OldestToken = EntryToToken(group.Last()),
Entries = group.Select(entry => new LogItem
{
Token = EntryToToken(entry),
Time = entry.DateTimeUtc.ToString("HH:mm:ss"),
Level = entry.Level,
Message = HttpUtility.HtmlEncode(entry.Message),
Error = HttpUtility.HtmlEncode(entry.Error ?? string.Empty)
}).ToArray()
}).ToArray()
};
if (entryList.Count == requestedCount)
{
logsModel.Groups.Last().OlderAvailable = true;
}
return logsModel;
}
static Storage.Shared.Logging.LogLevel ParseLogLevel(string str)
{
switch (str.ToLowerInvariant())
{
case "debug":
return Storage.Shared.Logging.LogLevel.Debug;
case "info":
return Storage.Shared.Logging.LogLevel.Info;
case "warn":
return Storage.Shared.Logging.LogLevel.Warn;
case "error":
return Storage.Shared.Logging.LogLevel.Error;
case "fatal":
return Storage.Shared.Logging.LogLevel.Fatal;
}
throw new ArgumentOutOfRangeException();
}
static string EntryToToken(LogEntry entry)
{
return entry.DateTimeUtc.ToString("yyyyMMddHHmmssffff");
}
static int EntryToGroupKey(LogEntry entry)
{
var date = entry.DateTimeUtc.Date;
return (date.Year * 100 + date.Month) * 100 + date.Day;
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Controllers/LogsController.cs
|
C#
|
bsd
| 5,840
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Web.Mvc;
using Lokad.Cloud.Console.WebRole.Behavior;
using Lokad.Cloud.Console.WebRole.Controllers.ObjectModel;
using Lokad.Cloud.Console.WebRole.Framework.Discovery;
using Lokad.Cloud.Console.WebRole.Framework.Services;
namespace Lokad.Cloud.Console.WebRole.Controllers
{
[RequireAuthorization, RequireDiscovery]
public sealed class QueuesController : TenantController
{
const string FailingMessagesStoreName = "failing-messages";
public QueuesController(AzureDiscoveryInfo discoveryInfo)
: base(discoveryInfo)
{
}
[HttpGet]
public override ActionResult ByHostedService(string hostedServiceName)
{
InitializeDeploymentTenant(hostedServiceName);
var provider = new AppDefinitionWithLiveDataProvider(Providers);
return View(provider.QueryQueues());
}
[HttpDelete]
public EmptyResult Queue(string hostedServiceName, string id)
{
InitializeDeploymentTenant(hostedServiceName);
Providers.QueueStorage.DeleteQueue(id);
return null;
}
[HttpDelete]
public EmptyResult QuarantinedMessage(string hostedServiceName, string id)
{
InitializeDeploymentTenant(hostedServiceName);
Providers.QueueStorage.DeletePersisted(FailingMessagesStoreName, id);
return null;
}
[HttpPost]
public EmptyResult RestoreQuarantinedMessage(string hostedServiceName, string id)
{
InitializeDeploymentTenant(hostedServiceName);
Providers.QueueStorage.RestorePersisted(FailingMessagesStoreName, id);
return null;
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Controllers/QueuesController.cs
|
C#
|
bsd
| 1,940
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Web.Mvc;
using Lokad.Cloud.Console.WebRole.Behavior;
using Lokad.Cloud.Console.WebRole.Controllers.ObjectModel;
using Lokad.Cloud.Console.WebRole.Framework.Discovery;
using Lokad.Cloud.Console.WebRole.Models.Config;
namespace Lokad.Cloud.Console.WebRole.Controllers
{
[RequireAuthorization, RequireDiscovery]
public sealed class ConfigController : TenantController
{
public ConfigController(AzureDiscoveryInfo discoveryInfo)
: base(discoveryInfo)
{
}
[HttpGet]
public override ActionResult ByHostedService(string hostedServiceName)
{
InitializeDeploymentTenant(hostedServiceName);
var cloudConfiguration = new Management.CloudConfiguration(Providers);
return View(new ConfigModel
{
Configuration = cloudConfiguration.GetConfigurationString()
});
}
[HttpPost]
[ValidateInput(false)] // we're expecting xml
public ActionResult Configuration(string hostedServiceName, ConfigModel model)
{
InitializeDeploymentTenant(hostedServiceName);
var cloudConfiguration = new Management.CloudConfiguration(Providers);
if (ModelState.IsValid)
{
if (string.IsNullOrWhiteSpace(model.Configuration))
{
cloudConfiguration.RemoveConfiguration();
}
else
{
cloudConfiguration.SetConfiguration(model.Configuration.Trim());
}
}
return RedirectToAction("ByHostedService");
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Controllers/ConfigController.cs
|
C#
|
bsd
| 1,897
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Web.Mvc;
using Lokad.Cloud.Console.WebRole.Behavior;
using Lokad.Cloud.Console.WebRole.Controllers.ObjectModel;
using Lokad.Cloud.Console.WebRole.Framework.Discovery;
using Lokad.Cloud.Console.WebRole.Models.Overview;
namespace Lokad.Cloud.Console.WebRole.Controllers
{
[RequireAuthorization, RequireDiscovery]
public sealed class OverviewController : TenantController
{
private readonly AzureUpdater _updater;
public OverviewController(AzureDiscoveryInfo discoveryInfo, AzureUpdater updater)
: base(discoveryInfo)
{
_updater = updater;
}
[HttpGet]
public override ActionResult Index()
{
return View(new OverviewModel
{
HostedServices = DiscoveryInfo.LokadCloudDeployments.ToArray()
});
}
[HttpGet]
public override ActionResult ByHostedService(string hostedServiceName)
{
InitializeDeploymentTenant(hostedServiceName);
return View(new DeploymentModel
{
HostedService = HostedService
});
}
[HttpPost]
public ActionResult InstanceCount(string hostedServiceName, string slot, int instanceCount)
{
InitializeDeploymentTenant(hostedServiceName);
_updater.UpdateInstanceCountAsync(hostedServiceName, slot, instanceCount).Wait();
return RedirectToAction("ByHostedService");
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Controllers/OverviewController.cs
|
C#
|
bsd
| 1,741
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.IO;
using System.Web;
using System.Web.Mvc;
using Lokad.Cloud.Application;
using Lokad.Cloud.Console.WebRole.Behavior;
using Lokad.Cloud.Console.WebRole.Controllers.ObjectModel;
using Lokad.Cloud.Console.WebRole.Framework.Discovery;
using Lokad.Cloud.Console.WebRole.Models.Assemblies;
namespace Lokad.Cloud.Console.WebRole.Controllers
{
[RequireAuthorization, RequireDiscovery]
public sealed class AssembliesController : TenantController
{
public AssembliesController(AzureDiscoveryInfo discoveryInfo)
: base(discoveryInfo)
{
}
[HttpGet]
public override ActionResult ByHostedService(string hostedServiceName)
{
InitializeDeploymentTenant(hostedServiceName);
var cloudAssemblies = new Management.CloudAssemblies(Providers);
var appDefinition = cloudAssemblies.GetApplicationDefinition();
return View(new AssembliesModel
{
ApplicationAssemblies = appDefinition.HasValue ?
appDefinition.Value.Assemblies : new CloudApplicationAssemblyInfo[0]
});
}
[HttpPost]
public ActionResult UploadPackage(string hostedServiceName, HttpPostedFileBase package)
{
InitializeDeploymentTenant(hostedServiceName);
var cloudAssemblies = new Management.CloudAssemblies(Providers);
byte[] bytes;
using (var reader = new BinaryReader(package.InputStream))
{
bytes = reader.ReadBytes(package.ContentLength);
}
switch ((Path.GetExtension(package.FileName) ?? string.Empty).ToLowerInvariant())
{
case ".dll":
cloudAssemblies.UploadAssemblyDll(bytes, package.FileName);
break;
default:
cloudAssemblies.UploadAssemblyZipContainer(bytes);
break;
}
return RedirectToAction("ByHostedService");
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Controllers/AssembliesController.cs
|
C#
|
bsd
| 2,291
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Web.Mvc;
using System.Web.Security;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OpenId;
using DotNetOpenAuth.OpenId.RelyingParty;
using Lokad.Cloud.Console.WebRole.Behavior;
using Lokad.Cloud.Console.WebRole.Controllers.ObjectModel;
using Lokad.Cloud.Console.WebRole.Framework.Discovery;
namespace Lokad.Cloud.Console.WebRole.Controllers
{
public sealed class AccountController : ApplicationController
{
private static readonly OpenIdRelyingParty OpenId = new OpenIdRelyingParty();
public AccountController(AzureDiscoveryInfo discoveryInfo)
: base(discoveryInfo)
{
ShowWaitingForDiscoveryInsteadOfContent = false;
HideDiscovery();
}
public ActionResult Login()
{
return View();
}
public ActionResult Authenticate(string returnUrl)
{
var response = OpenId.GetResponse();
if (response == null)
{
// Stage 2: user submitting Identifier
Identifier id;
if (Identifier.TryParse(Request.Form["openid_identifier"], out id))
{
try
{
OpenId.CreateRequest(Request.Form["openid_identifier"]).RedirectToProvider();
}
catch (ProtocolException)
{
ViewBag.Message = "No such endpoint can be found.";
return View("Login");
}
}
else
{
ViewBag.Message = "Invalid identifier.";
return View("Login");
}
}
else
{
// HACK: Filtering users based on their registrations
if (!Users.IsAdministrator(response.ClaimedIdentifier))
{
ViewBag.Message = "This user does not have access rights.";
return View("Login");
}
// Stage 3: OpenID Provider sending assertion response
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
Session["FriendlyIdentifier"] = response.FriendlyIdentifierForDisplay;
FormsAuthentication.SetAuthCookie(response.ClaimedIdentifier, false);
if (!string.IsNullOrEmpty(returnUrl))
{
return Redirect(returnUrl);
}
else
{
return RedirectToAction("Index", "Overview");
}
case AuthenticationStatus.Canceled:
ViewBag.Message = "Canceled at provider";
return View("Login");
case AuthenticationStatus.Failed:
ViewBag.Message = response.Exception.Message;
return View("Login");
}
}
return new EmptyResult();
}
public ActionResult Logout()
{
FormsAuthentication.SignOut();
return RedirectToAction("Index", "Overview");
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Controllers/AccountController.cs
|
C#
|
bsd
| 3,616
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Linq;
using System.Web.Mvc;
using Lokad.Cloud.Console.WebRole.Framework.Discovery;
using Lokad.Cloud.Runtime;
using Lokad.Cloud.Storage;
namespace Lokad.Cloud.Console.WebRole.Controllers.ObjectModel
{
public abstract class TenantController : ApplicationController
{
protected LokadCloudHostedService HostedService { get; private set; }
protected RuntimeProviders Providers { get; private set; }
protected TenantController(AzureDiscoveryInfo discoveryInfo) : base(discoveryInfo)
{
}
protected void InitializeDeploymentTenant(string hostedServiceName)
{
CurrentHostedService = hostedServiceName;
var services = DiscoveryInfo.LokadCloudDeployments;
HostedService = services.Single(d => d.ServiceName == hostedServiceName);
Providers = CloudStorage
.ForAzureAccount(HostedService.StorageAccount)
.BuildRuntimeProviders();
}
public abstract ActionResult ByHostedService(string hostedServiceName);
public virtual ActionResult Index()
{
return RedirectToAction("ByHostedService", new { hostedServiceName = DiscoveryInfo.LokadCloudDeployments.First().ServiceName });
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Controllers/ObjectModel/TenantController.cs
|
C#
|
bsd
| 1,473
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Linq;
using System.Web.Mvc;
using Lokad.Cloud.Console.WebRole.Framework.Discovery;
using Lokad.Cloud.Console.WebRole.Helpers;
using Lokad.Cloud.Console.WebRole.Models.Shared;
namespace Lokad.Cloud.Console.WebRole.Controllers.ObjectModel
{
public abstract class ApplicationController : Controller
{
private readonly NavigationModel _navigation;
private readonly DiscoveryModel _discovery;
protected AzureDiscoveryInfo DiscoveryInfo { get; private set; }
protected ApplicationController(AzureDiscoveryInfo discoveryInfo)
{
DiscoveryInfo = discoveryInfo;
ViewBag.Discovery = _discovery = new DiscoveryModel
{
IsAvailable = discoveryInfo.IsAvailable,
ShowLastDiscoveryUpdate = discoveryInfo.IsAvailable,
LastDiscoveryUpdate = (DateTimeOffset.UtcNow - discoveryInfo.Timestamp).PrettyFormat() + " (" + Math.Round((discoveryInfo.FinishedTimestamp - discoveryInfo.Timestamp).TotalSeconds,1) + "s)"
};
var controllerName = GetType().Name;
ViewBag.Navigation = _navigation = new NavigationModel
{
ShowDeploymentSelector = discoveryInfo.IsAvailable,
HostedServiceNames = discoveryInfo.LokadCloudDeployments.Select(d => d.ServiceName).ToArray(),
CurrentController = controllerName.Substring(0, controllerName.Length - 10),
ControllerAction = discoveryInfo.IsAvailable ? "ByHostedService" : "Index"
};
}
protected bool ShowWaitingForDiscoveryInsteadOfContent
{
get { return !_discovery.IsAvailable; }
set { _discovery.IsAvailable = !value; }
}
protected string CurrentHostedService
{
get { return _navigation.CurrentHostedServiceName; }
set
{
_navigation.CurrentHostedServiceName = value;
ViewBag.TenantPath = String.Format("/{0}/{1}", _navigation.CurrentController, value);
}
}
protected void HideDiscovery()
{
_navigation.ShowDeploymentSelector = false;
_navigation.ControllerAction = "Index";
_discovery.ShowLastDiscoveryUpdate = false;
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Controllers/ObjectModel/ApplicationController.cs
|
C#
|
bsd
| 2,604
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Web.Mvc;
using Lokad.Cloud.Console.WebRole.Behavior;
using Lokad.Cloud.Console.WebRole.Controllers.ObjectModel;
using Lokad.Cloud.Console.WebRole.Framework.Discovery;
using Lokad.Cloud.Console.WebRole.Models.Scheduler;
using Lokad.Cloud.Management;
namespace Lokad.Cloud.Console.WebRole.Controllers
{
[RequireAuthorization, RequireDiscovery]
public sealed class SchedulerController : TenantController
{
public SchedulerController(AzureDiscoveryInfo discoveryInfo)
: base(discoveryInfo)
{
}
[HttpGet]
public override ActionResult ByHostedService(string hostedServiceName)
{
InitializeDeploymentTenant(hostedServiceName);
var cloudServiceScheduling = new CloudServiceScheduling(Providers);
return View(new SchedulerModel
{
Schedules = cloudServiceScheduling.GetSchedules().ToArray()
});
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Controllers/SchedulerController.cs
|
C#
|
bsd
| 1,162
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Web.Mvc;
using Lokad.Cloud.Console.WebRole.Behavior;
using Lokad.Cloud.Console.WebRole.Controllers.ObjectModel;
using Lokad.Cloud.Console.WebRole.Framework.Discovery;
using Lokad.Cloud.Console.WebRole.Framework.Services;
using Lokad.Cloud.Management;
namespace Lokad.Cloud.Console.WebRole.Controllers
{
[RequireAuthorization, RequireDiscovery]
public sealed class ServicesController : TenantController
{
public ServicesController(AzureDiscoveryInfo discoveryInfo)
: base(discoveryInfo)
{
}
[HttpGet]
public override ActionResult ByHostedService(string hostedServiceName)
{
InitializeDeploymentTenant(hostedServiceName);
var provider = new AppDefinitionWithLiveDataProvider(Providers);
return View(provider.QueryServices());
}
[HttpPut]
public ActionResult Status(string hostedServiceName, string id, bool isStarted)
{
InitializeDeploymentTenant(hostedServiceName);
var cloudServices = new CloudServices(Providers);
if (isStarted)
{
cloudServices.EnableService(id);
}
else
{
cloudServices.DisableService(id);
}
return Json(new
{
serviceName = id,
isStarted,
});
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Console.WebRole/Controllers/ServicesController.cs
|
C#
|
bsd
| 1,650
|
#region (c)2009 Lokad - New BSD license
// Company: http://www.lokad.com
// This code is released under the terms of the new BSD licence
#endregion
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
[assembly : AssemblyCompany("Lokad")]
[assembly : AssemblyProduct("Lokad.Cloud")]
[assembly : AssemblyCulture("")]
[assembly : ComVisible(false)]
// .NET 2.0 security model
[assembly: SecurityRules(SecurityRuleSet.Level1)]
///<summary>
/// Assembly information class that is shared between all projects
///</summary>
internal static class GlobalAssemblyInfo
{
// copied from the Lokad.Client 'GlobalAssemblyInfo.cs'
internal const string PublicKey =
"00240000048000009400000006020000002400005253413100040000010001009df7" +
"e75ec7a084a12820d571ea9184386b479eb6e8dbf365106519bda8fc437cbf8e" +
"fb3ce06212ac89e61cd0caa534537575c638a189caa4ac7b831474ceca5a" +
"cf5018f2d4b41499044ce90e4f67bb0e8da4121882399b13aabaa6ff" +
"46b4c24d5ec6141104028e1b5199e2ba1e35ad95bd50c1cf6ec5" +
"c4e7b97c1d29c976e793";
}
|
zyyin2005-lokadclone
|
Source/GlobalAssemblyInfo.cs
|
C#
|
bsd
| 1,097
|
#region Copyright (c) Lokad 2009
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using Lokad.Cloud.ServiceFabric.Runtime;
using Microsoft.WindowsAzure.ServiceRuntime;
namespace Lokad.Cloud
{
/// <summary>Entry point of Lokad.Cloud.</summary>
public class WorkerRole : RoleEntryPoint
{
readonly ServiceFabricHost _serviceFabricHost;
public WorkerRole()
{
_serviceFabricHost = new ServiceFabricHost();
}
/// <summary>
/// Called by Windows Azure to initialize the role instance.
/// </summary>
/// <returns>
/// True if initialization succeeds, False if it fails. The default implementation returns True.
/// </returns>
/// <remarks>
/// <para>Any exception that occurs within the OnStart method is an unhandled exception.</para>
/// </remarks>
public override bool OnStart()
{
_serviceFabricHost.StartRuntime();
return true;
}
/// <summary>
/// Called by Windows Azure when the role instance is to be stopped.
/// </summary>
/// <remarks>
/// <para>
/// Override the OnStop method to implement any code your role requires to
/// shut down in an orderly fashion.
/// </para>
/// <para>
/// This method must return within certain period of time. If it does not,
/// Windows Azure will stop the role instance.
/// </para>
/// <para>
/// A web role can include shutdown sequence code in the ASP.NET
/// Application_End method instead of the OnStop method. Application_End is
/// called before the Stopping event is raised or the OnStop method is called.
/// </para>
/// <para>
/// Any exception that occurs within the OnStop method is an unhandled
/// exception.
/// </para>
/// </remarks>
public override void OnStop()
{
_serviceFabricHost.ShutdownRuntime();
}
/// <summary>
/// Called by Windows Azure after the role instance has been initialized. This
/// method serves as the main thread of execution for your role.
/// </summary>
/// <remarks>
/// <para>The role recycles when the Run method returns.</para>
/// <para>Any exception that occurs within the Run method is an unhandled exception.</para>
/// </remarks>
public override void Run()
{
_serviceFabricHost.Run();
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.WorkerRole/WorkerRole.cs
|
C#
|
bsd
| 2,343
|
#region Copyright (c) Lokad 2009
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Lokad.Cloud.WorkerRole")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyCopyright("Copyright © Lokad 2009")]
[assembly: AssemblyTrademark("")]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("6d6757ec-a849-4cb5-bdbb-17707b7129a5")]
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.WorkerRole/Properties/AssemblyInfo.cs
|
C#
|
bsd
| 773
|
#region Copyright (c) Lokad 2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using Autofac;
using Autofac.Builder;
using Autofac.Configuration;
namespace Lokad.Cloud
{
/// <summary>
/// Provider factory for standalone use of the cloud storage toolkit (O/C mapping)
/// (if not hosted as worker services in the ServiceFabric).
/// </summary>
public static class Standalone
{
/// <summary>
/// Create standalone infrastructure providers using the specified settings.
/// </summary>
public static CloudInfrastructureProviders CreateProviders(ICloudConfigurationSettings settings)
{
var builder = new ContainerBuilder();
builder.RegisterModule(new CloudModule());
builder.RegisterModule(new CloudConfigurationModule(settings));
using (var container = builder.Build())
{
return container.Resolve<CloudInfrastructureProviders>();
}
}
/// <summary>
/// Create standalone infrastructure providers using the specified settings.
/// </summary>
public static CloudInfrastructureProviders CreateProviders(string dataConnectionString)
{
return CreateProviders(new RoleConfigurationSettings
{
DataConnectionString = dataConnectionString
});
}
/// <summary>
/// Create standalone infrastructure providers using an IoC module configuration
/// in the local config file in the specified config section.
/// </summary>
public static CloudInfrastructureProviders CreateProvidersFromConfiguration(string configurationSectionName)
{
var builder = new ContainerBuilder();
builder.RegisterModule(new CloudModule());
builder.RegisterModule(new ConfigurationSettingsReader(configurationSectionName));
using (var container = builder.Build())
{
return container.Resolve<CloudInfrastructureProviders>();
}
}
/// <summary>
/// Create standalone mock infrastructure providers.
/// </summary>
/// <returns></returns>
public static CloudInfrastructureProviders CreateMockProviders()
{
var builder = new ContainerBuilder();
builder.RegisterModule(new CloudModule());
builder.RegisterModule(new Mock.MockStorageModule());
using (var container = builder.Build())
{
return container.Resolve<CloudInfrastructureProviders>();
}
}
/// <summary>
/// Create standalone infrastructure providers bound to the local development storage.
/// </summary>
public static CloudInfrastructureProviders CreateDevelopmentStorageProviders()
{
return CreateProviders("UseDevelopmentStorage=true");
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Standalone.cs
|
C#
|
bsd
| 2,663
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using Lokad.Cloud.Diagnostics;
using Lokad.Cloud.Storage;
namespace Lokad.Cloud.Runtime
{
public static class CloudStorageExtensions
{
public static RuntimeProviders BuildRuntimeProviders(this CloudStorage.CloudStorageBuilder builder)
{
var formatter = new CloudFormatter();
var diagnosticsStorage = builder
.WithLog(null)
.WithDataSerializer(formatter)
.BuildBlobStorage();
var providers = builder
.WithLog(new CloudLogger(diagnosticsStorage, string.Empty))
.WithDataSerializer(formatter)
.BuildStorageProviders();
return new RuntimeProviders(
providers.BlobStorage,
providers.QueueStorage,
providers.TableStorage,
providers.RuntimeFinalizer,
providers.Log);
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Runtime/CloudStorageExtensions.cs
|
C#
|
bsd
| 1,113
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using Lokad.Cloud.Storage;
namespace Lokad.Cloud.Runtime
{
/// <remarks>
/// The purpose of having a separate class mirroring CloudStorageProviders
/// just for runtime classes is to make it easier to distinct them and avoid
/// mixing them up (also simplifying IoC on the way), since they have a different
/// purpose and are likely configured slightly different. E.g. Runtime Providers
/// have a fixed data serializer, while the application can choose it's serializer
/// for it's own application code.
/// </remarks>
public class RuntimeProviders
{
/// <summary>Abstracts the Blob Storage.</summary>
public IBlobStorageProvider BlobStorage { get; private set; }
/// <summary>Abstracts the Queue Storage.</summary>
public IQueueStorageProvider QueueStorage { get; private set; }
/// <summary>Abstracts the Table Storage.</summary>
public ITableStorageProvider TableStorage { get; private set; }
/// <summary>Abstracts the finalizer (used for fast resource release
/// in case of runtime shutdown).</summary>
public IRuntimeFinalizer RuntimeFinalizer { get; private set; }
public Storage.Shared.Logging.ILog Log { get; private set; }
/// <summary>IoC constructor.</summary>
public RuntimeProviders(
IBlobStorageProvider blobStorage,
IQueueStorageProvider queueStorage,
ITableStorageProvider tableStorage,
IRuntimeFinalizer runtimeFinalizer,
Storage.Shared.Logging.ILog log)
{
BlobStorage = blobStorage;
QueueStorage = queueStorage;
TableStorage = tableStorage;
RuntimeFinalizer = runtimeFinalizer;
Log = log;
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Runtime/RuntimeProviders.cs
|
C#
|
bsd
| 1,992
|
#region Copyright (c) Lokad 2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using Lokad.Cloud.Storage;
namespace Lokad.Cloud
{
[Serializable]
public class RoleConfigurationSettings : ICloudConfigurationSettings
{
public string DataConnectionString { get; set; }
public string SelfManagementSubscriptionId { get; set; }
public string SelfManagementCertificateThumbprint { get; set; }
public static Maybe<ICloudConfigurationSettings> LoadFromRoleEnvironment()
{
if (!CloudEnvironment.IsAvailable)
{
return Maybe<ICloudConfigurationSettings>.Empty;
}
var setting = new RoleConfigurationSettings();
ApplySettingFromRole("DataConnectionString", v => setting.DataConnectionString = v);
ApplySettingFromRole("SelfManagementSubscriptionId", v => setting.SelfManagementSubscriptionId = v);
ApplySettingFromRole("SelfManagementCertificateThumbprint", v => setting.SelfManagementCertificateThumbprint = v);
return setting;
}
static void ApplySettingFromRole(string setting, Action<string> setter)
{
CloudEnvironment.GetConfigurationSetting(setting).Apply(setter);
}
}
/// <summary>
/// Settings used among others by the <see cref="Lokad.Cloud.Storage.Azure.StorageModule" />.
/// </summary>
public interface ICloudConfigurationSettings
{
/// <summary>
/// Gets the data connection string.
/// </summary>
/// <value>The data connection string.</value>
string DataConnectionString { get; }
/// <summary>
/// Gets the Azure subscription Id to be used for self management (optional, can be null).
/// </summary>
string SelfManagementSubscriptionId { get; }
/// <summary>
/// Gets the Azure certificate thumbpring to be used for self management (optional, can be null).
/// </summary>
string SelfManagementCertificateThumbprint { get; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/RoleConfigurationSettings.cs
|
C#
|
bsd
| 1,955
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using Autofac;
using Autofac.Builder;
using Lokad.Cloud.Management.Api10;
namespace Lokad.Cloud.Management
{
/// <summary>
/// IoC module for Lokad.Cloud management classes.
/// </summary>
public class ManagementModule : Module
{
protected override void Load(ContainerBuilder builder)
{
builder.RegisterType<CloudConfiguration>().As<ICloudConfigurationApi>().InstancePerDependency();
builder.RegisterType<CloudAssemblies>().As<ICloudAssembliesApi>().InstancePerDependency();
builder.RegisterType<CloudServices>().As<ICloudServicesApi>().InstancePerDependency();
builder.RegisterType<CloudServiceScheduling>().As<ICloudServiceSchedulingApi>().InstancePerDependency();
builder.RegisterType<CloudStatistics>().As<ICloudStatisticsApi>().InstancePerDependency();
// in some cases (like standalone mock storage) the RoleConfigurationSettings
// will not be available. That's ok, since in this case Provisioning is not
// available anyway and there's no need to make Provisioning resolveable.
builder.Register(c => new CloudProvisioning(
c.Resolve<ICloudConfigurationSettings>(),
c.Resolve<Storage.Shared.Logging.ILog>()))
.As<CloudProvisioning, IProvisioningProvider, ICloudProvisioningApi>()
.SingleInstance();
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/ManagementModule.cs
|
C#
|
bsd
| 1,494
|
#region Copyright (c) Lokad 2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Web;
namespace Lokad.Cloud.Management.Api10
{
using Lokad.Cloud.Application;
[ServiceContract(Name = "CloudAssemblies", Namespace = "http://schemas.lokad.com/lokad-cloud/management/1.0")]
public interface ICloudAssembliesApi
{
[OperationContract]
[WebGet(UriTemplate = @"assemblies")]
List<CloudApplicationAssemblyInfo> GetAssemblies();
[OperationContract]
[WebInvoke(UriTemplate = @"upload/dll/{filename}", Method = "POST")]
void UploadAssemblyDll(byte[] data, string fileName);
[OperationContract]
[WebInvoke(UriTemplate = @"upload/zip", Method = "POST")]
void UploadAssemblyZipContainer(byte[] data);
[OperationContract]
[WebInvoke(UriTemplate = @"upload/zip/isvalid", Method = "POST")]
bool IsValidZipContainer(byte[] data);
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Api10/ICloudAssembliesApi.cs
|
C#
|
bsd
| 1,117
|
#region Copyright (c) Lokad 2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Web;
namespace Lokad.Cloud.Management.Api10
{
[ServiceContract(Name = "CloudServices", Namespace = "http://schemas.lokad.com/lokad-cloud/management/1.0")]
public interface ICloudServicesApi
{
[OperationContract]
[WebGet(UriTemplate = @"services")]
List<string> GetServiceNames();
[OperationContract]
[WebGet(UriTemplate = @"userservices")]
List<string> GetUserServiceNames();
[OperationContract]
[WebGet(UriTemplate = @"services/all")]
List<CloudServiceInfo> GetServices();
[OperationContract]
[WebGet(UriTemplate = @"services/{serviceName}")]
CloudServiceInfo GetService(string serviceName);
[OperationContract]
[WebInvoke(UriTemplate = @"services/{serviceName}/enable", Method = "POST")]
void EnableService(string serviceName);
[OperationContract]
[WebInvoke(UriTemplate = @"services/{serviceName}/disable", Method = "POST")]
void DisableService(string serviceName);
[OperationContract]
[WebInvoke(UriTemplate = @"services/{serviceName}/toggle", Method = "POST")]
void ToggleServiceState(string serviceName);
[OperationContract]
[WebInvoke(UriTemplate = @"services/{serviceName}/reset", Method = "POST")]
void ResetServiceState(string serviceName);
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Api10/ICloudServicesApi.cs
|
C#
|
bsd
| 1,492
|
#region Copyright (c) Lokad 2009-2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Api10
{
/// <summary>
/// Cloud Service Info
/// </summary>
[DataContract(Name = "CloudServiceInfo", Namespace = "http://schemas.lokad.com/lokad-cloud/management/1.0")]
public class CloudServiceInfo
{
/// <summary>Name of the service</summary>
[DataMember(Order = 0, IsRequired = true)]
public string ServiceName { get; set; }
/// <summary>Current state of the service</summary>
[DataMember(Order = 1)]
public bool IsStarted { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Api10/CloudServiceInfo.cs
|
C#
|
bsd
| 703
|
#region Copyright (c) Lokad 2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.ServiceModel;
using System.ServiceModel.Web;
namespace Lokad.Cloud.Management.Api10
{
[ServiceContract(Name = "CloudConfiguration", Namespace = "http://schemas.lokad.com/lokad-cloud/management/1.0")]
public interface ICloudConfigurationApi
{
[OperationContract]
[WebGet(UriTemplate = @"config")]
string GetConfigurationString();
[OperationContract]
[WebInvoke(UriTemplate = @"config", Method = "POST")]
void SetConfiguration(string configuration);
[OperationContract]
[WebInvoke(UriTemplate = @"remove", Method = "POST")]
void RemoveConfiguration();
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Api10/ICloudConfigurationApi.cs
|
C#
|
bsd
| 761
|
#region Copyright (c) Lokad 2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.ServiceModel;
using System.ServiceModel.Web;
namespace Lokad.Cloud.Management.Api10
{
[ServiceContract(Name = "CloudProvisioning", Namespace = "http://schemas.lokad.com/lokad-cloud/management/1.0")]
public interface ICloudProvisioningApi
{
[OperationContract]
[WebGet(UriTemplate = @"instances")]
int GetWorkerInstanceCount();
[OperationContract]
[WebInvoke(UriTemplate = @"instances/set?newcount={instanceCount}", Method = "POST")]
void SetWorkerInstanceCount(int instanceCount);
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Api10/ICloudProvisioningApi.cs
|
C#
|
bsd
| 681
|
#region Copyright (c) Lokad 2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Web;
using Lokad.Cloud.Diagnostics;
namespace Lokad.Cloud.Management.Api10
{
[ServiceContract(Name = "CloudStatistics", Namespace = "http://schemas.lokad.com/lokad-cloud/management/1.0")]
public interface ICloudStatisticsApi
{
[OperationContract]
[WebGet(UriTemplate = @"partitions/month?date={monthUtc}")]
List<PartitionStatistics> GetPartitionsOfMonth(DateTime? monthUtc);
[OperationContract]
[WebGet(UriTemplate = @"partitions/day?date={dayUtc}")]
List<PartitionStatistics> GetPartitionsOfDay(DateTime? dayUtc);
[OperationContract]
[WebGet(UriTemplate = @"services/month?date={monthUtc}")]
List<ServiceStatistics> GetServicesOfMonth(DateTime? monthUtc);
[OperationContract]
[WebGet(UriTemplate = @"services/day?date={dayUtc}")]
List<ServiceStatistics> GetServicesOfDay(DateTime? dayUtc);
[OperationContract]
[WebGet(UriTemplate = @"profiles/month?date={monthUtc}")]
List<ExecutionProfilingStatistics> GetProfilesOfMonth(DateTime? monthUtc);
[OperationContract]
[WebGet(UriTemplate = @"profiles/day?date={dayUtc}")]
List<ExecutionProfilingStatistics> GetProfilesOfDay(DateTime? dayUtc);
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Api10/ICloudStatisticsApi.cs
|
C#
|
bsd
| 1,422
|
#region Copyright (c) Lokad 2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Collections.Generic;
using System.ServiceModel;
using System.ServiceModel.Web;
namespace Lokad.Cloud.Management.Api10
{
[ServiceContract(Name = "CloudServiceScheduling", Namespace = "http://schemas.lokad.com/lokad-cloud/management/1.0")]
public interface ICloudServiceSchedulingApi
{
[OperationContract]
[WebGet(UriTemplate = @"services")]
List<string> GetScheduledServiceNames();
[OperationContract]
[WebGet(UriTemplate = @"userservices")]
List<string> GetScheduledUserServiceNames();
[OperationContract]
[WebGet(UriTemplate = @"services/all")]
List<CloudServiceSchedulingInfo> GetSchedules();
[OperationContract]
[WebGet(UriTemplate = @"services/{serviceName}")]
CloudServiceSchedulingInfo GetSchedule(string serviceName);
[OperationContract]
[WebInvoke(UriTemplate = @"services/{serviceName}/interval?timespan={triggerInterval}", Method = "POST")]
void SetTriggerInterval(string serviceName, TimeSpan triggerInterval);
[OperationContract]
[WebInvoke(UriTemplate = @"services/{serviceName}/reset", Method = "POST")]
void ResetSchedule(string serviceName);
[OperationContract]
[WebInvoke(UriTemplate = @"services/{serviceName}/release", Method = "POST")]
void ReleaseLease(string serviceName);
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Api10/ICloudServiceSchedulingApi.cs
|
C#
|
bsd
| 1,466
|
#region Copyright (c) Lokad 2009-2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Api10
{
/// <summary>
/// Cloud Assembly Info
/// </summary>
[DataContract(Name = "CloudAssemblyInfo", Namespace = "http://schemas.lokad.com/lokad-cloud/management/1.0")]
public class CloudAssemblyInfo
{
/// <summary>Name of the cloud assembly.</summary>
[DataMember(Order = 0, IsRequired = true)]
public string AssemblyName { get; set; }
/// <summary>Time stamp of the cloud assembly.</summary>
[DataMember(Order = 1)]
public DateTime DateTime { get; set; }
/// <summary>Version of the cloud assembly.</summary>
[DataMember(Order = 2)]
public Version Version { get; set; }
/// <summary>File size of the cloud assembly, in bytes.</summary>
[DataMember(Order = 3)]
public long SizeBytes { get; set; }
/// <summary>Assembly can be loaded successfully.</summary>
[DataMember(Order = 4)]
public bool IsValid { get; set; }
/// <summary>Assembly symbol store (PDB file) is available.</summary>
[DataMember(Order = 5)]
public bool HasSymbols { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Api10/CloudAssemblyInfo.cs
|
C#
|
bsd
| 1,272
|
#region Copyright (c) Lokad 2009-2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Runtime.Serialization;
using Lokad.Cloud.Storage;
namespace Lokad.Cloud.Management.Api10
{
/// <summary>
/// Cloud Service Scheduling Info
/// </summary>
[DataContract(Name = "CloudServiceSchedulingInfo", Namespace = "http://schemas.lokad.com/lokad-cloud/management/1.0")]
public class CloudServiceSchedulingInfo
{
/// <summary>Name of the service.</summary>
[DataMember(Order = 0, IsRequired = true)]
public string ServiceName { get; set; }
/// <summary>Scheduled trigger interval.</summary>
[DataMember(Order = 1, IsRequired = true)]
public TimeSpan TriggerInterval { get; set; }
/// <summary>Last execution time stamp.</summary>
[DataMember(Order = 3, IsRequired = false)]
public DateTimeOffset LastExecuted { get; set; }
/// <summary>True if the services is worker scoped instead of cloud scoped.</summary>
[DataMember(Order = 2, IsRequired = false, EmitDefaultValue = false)]
public bool WorkerScoped { get; set; }
/// <summary>Owner of the lease.</summary>
[DataMember(Order = 4, IsRequired = false)]
public Maybe<string> LeasedBy { get; set; }
/// <summary>Point of time when the lease was acquired.</summary>
[DataMember(Order = 5, IsRequired = false)]
public Maybe<DateTimeOffset> LeasedSince { get; set; }
/// <summary>Point of time when the lease will timeout.</summary>
[DataMember(Order = 6, IsRequired = false)]
public Maybe<DateTimeOffset> LeasedUntil { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Api10/CloudServiceSchedulingInfo.cs
|
C#
|
bsd
| 1,660
|
#region Copyright (c) Lokad 2009-2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Text;
using Lokad.Cloud.Management.Api10;
using Lokad.Cloud.Runtime;
using Lokad.Cloud.ServiceFabric.Runtime;
using Lokad.Cloud.Storage;
namespace Lokad.Cloud.Management
{
/// <summary>
/// Management facade for cloud configuration.
/// </summary>
public class CloudConfiguration : ICloudConfigurationApi
{
readonly IBlobStorageProvider _blobProvider;
readonly UTF8Encoding _encoding = new UTF8Encoding();
/// <summary>
/// Initializes a new instance of the <see cref="CloudConfiguration"/> class.
/// </summary>
public CloudConfiguration(RuntimeProviders runtimeProviders)
{
_blobProvider = runtimeProviders.BlobStorage;
}
/// <summary>
/// Get the cloud configuration file.
/// </summary>
public string GetConfigurationString()
{
var buffer = _blobProvider.GetBlob<byte[]>(
AssemblyLoader.ContainerName,
AssemblyLoader.ConfigurationBlobName);
return buffer.Convert(bytes => _encoding.GetString(bytes), String.Empty);
}
/// <summary>
/// Set or update the cloud configuration file.
/// </summary>
public void SetConfiguration(string configuration)
{
if(configuration == null)
{
RemoveConfiguration();
return;
}
configuration = configuration.Trim();
if(String.IsNullOrEmpty(configuration))
{
RemoveConfiguration();
return;
}
_blobProvider.PutBlob(
AssemblyLoader.ContainerName,
AssemblyLoader.ConfigurationBlobName,
_encoding.GetBytes(configuration));
}
/// <summary>
/// Remove the cloud configuration file.
/// </summary>
public void RemoveConfiguration()
{
_blobProvider.DeleteBlobIfExist(
AssemblyLoader.ContainerName,
AssemblyLoader.ConfigurationBlobName);
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/CloudConfiguration.cs
|
C#
|
bsd
| 2,380
|
#region Copyright (c) Lokad 2009-2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Collections.Generic;
using System.Linq;
using Lokad.Cloud.Diagnostics;
using Lokad.Cloud.Management.Api10;
namespace Lokad.Cloud.Management
{
/// <summary>Management facade for cloud configuration.</summary>
public class CloudStatistics : ICloudStatisticsApi
{
readonly ICloudDiagnosticsRepository _repository;
/// <summary>
/// Initializes a new instance of the <see cref="CloudStatistics"/> class.
/// </summary>
public CloudStatistics(ICloudDiagnosticsRepository diagnosticsRepository)
{
_repository = diagnosticsRepository;
}
/// <summary>Get the statistics of all cloud partitions on the provided month.</summary>
public List<PartitionStatistics> GetPartitionsOfMonth(DateTime? monthUtc)
{
return _repository.GetAllPartitionStatistics(TimeSegments.For(TimeSegmentPeriod.Month, new DateTimeOffset(monthUtc ?? DateTime.UtcNow, TimeSpan.Zero))).ToList();
}
/// <summary>Get the statistics of all cloud partitions on the provided day.</summary>
public List<PartitionStatistics> GetPartitionsOfDay(DateTime? dayUtc)
{
return _repository.GetAllPartitionStatistics(TimeSegments.For(TimeSegmentPeriod.Day, new DateTimeOffset(dayUtc ?? DateTime.UtcNow, TimeSpan.Zero))).ToList();
}
/// <summary>Get the statistics of all cloud services on the provided month.</summary>
public List<ServiceStatistics> GetServicesOfMonth(DateTime? monthUtc)
{
return _repository.GetAllServiceStatistics(TimeSegments.For(TimeSegmentPeriod.Month, new DateTimeOffset(monthUtc ?? DateTime.UtcNow, TimeSpan.Zero))).ToList();
}
/// <summary>Get the statistics of all cloud services on the provided day.</summary>
public List<ServiceStatistics> GetServicesOfDay(DateTime? dayUtc)
{
return _repository.GetAllServiceStatistics(TimeSegments.For(TimeSegmentPeriod.Day, new DateTimeOffset(dayUtc ?? DateTime.UtcNow, TimeSpan.Zero))).ToList();
}
/// <summary>Get the statistics of all execution profiles on the provided month.</summary>
public List<ExecutionProfilingStatistics> GetProfilesOfMonth(DateTime? monthUtc)
{
return _repository.GetExecutionProfilingStatistics(TimeSegments.For(TimeSegmentPeriod.Month, new DateTimeOffset(monthUtc ?? DateTime.UtcNow, TimeSpan.Zero))).ToList();
}
/// <summary>Get the statistics of all execution profiles on the provided day.</summary>
public List<ExecutionProfilingStatistics> GetProfilesOfDay(DateTime? dayUtc)
{
return _repository.GetExecutionProfilingStatistics(TimeSegments.For(TimeSegmentPeriod.Day, new DateTimeOffset(dayUtc ?? DateTime.UtcNow, TimeSpan.Zero))).ToList();
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/CloudStatistics.cs
|
C#
|
bsd
| 2,820
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Linq;
using System.Collections.Generic;
using Lokad.Cloud.Management.Api10;
using Lokad.Cloud.Runtime;
using Lokad.Cloud.ServiceFabric;
using Lokad.Cloud.Services;
using Lokad.Cloud.Storage;
// TODO: blobs are sequentially enumerated, performance issue
// if there are more than a few dozen services
namespace Lokad.Cloud.Management
{
/// <summary>Management facade for scheduled cloud services.</summary>
public class CloudServiceScheduling : ICloudServiceSchedulingApi
{
readonly IBlobStorageProvider _blobProvider;
/// <summary>
/// Initializes a new instance of the <see cref="CloudServiceScheduling"/> class.
/// </summary>
public CloudServiceScheduling(RuntimeProviders runtimeProviders)
{
_blobProvider = runtimeProviders.BlobStorage;
}
/// <summary>
/// Enumerate infos of all cloud service schedules.
/// </summary>
public List<CloudServiceSchedulingInfo> GetSchedules()
{
// TODO: Redesign to make it self-contained (so that we don't need to pass the name as well)
return _blobProvider.ListBlobNames(ScheduledServiceStateName.GetPrefix())
.Select(name => System.Tuple.Create(name, _blobProvider.GetBlob(name)))
.Where(pair => pair.Item2.HasValue)
.Select(pair =>
{
var state = pair.Item2.Value;
var info = new CloudServiceSchedulingInfo
{
ServiceName = pair.Item1.ServiceName,
TriggerInterval = state.TriggerInterval,
LastExecuted = state.LastExecuted,
WorkerScoped = state.SchedulePerWorker,
LeasedBy = Maybe<string>.Empty,
LeasedSince = Maybe<DateTimeOffset>.Empty,
LeasedUntil = Maybe<DateTimeOffset>.Empty
};
if (state.Lease != null)
{
info.LeasedBy = state.Lease.Owner;
info.LeasedSince = state.Lease.Acquired;
info.LeasedUntil = state.Lease.Timeout;
}
return info;
})
.ToList();
}
/// <summary>
/// Gets infos of one cloud service schedule.
/// </summary>
public CloudServiceSchedulingInfo GetSchedule(string serviceName)
{
var blob = _blobProvider.GetBlob(new ScheduledServiceStateName(serviceName));
var state = blob.Value;
var info = new CloudServiceSchedulingInfo
{
ServiceName = serviceName,
TriggerInterval = state.TriggerInterval,
LastExecuted = state.LastExecuted,
WorkerScoped = state.SchedulePerWorker,
LeasedBy = Maybe<string>.Empty,
LeasedSince = Maybe<DateTimeOffset>.Empty,
LeasedUntil = Maybe<DateTimeOffset>.Empty
};
if (state.Lease != null)
{
info.LeasedBy = state.Lease.Owner;
info.LeasedSince = state.Lease.Acquired;
info.LeasedUntil = state.Lease.Timeout;
}
return info;
}
/// <summary>
/// Enumerate the names of all scheduled cloud service.
/// </summary>
public List<string> GetScheduledServiceNames()
{
return _blobProvider.ListBlobNames(ScheduledServiceStateName.GetPrefix())
.Select(reference => reference.ServiceName).ToList();
}
/// <summary>
/// Enumerate the names of all scheduled user cloud service (system services are skipped).
/// </summary>
public List<string> GetScheduledUserServiceNames()
{
var systemServices =
new[]
{
typeof(GarbageCollectorService),
typeof(DelayedQueueService),
typeof(MonitoringService),
typeof(MonitoringDataRetentionService),
typeof(AssemblyConfigurationUpdateService)
}
.Select(type => type.FullName)
.ToList();
return GetScheduledServiceNames()
.Where(service => !systemServices.Contains(service)).ToList();
}
/// <summary>
/// Set the trigger interval of a cloud service.
/// </summary>
public void SetTriggerInterval(string serviceName, TimeSpan triggerInterval)
{
_blobProvider.UpdateBlobIfExist(
new ScheduledServiceStateName(serviceName),
state =>
{
state.TriggerInterval = triggerInterval;
return state;
});
}
/// <summary>
/// Remove the scheduling information of a cloud service
/// </summary>
public void ResetSchedule(string serviceName)
{
_blobProvider.DeleteBlobIfExist(new ScheduledServiceStateName(serviceName));
}
/// <summary>
/// Forcibly remove the synchronization lease of a periodic cloud service
/// </summary>
public void ReleaseLease(string serviceName)
{
_blobProvider.UpdateBlobIfExist(
new ScheduledServiceStateName(serviceName),
state =>
{
state.Lease = null;
return state;
});
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/CloudServiceScheduling.cs
|
C#
|
bsd
| 6,231
|
#region Copyright (c) Lokad 2009-2011
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Collections.Generic;
using System.Linq;
using Lokad.Cloud.Management.Api10;
using Lokad.Cloud.Runtime;
using Lokad.Cloud.ServiceFabric;
using Lokad.Cloud.Services;
using Lokad.Cloud.Storage;
// TODO: blobs are sequentially enumerated, performance issue
// if there are more than a few dozen services
namespace Lokad.Cloud.Management
{
/// <summary>Management facade for cloud services.</summary>
public class CloudServices : ICloudServicesApi
{
readonly IBlobStorageProvider _blobProvider;
/// <summary>
/// Initializes a new instance of the <see cref="CloudServices"/> class.
/// </summary>
public CloudServices(RuntimeProviders runtimeProviders)
{
_blobProvider = runtimeProviders.BlobStorage;
}
/// <summary>
/// Enumerate infos of all cloud services.
/// </summary>
public List<CloudServiceInfo> GetServices()
{
// TODO: Redesign to make it self-contained (so that we don't need to pass the name as well)
return _blobProvider.ListBlobNames(CloudServiceStateName.GetPrefix())
.Select(name => System.Tuple.Create(name, _blobProvider.GetBlob(name)))
.Where(pair => pair.Item2.HasValue)
.Select(pair => new CloudServiceInfo
{
ServiceName = pair.Item1.ServiceName,
IsStarted = pair.Item2.Value == CloudServiceState.Started
})
.ToList();
}
/// <summary>
/// Gets info of one cloud service.
/// </summary>
public CloudServiceInfo GetService(string serviceName)
{
var blob = _blobProvider.GetBlob(new CloudServiceStateName(serviceName));
return new CloudServiceInfo
{
ServiceName = serviceName,
IsStarted = blob.Value == CloudServiceState.Started
};
}
/// <summary>
/// Enumerate the names of all cloud services.
/// </summary>
public List<string> GetServiceNames()
{
return _blobProvider.ListBlobNames(CloudServiceStateName.GetPrefix())
.Select(reference => reference.ServiceName).ToList();
}
/// <summary>
/// Enumerate the names of all user cloud services (system services are skipped).
/// </summary>
public List<string> GetUserServiceNames()
{
var systemServices =
new[]
{
typeof(GarbageCollectorService),
typeof(DelayedQueueService),
typeof(MonitoringService),
typeof(MonitoringDataRetentionService),
typeof(AssemblyConfigurationUpdateService)
}
.Select(type => type.FullName)
.ToList();
return GetServiceNames()
.Where(service => !systemServices.Contains(service)).ToList();
}
/// <summary>
/// Enable a cloud service
/// </summary>
public void EnableService(string serviceName)
{
_blobProvider.PutBlob(new CloudServiceStateName(serviceName), CloudServiceState.Started);
}
/// <summary>
/// Disable a cloud service
/// </summary>
public void DisableService(string serviceName)
{
_blobProvider.PutBlob(new CloudServiceStateName(serviceName), CloudServiceState.Stopped);
}
/// <summary>
/// Toggle the state of a cloud service
/// </summary>
public void ToggleServiceState(string serviceName)
{
_blobProvider.UpsertBlob(
new CloudServiceStateName(serviceName),
() => CloudServiceState.Started,
state => state == CloudServiceState.Started ? CloudServiceState.Stopped : CloudServiceState.Started);
}
/// <summary>
/// Remove the state information of a cloud service
/// </summary>
public void ResetServiceState(string serviceName)
{
_blobProvider.DeleteBlobIfExist(new CloudServiceStateName(serviceName));
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/CloudServices.cs
|
C#
|
bsd
| 4,633
|
#region Copyright (c) Lokad 2009-2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ICSharpCode.SharpZipLib.Zip;
using Lokad.Cloud.Application;
using Lokad.Cloud.Management.Api10;
using Lokad.Cloud.Runtime;
using Lokad.Cloud.ServiceFabric.Runtime;
using Lokad.Cloud.Storage;
namespace Lokad.Cloud.Management
{
/// <summary>Management facade for cloud assemblies.</summary>
public class CloudAssemblies : ICloudAssembliesApi
{
readonly RuntimeProviders _runtimeProviders;
/// <summary>
/// Initializes a new instance of the <see cref="CloudAssemblies"/> class.
/// </summary>
public CloudAssemblies(RuntimeProviders runtimeProviders)
{
_runtimeProviders = runtimeProviders;
}
public Maybe<CloudApplicationDefinition> GetApplicationDefinition()
{
var inspector = new CloudApplicationInspector(_runtimeProviders);
return inspector.Inspect();
}
/// <summary>
/// Enumerate infos of all configured cloud service assemblies.
/// </summary>
public List<CloudApplicationAssemblyInfo> GetAssemblies()
{
var maybe = GetApplicationDefinition();
if(maybe.HasValue)
{
return maybe.Value.Assemblies.ToList();
}
// empty list
return new List<CloudApplicationAssemblyInfo>();
}
/// <summary>
/// Configure a .dll assembly file as the new cloud service assembly.
/// </summary>
public void UploadAssemblyDll(byte[] data, string fileName)
{
using (var tempStream = new MemoryStream())
{
using (var zip = new ZipOutputStream(tempStream))
{
zip.PutNextEntry(new ZipEntry(fileName));
zip.Write(data, 0, data.Length);
zip.CloseEntry();
}
UploadAssemblyZipContainer(tempStream.ToArray());
}
}
/// <summary>
/// Configure a zip container with one or more assemblies as the new cloud services.
/// </summary>
public void UploadAssemblyZipContainer(byte[] data)
{
_runtimeProviders.BlobStorage.PutBlob(
AssemblyLoader.ContainerName,
AssemblyLoader.PackageBlobName,
data,
true);
}
/// <summary>
/// Verify whether the provided zip container is valid.
/// </summary>
public bool IsValidZipContainer(byte[] data)
{
try
{
using (var dataStream = new MemoryStream(data))
using (var zipStream = new ZipInputStream(dataStream))
{
ZipEntry entry;
while ((entry = zipStream.GetNextEntry()) != null)
{
var buffer = new byte[entry.Size];
zipStream.Read(buffer, 0, buffer.Length);
}
}
return true;
}
catch
{
return false;
}
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/CloudAssemblies.cs
|
C#
|
bsd
| 3,494
|
#region Copyright (c) Lokad 2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using Lokad.Cloud.Storage;
namespace Lokad.Cloud.Management
{
/// <summary>Defines an interface to auto-scale your cloud app.</summary>
/// <remarks>The implementation relies on the Management API on Windows Azure.</remarks>
public interface IProvisioningProvider
{
/// <summary>Indicates where the provider is correctly setup.</summary>
bool IsAvailable { get; }
/// <summary>Defines the number of regular VM instances to get allocated
/// for the cloud app.</summary>
/// <param name="count"></param>
void SetWorkerInstanceCount(int count);
/// <summary>Indicates the number of VM instances currently allocated
/// for the cloud app.</summary>
/// <remarks>If <see cref="IsAvailable"/> is <c>false</c> this method
/// will be returning a <c>null</c> value.</remarks>
Maybe<int> GetWorkerInstanceCount();
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/IProvisioningProvider.cs
|
C#
|
bsd
| 1,010
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Azure.InputParameters
{
[DataContract(Name = "CertificateFile", Namespace = ApiConstants.XmlNamespace)]
public class CertificateFileInput : IExtensibleDataObject
{
[DataMember(Order = 1)]
public string Data { get; set; }
[DataMember(Order = 2)]
public string CertificateFormat { get; set; }
[DataMember(Order = 3)]
public string Password { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/InputParameters/CertificateFileInput.cs
|
C#
|
bsd
| 1,237
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Azure.InputParameters
{
[DataContract(Name = "RegenerateKeys", Namespace = ApiConstants.XmlNamespace)]
public class RegenerateKeysInput : IExtensibleDataObject
{
[DataMember(Order = 1)]
public KeyType KeyType { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
public enum KeyType
{
Primary,
Secondary,
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/InputParameters/RegenerateKeysInput.cs
|
C#
|
bsd
| 1,150
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System;
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Azure.InputParameters
{
[DataContract(Name = "CreateDeployment", Namespace = ApiConstants.XmlNamespace)]
public class CreateDeploymentInput : IExtensibleDataObject
{
[DataMember(Order = 1)]
public string Name { get; set; }
[DataMember(Order = 2)]
public Uri PackageUrl { get; set; }
[DataMember(Order = 3)]
public string Label { get; set; }
[DataMember(Order = 4)]
public string Configuration { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/InputParameters/CreateDeploymentInput.cs
|
C#
|
bsd
| 1,315
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System.Runtime.Serialization;
using Lokad.Cloud.Management.Azure.Entities;
namespace Lokad.Cloud.Management.Azure.InputParameters
{
[DataContract(Name = "UpdateDeploymentStatus", Namespace = ApiConstants.XmlNamespace)]
public class UpdateDeploymentStatusInput : IExtensibleDataObject
{
[DataMember(Order = 1)]
public DeploymentStatus Status { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/InputParameters/UpdateDeploymentStatusInput.cs
|
C#
|
bsd
| 1,162
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Azure.InputParameters
{
[DataContract(Name = "Swap", Namespace = ApiConstants.XmlNamespace)]
public class SwapDeploymentInput : IExtensibleDataObject
{
[DataMember(Order = 1)]
public string Production { get; set; }
[DataMember(Order = 2)]
public string SourceDeployment { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/InputParameters/SwapDeploymentInput.cs
|
C#
|
bsd
| 1,161
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System;
using System.Runtime.Serialization;
using Lokad.Cloud.Management.Azure.Entities;
namespace Lokad.Cloud.Management.Azure.InputParameters
{
[DataContract(Name = "UpgradeDeployment", Namespace = ApiConstants.XmlNamespace)]
public class UpgradeDeploymentInput : IExtensibleDataObject
{
[DataMember(Order = 1)]
public UpgradeMode Mode { get; set; }
[DataMember(Order = 2)]
public Uri PackageUrl { get; set; }
[DataMember(Order = 3)]
public string Configuration { get; set; }
[DataMember(Order = 4)]
public string Label { get; set; }
[DataMember(Order = 5)]
public string RoleToUpgrade { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/InputParameters/UpgradeDeploymentInput.cs
|
C#
|
bsd
| 1,442
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Azure.InputParameters
{
[DataContract(Name = "ChangeConfiguration", Namespace = ApiConstants.XmlNamespace)]
public class ChangeConfigurationInput : IExtensibleDataObject
{
[DataMember(Order = 1)]
public string Configuration { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/InputParameters/ChangeConfigurationInput.cs
|
C#
|
bsd
| 1,107
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Azure.InputParameters
{
[DataContract(Name = "WalkUpgradeDomain", Namespace = ApiConstants.XmlNamespace)]
public class WalkUpgradeDomainInput : IExtensibleDataObject
{
[DataMember(Order = 1)]
public int UpgradeDomain { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/InputParameters/WalkUpgradeDomainInput.cs
|
C#
|
bsd
| 1,100
|
#region Copyright (c) Lokad 2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using System.ServiceModel.Web;
// TODO: To be replaced with official REST client once available
namespace Lokad.Cloud.Management.Azure
{
public class ManagementClient : IDisposable
{
readonly X509Certificate2 _certificate;
readonly object _sync = new object();
WebChannelFactory<IAzureServiceManagement> _factory;
public ManagementClient(X509Certificate2 certificate)
{
if (certificate == null)
{
throw new ArgumentNullException("certificate");
}
_certificate = certificate;
}
public IAzureServiceManagement CreateChannel()
{
// long lock, but should in practice never be accessed
// from two threads anyway (just a safeguard) and this way
// we avoid multiple sync monitor enters per call
lock (_sync)
{
if (_factory != null)
{
switch (_factory.State)
{
case CommunicationState.Closed:
case CommunicationState.Closing:
// TODO: consider reusing the factory
_factory = null;
break;
case CommunicationState.Faulted:
_factory.Close();
_factory = null;
break;
}
}
if (_factory == null)
{
var binding = new WebHttpBinding(WebHttpSecurityMode.Transport);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;
_factory = new WebChannelFactory<IAzureServiceManagement>(binding, new Uri(ApiConstants.ServiceEndpoint));
_factory.Endpoint.Behaviors.Add(new ClientOutputMessageInspector());
_factory.Credentials.ClientCertificate.Certificate = _certificate;
}
return _factory.CreateChannel();
}
}
public void Dispose()
{
lock (_sync)
{
if (_factory == null)
{
return;
}
_factory.Close();
_factory = null;
}
}
public void CloseChannel(IAzureServiceManagement channel)
{
var clientChannel = channel as IClientChannel;
if (clientChannel != null)
{
clientChannel.Close();
clientChannel.Dispose();
}
}
private class ClientOutputMessageInspector : IClientMessageInspector, IEndpointBehavior
{
public void AfterReceiveReply(ref Message reply, object correlationState)
{
}
public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
var property = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name];
property.Headers.Add(ApiConstants.VersionHeaderName, ApiConstants.VersionHeaderContent);
return null;
}
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
{
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
clientRuntime.MessageInspectors.Add(this);
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
}
public void Validate(ServiceEndpoint endpoint)
{
}
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/ManagementClient.cs
|
C#
|
bsd
| 3,385
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
// TODO: To be replaced with official REST client once available
using Lokad.Cloud.Management.Azure.Entities;
using Lokad.Cloud.Management.Azure.InputParameters;
namespace Lokad.Cloud.Management.Azure
{
/// <summary>
/// Synchronous wrappers around the asynchronous web service channel.
/// </summary>
public static class SynchronousApiExtensionMethods
{
/// <summary>
/// Gets the result of an asynchronous operation.
/// </summary>
public static Operation GetOperationStatus(this IAzureServiceManagement proxy, string subscriptionId, string operationId)
{
return proxy.EndGetOperationStatus(proxy.BeginGetOperationStatus(subscriptionId, operationId, null, null));
}
/// <summary>
/// Swaps the deployment to a production slot.
/// </summary>
public static void SwapDeployment(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, SwapDeploymentInput input)
{
proxy.EndSwapDeployment(proxy.BeginSwapDeployment(subscriptionId, serviceName, input, null, null));
}
/// <summary>
/// Creates a deployment.
/// </summary>
public static void CreateOrUpdateDeployment(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string deploymentSlot, CreateDeploymentInput input)
{
proxy.EndCreateOrUpdateDeployment(proxy.BeginCreateOrUpdateDeployment(subscriptionId, serviceName, deploymentSlot, input, null, null));
}
/// <summary>
/// Deletes the specified deployment. This works against either through the deployment name.
/// </summary>
public static void DeleteDeployment(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string deploymentName)
{
proxy.EndDeleteDeployment(proxy.BeginDeleteDeployment(subscriptionId, serviceName, deploymentName, null, null));
}
/// <summary>
/// Deletes the specified deployment. This works against either through the slot name.
/// </summary>
public static void DeleteDeploymentBySlot(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string deploymentSlot)
{
proxy.EndDeleteDeploymentBySlot(proxy.BeginDeleteDeploymentBySlot(subscriptionId, serviceName, deploymentSlot, null, null));
}
/// <summary>
/// Gets the specified deployment details.
/// </summary>
public static Deployment GetDeployment(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string deploymentName)
{
return proxy.EndGetDeployment(proxy.BeginGetDeployment(subscriptionId, serviceName, deploymentName, null, null));
}
/// <summary>
/// Gets the specified deployment details.
/// </summary>
public static Deployment GetDeploymentBySlot(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string deploymentSlot)
{
return proxy.EndGetDeploymentBySlot(proxy.BeginGetDeploymentBySlot(subscriptionId, serviceName, deploymentSlot, null, null));
}
/// <summary>
/// Initiates a change to the deployment. This works against through the deployment name.
/// </summary>
public static void ChangeConfiguration(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string deploymentName, ChangeConfigurationInput input)
{
proxy.EndChangeConfiguration(proxy.BeginChangeConfiguration(subscriptionId, serviceName, deploymentName, input, null, null));
}
/// <summary>
/// Initiates a change to the deployment. This works against through the slot name.
/// </summary>
public static void ChangeConfigurationBySlot(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string deploymentSlot, ChangeConfigurationInput input)
{
proxy.EndChangeConfigurationBySlot(proxy.BeginChangeConfigurationBySlot(subscriptionId, serviceName, deploymentSlot, input, null, null));
}
/// <summary>
/// Initiates a change to the deployment. This works against through the deployment name.
/// </summary>
public static void UpdateDeploymentStatus(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string deploymentName, UpdateDeploymentStatusInput input)
{
proxy.EndUpdateDeploymentStatus(proxy.BeginUpdateDeploymentStatus(subscriptionId, serviceName, deploymentName, input, null, null));
}
/// <summary>
/// Initiates a change to the deployment. This works against through the slot name.
/// </summary>
public static void UpdateDeploymentStatusBySlot(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string deploymentSlot, UpdateDeploymentStatusInput input)
{
proxy.EndUpdateDeploymentStatusBySlot(proxy.BeginUpdateDeploymentStatusBySlot(subscriptionId, serviceName, deploymentSlot, input, null, null));
}
/// <summary>
/// Initiates an deployment upgrade.
/// </summary>
public static void UpgradeDeployment(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string deploymentName, UpgradeDeploymentInput input)
{
proxy.EndUpgradeDeployment(proxy.BeginUpgradeDeployment(subscriptionId, serviceName, deploymentName, input, null, null));
}
/// <summary>
/// Initiates an deployment upgrade through the slot name.
/// </summary>
public static void UpgradeDeploymentBySlot(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string deploymentSlot, UpgradeDeploymentInput input)
{
proxy.EndUpgradeDeploymentBySlot(proxy.BeginUpgradeDeploymentBySlot(subscriptionId, serviceName, deploymentSlot, input, null, null));
}
/// <summary>
/// Initiates an deployment upgrade.
/// </summary>
public static void WalkUpgradeDomain(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string deploymentName, WalkUpgradeDomainInput input)
{
proxy.EndWalkUpgradeDomain(proxy.BeginWalkUpgradeDomain(subscriptionId, serviceName, deploymentName, input, null, null));
}
/// <summary>
/// Initiates an deployment upgrade through the slot name.
/// </summary>
public static void WalkUpgradeDomainBySlot(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string deploymentSlot, WalkUpgradeDomainInput input)
{
proxy.EndWalkUpgradeDomainBySlot(proxy.BeginWalkUpgradeDomainBySlot(subscriptionId, serviceName, deploymentSlot, input, null, null));
}
/// <summary>
/// Lists the affinity groups associated with the specified subscription.
/// </summary>
public static AffinityGroupList ListAffinityGroups(this IAzureServiceManagement proxy, string subscriptionId)
{
return proxy.EndListAffinityGroups(proxy.BeginListAffinityGroups(subscriptionId, null, null));
}
/// <summary>
/// Get properties for the specified affinity group.
/// </summary>
public static AffinityGroup GetAffinityGroup(this IAzureServiceManagement proxy, string subscriptionId, string affinityGroupName)
{
return proxy.EndGetAffinityGroup(proxy.BeginGetAffinityGroup(subscriptionId, affinityGroupName, null, null));
}
/// <summary>
/// Lists the certificates associated with a given subscription.
/// </summary>
public static CertificateList ListCertificates(this IAzureServiceManagement proxy, string subscriptionId, string serviceName)
{
return proxy.EndListCertificates(proxy.BeginListCertificates(subscriptionId, serviceName, null, null));
}
/// <summary>
/// Gets public data for the given certificate.
/// </summary>
public static Certificate GetCertificate(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string algorithm, string thumbprint)
{
return proxy.EndGetCertificate(proxy.BeginGetCertificate(subscriptionId, serviceName, algorithm, thumbprint, null, null));
}
/// <summary>
/// Adds certificates to the given subscription.
/// </summary>
public static void AddCertificates(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, CertificateFileInput input)
{
proxy.EndAddCertificates(proxy.BeginAddCertificates(subscriptionId, serviceName, input, null, null));
}
/// <summary>
/// Deletes the given certificate.
/// </summary>
public static void DeleteCertificate(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, string algorithm, string thumbprint)
{
proxy.EndDeleteCertificate(proxy.BeginDeleteCertificate(subscriptionId, serviceName, algorithm, thumbprint, null, null));
}
/// <summary>
/// Lists the hosted services associated with a given subscription.
/// </summary>
public static HostedServiceList ListHostedServices(this IAzureServiceManagement proxy, string subscriptionId)
{
return proxy.EndListHostedServices(proxy.BeginListHostedServices(subscriptionId, null, null));
}
/// <summary>
/// Gets the properties for the specified hosted service.
/// </summary>
public static HostedService GetHostedService(this IAzureServiceManagement proxy, string subscriptionId, string serviceName)
{
return proxy.EndGetHostedService(proxy.BeginGetHostedService(subscriptionId, serviceName, null, null));
}
/// <summary>
/// Gets the detailed properties for the specified hosted service.
/// </summary>
public static HostedService GetHostedServiceWithDetails(this IAzureServiceManagement proxy, string subscriptionId, string serviceName, bool embedDetail)
{
return proxy.EndGetHostedServiceWithDetails(proxy.BeginGetHostedServiceWithDetails(subscriptionId, serviceName, embedDetail, null, null));
}
/// <summary>
/// Lists the storage services associated with a given subscription.
/// </summary>
public static StorageServiceList ListStorageServices(this IAzureServiceManagement proxy, string subscriptionId)
{
return proxy.EndListStorageServices(proxy.BeginListStorageServices(subscriptionId, null, null));
}
/// <summary>
/// Gets a storage service.
/// </summary>
public static StorageService GetStorageService(this IAzureServiceManagement proxy, string subscriptionId, string name)
{
return proxy.EndGetStorageService(proxy.BeginGetStorageService(subscriptionId, name, null, null));
}
/// <summary>
/// Gets the key of a storage service.
/// </summary>
public static StorageService GetStorageKeys(this IAzureServiceManagement proxy, string subscriptionId, string name)
{
return proxy.EndGetStorageKeys(proxy.BeginGetStorageKeys(subscriptionId, name, null, null));
}
/// <summary>
/// Regenerates keys associated with a storage service.
/// </summary>
public static StorageService RegenerateStorageServiceKeys(this IAzureServiceManagement proxy, string subscriptionId, string name, RegenerateKeysInput regenerateKeys)
{
return proxy.EndRegenerateStorageServiceKeys(proxy.BeginRegenerateStorageServiceKeys(subscriptionId, name, regenerateKeys, null, null));
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/ExtensionMethods.cs
|
C#
|
bsd
| 11,755
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Azure.Entities
{
/// <summary>
/// Affinity Group
/// </summary>
[DataContract(Namespace = ApiConstants.XmlNamespace)]
public class AffinityGroup : IExtensibleDataObject
{
[DataMember(Order = 1, EmitDefaultValue = false)]
public string Name { get; set; }
/// <remarks>Base64-Encoded</remarks>
[DataMember(Order = 2)]
public string Label { get; set; }
[DataMember(Order = 3)]
public string Description { get; set; }
[DataMember(Order = 4)]
public string Location { get; set; }
[DataMember(Order = 5, EmitDefaultValue = false)]
public HostedServiceList HostedServices { get; set; }
[DataMember(Order = 6, EmitDefaultValue = false)]
public StorageServiceList StorageServices { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
/// <summary>
/// List of affinity groups
/// </summary>
[CollectionDataContract(Name = "AffinityGroups", ItemName = "AffinityGroup", Namespace = ApiConstants.XmlNamespace)]
public class AffinityGroupList : List<AffinityGroup>
{
public AffinityGroupList()
{
}
public AffinityGroupList(IEnumerable<AffinityGroup> affinityGroups)
: base(affinityGroups)
{
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/Entities/AffinityGroup.cs
|
C#
|
bsd
| 2,036
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Azure.Entities
{
/// <summary>
/// Hosted Service
/// </summary>
[DataContract(Namespace = ApiConstants.XmlNamespace)]
public class HostedService : IExtensibleDataObject
{
[DataMember(Order = 1)]
public Uri Url { get; set; }
[DataMember(Order = 2, EmitDefaultValue = false)]
public string ServiceName { get; set; }
[DataMember(Order = 3, EmitDefaultValue = false)]
public HostedServiceProperties HostedServiceProperties { get; set; }
[DataMember(Order = 4, EmitDefaultValue = false)]
public DeploymentList Deployments { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
/// <summary>
/// Hosted Service Properties
/// </summary>
[DataContract(Namespace = ApiConstants.XmlNamespace)]
public class HostedServiceProperties : IExtensibleDataObject
{
[DataMember(Order = 1)]
public string Description { get; set; }
[DataMember(Order = 2, EmitDefaultValue = false)]
public string AffinityGroup { get; set; }
[DataMember(Order = 3, EmitDefaultValue = false)]
public string Location { get; set; }
/// <remarks>Base64-Encoded</remarks>
[DataMember(Order = 4)]
public string Label { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
/// <summary>
/// List of host services
/// </summary>
[CollectionDataContract(Name = "HostedServices", ItemName = "HostedService", Namespace = ApiConstants.XmlNamespace)]
public class HostedServiceList : List<HostedService>
{
public HostedServiceList()
{
}
public HostedServiceList(IEnumerable<HostedService> hostedServices)
: base(hostedServices)
{
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/Entities/HostedService.cs
|
C#
|
bsd
| 2,502
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Azure.Entities
{
/// <summary>
/// Role Instance
/// </summary>
[DataContract(Namespace = ApiConstants.XmlNamespace)]
public class RoleInstance
{
[DataMember(Order = 1)]
public string RoleName { get; set; }
[DataMember(Order = 2)]
public string InstanceName { get; set; }
[DataMember(Order = 3)]
public RoleInstanceStatus InstanceStatus { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
public enum RoleInstanceStatus
{
Initializing,
Ready,
Busy,
Stopping,
Stopped,
Unresponsive
}
/// <summary>
/// List of role instances
/// </summary>
[CollectionDataContract(Name = "RoleInstanceList", ItemName = "RoleInstance", Namespace = ApiConstants.XmlNamespace)]
public class RoleInstanceList : List<RoleInstance>
{
public RoleInstanceList()
{
}
public RoleInstanceList(IEnumerable<RoleInstance> roles)
: base(roles)
{
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/Entities/RoleInstance.cs
|
C#
|
bsd
| 1,771
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Azure.Entities
{
/// <summary>
/// Asynchronous Operation
/// </summary>
[DataContract(Namespace = ApiConstants.XmlNamespace)]
public class Operation : IExtensibleDataObject
{
[DataMember(Name = "ID", Order = 1)]
public string OperationTrackingId { get; set; }
[DataMember(Order = 2)]
public OperationStatus Status { get; set; }
[DataMember(Order = 3, EmitDefaultValue = false)]
public int HttpStatusCode { get; set; }
[DataMember(Order = 4, EmitDefaultValue = false)]
public OperationError Error { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
public enum OperationStatus
{
InProgress,
Succeeded,
Failed,
}
/// <summary>
/// Asynchronous Operation Error
/// </summary>
[DataContract(Name = "Error", Namespace = ApiConstants.XmlNamespace)]
public class OperationError : IExtensibleDataObject
{
[DataMember(Order = 1)]
public OperationErrorCode Code { get; set; }
[DataMember(Order = 2)]
public string Message { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
public enum OperationErrorCode
{
MissingOrIncorrectVersionHeader,
InvalidRequest,
InvalidXmlRequest,
InvalidContentType,
MissingOrInvalidRequiredQueryParameter,
InvalidHttpVerb,
InternalError,
BadRequest,
AuthenticationFailed,
ResourceNotFound,
SubscriptionDisabled,
ServerBusy,
TooManyRequests,
ConflictError,
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/Entities/Operation.cs
|
C#
|
bsd
| 2,260
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Azure.Entities
{
/// <summary>
/// Deployment
/// </summary>
[DataContract(Namespace = ApiConstants.XmlNamespace)]
public class Deployment : IExtensibleDataObject
{
[DataMember(Order = 1, EmitDefaultValue = false)]
public string Name { get; set; }
[DataMember(Order = 2)]
public DeploymentSlot DeploymentSlot { get; set; }
[DataMember(Order = 3, EmitDefaultValue = false)]
public string PrivateID { get; set; }
[DataMember(Order = 4)]
public DeploymentStatus Status { get; set; }
/// <remarks>Base64-Encoded</remarks>
[DataMember(Order = 5, EmitDefaultValue = false)]
public string Label { get; set; }
[DataMember(Order = 6, EmitDefaultValue = false)]
public Uri Url { get; set; }
/// <remarks>Base64-Encoded</remarks>
[DataMember(Order = 7, EmitDefaultValue = false)]
public string Configuration { get; set; }
[DataMember(Order = 8, EmitDefaultValue = false)]
public RoleInstanceList RoleInstanceList { get; set; }
[DataMember(Order = 9, EmitDefaultValue = false)]
public RoleList RoleList { get; set; }
[DataMember(Order = 10, EmitDefaultValue = false)]
public UpgradeStatus UpgradeStatus { get; set; }
[DataMember(Order = 11, EmitDefaultValue = false)]
public int UpgradeDomainCount { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
public enum DeploymentStatus
{
Running,
Suspended,
RunningTransitioning,
SuspendedTransitioning,
Starting,
Suspending,
Deploying,
Deleting,
}
public enum DeploymentSlot
{
Staging,
Production,
}
/// <summary>
/// Deployment Upgrade Status
/// </summary>
[DataContract(Namespace = ApiConstants.XmlNamespace)]
public class UpgradeStatus : IExtensibleDataObject
{
[DataMember(Order = 1)]
public UpgradeMode UpgradeType { get; set; }
[DataMember(Order = 2)]
public UpgradeDomainState CurrentUpgradeDomainState { get; set; }
[DataMember(Order = 3)]
public int CurrentUpgradeDomain { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
public enum UpgradeMode
{
Auto,
Manual
}
public enum UpgradeDomainState
{
Before,
During
}
/// <summary>
/// List of deployments
/// </summary>
[CollectionDataContract(Name = "Deployments", ItemName = "Deployment", Namespace = ApiConstants.XmlNamespace)]
public class DeploymentList : List<Deployment>
{
public DeploymentList()
{
}
public DeploymentList(IEnumerable<Deployment> deployments)
: base(deployments)
{
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/Entities/Deployment.cs
|
C#
|
bsd
| 3,431
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Azure.Entities
{
/// <summary>
/// Role Instance
/// </summary>
[DataContract(Namespace = ApiConstants.XmlNamespace)]
public class Role
{
[DataMember(Order = 1)]
public string RoleName { get; set; }
[DataMember(Order = 2)]
public string OperatingSystemVersion { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
/// <summary>
/// List of role instances
/// </summary>
[CollectionDataContract(Name = "RoleList", ItemName = "Role", Namespace = ApiConstants.XmlNamespace)]
public class RoleList : List<Role>
{
public RoleList()
{
}
public RoleList(IEnumerable<Role> roles)
: base(roles)
{
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/Entities/Role.cs
|
C#
|
bsd
| 1,510
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Azure.Entities
{
/// <summary>
/// Certificate
/// </summary>
[DataContract(Namespace = ApiConstants.XmlNamespace)]
public class Certificate : IExtensibleDataObject
{
[DataMember(Order = 1, EmitDefaultValue = false)]
public Uri CertificateUrl { get; set; }
[DataMember(Order = 2, EmitDefaultValue = false)]
public string Thumbprint { get; set; }
[DataMember(Order = 3, EmitDefaultValue = false)]
public string ThumbprintAlgorithm { get; set; }
/// <remarks>Base64-Encoded X509</remarks>
[DataMember(Order = 4, EmitDefaultValue = false)]
public string Data { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
/// <summary>
/// List of certificates
/// </summary>
[CollectionDataContract(Name = "Certificates", ItemName = "Certificate", Namespace = ApiConstants.XmlNamespace)]
public class CertificateList : List<Certificate>
{
public CertificateList()
{
}
public CertificateList(IEnumerable<Certificate> certificateList)
: base(certificateList)
{
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/Entities/Certificate.cs
|
C#
|
bsd
| 1,904
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Lokad.Cloud.Management.Azure.Entities
{
/// <summary>
/// Storage Service
/// </summary>
[DataContract(Namespace = ApiConstants.XmlNamespace)]
public class StorageService : IExtensibleDataObject
{
[DataMember(Order = 1)]
public Uri Url { get; set; }
[DataMember(Order = 2, EmitDefaultValue = false)]
public string ServiceName { get; set; }
[DataMember(Order = 3, EmitDefaultValue = false)]
public StorageServiceProperties StorageServiceProperties { get; set; }
[DataMember(Order = 4, EmitDefaultValue = false)]
public StorageServiceKeys StorageServiceKeys { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
/// <summary>
/// Storage Service Properties
/// </summary>
[DataContract(Namespace = ApiConstants.XmlNamespace)]
public class StorageServiceProperties : IExtensibleDataObject
{
[DataMember(Order = 1)]
public string Description { get; set; }
[DataMember(Order = 2, EmitDefaultValue = false)]
public string AffinityGroup { get; set; }
[DataMember(Order = 3, EmitDefaultValue = false)]
public string Location { get; set; }
[DataMember(Order = 4)]
public string Label { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
/// <summary>
/// Storage Service Keys
/// </summary>
[DataContract(Namespace = ApiConstants.XmlNamespace)]
public class StorageServiceKeys : IExtensibleDataObject
{
[DataMember(Order = 1)]
public string Primary { get; set; }
[DataMember(Order = 2)]
public string Secondary { get; set; }
public ExtensionDataObject ExtensionData { get; set; }
}
/// <summary>
/// List of storage services
/// </summary>
[CollectionDataContract(Name = "StorageServices", ItemName = "StorageService", Namespace = ApiConstants.XmlNamespace)]
public class StorageServiceList : List<StorageService>
{
public StorageServiceList()
{
}
public StorageServiceList(IEnumerable<StorageService> storageServices)
: base(storageServices)
{
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/Entities/StorageService.cs
|
C#
|
bsd
| 2,871
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
using System;
using System.ServiceModel;
using System.ServiceModel.Web;
using Lokad.Cloud.Management.Azure.Entities;
using Lokad.Cloud.Management.Azure.InputParameters;
// TODO: To be replaced with official REST client once available
namespace Lokad.Cloud.Management.Azure
{
/// <summary>
/// Windows Azure Service Management API.
/// </summary>
[ServiceContract(Namespace = ApiConstants.XmlNamespace)]
public interface IAzureServiceManagement
{
/// <summary>
/// Gets the result of an asynchronous operation.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebGet(UriTemplate = @"{subscriptionId}/operations/{operationTrackingId}")]
IAsyncResult BeginGetOperationStatus(string subscriptionId, string operationTrackingId, AsyncCallback callback, object state);
Operation EndGetOperationStatus(IAsyncResult asyncResult);
/// <summary>
/// Swaps the deployment to a production slot.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "POST", UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}")]
IAsyncResult BeginSwapDeployment(string subscriptionId, string serviceName, SwapDeploymentInput input, AsyncCallback callback, object state);
void EndSwapDeployment(IAsyncResult asyncResult);
/// <summary>
/// Creates a deployment.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "POST", UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/deploymentslots/{deploymentSlot}")]
IAsyncResult BeginCreateOrUpdateDeployment(string subscriptionId, string serviceName, string deploymentSlot, CreateDeploymentInput input, AsyncCallback callback, object state);
void EndCreateOrUpdateDeployment(IAsyncResult asyncResult);
/// <summary>
/// Deletes the specified deployment. This works against through the deployment name.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "DELETE", UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/deployments/{deploymentName}")]
IAsyncResult BeginDeleteDeployment(string subscriptionId, string serviceName, string deploymentName, AsyncCallback callback, object state);
void EndDeleteDeployment(IAsyncResult asyncResult);
/// <summary>
/// Deletes the specified deployment. This works against through the slot name.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "DELETE", UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/deploymentslots/{deploymentSlot}")]
IAsyncResult BeginDeleteDeploymentBySlot(string subscriptionId, string serviceName, string deploymentSlot, AsyncCallback callback, object state);
void EndDeleteDeploymentBySlot(IAsyncResult asyncResult);
/// <summary>
/// Gets the specified deployment details.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebGet(UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/deployments/{deploymentName}")]
IAsyncResult BeginGetDeployment(string subscriptionId, string serviceName, string deploymentName, AsyncCallback callback, object state);
Deployment EndGetDeployment(IAsyncResult asyncResult);
/// <summary>
/// Gets the specified deployment details.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebGet(UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/deploymentslots/{deploymentSlot}")]
IAsyncResult BeginGetDeploymentBySlot(string subscriptionId, string serviceName, string deploymentSlot, AsyncCallback callback, object state);
Deployment EndGetDeploymentBySlot(IAsyncResult asyncResult);
/// <summary>
/// Initiates a change to the deployment. This works against through the deployment name.
/// This is an asynchronous operation
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "POST", UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/deployments/{deploymentName}/?comp=config")]
IAsyncResult BeginChangeConfiguration(string subscriptionId, string serviceName, string deploymentName, ChangeConfigurationInput input, AsyncCallback callback, object state);
void EndChangeConfiguration(IAsyncResult asyncResult);
/// <summary>
/// Initiates a change to the deployment. This works against through the slot name.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "POST", UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/deploymentslots/{deploymentSlot}/?comp=config")]
IAsyncResult BeginChangeConfigurationBySlot(string subscriptionId, string serviceName, string deploymentSlot, ChangeConfigurationInput input, AsyncCallback callback, object state);
void EndChangeConfigurationBySlot(IAsyncResult asyncResult);
/// <summary>
/// Initiates a change to the deployment. This works against through the deployment name.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "POST", UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/deployments/{deploymentName}/?comp=status")]
IAsyncResult BeginUpdateDeploymentStatus(string subscriptionId, string serviceName, string deploymentName, UpdateDeploymentStatusInput input, AsyncCallback callback, object state);
void EndUpdateDeploymentStatus(IAsyncResult asyncResult);
/// <summary>
/// Initiates a change to the deployment. This works against through the slot name.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "POST", UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/deploymentslots/{deploymentSlot}/?comp=status")]
IAsyncResult BeginUpdateDeploymentStatusBySlot(string subscriptionId, string serviceName, string deploymentSlot, UpdateDeploymentStatusInput input, AsyncCallback callback, object state);
void EndUpdateDeploymentStatusBySlot(IAsyncResult asyncResult);
/// <summary>
/// Initiates an deployment upgrade.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "POST", UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/deployments/{deploymentName}/?comp=upgrade")]
IAsyncResult BeginUpgradeDeployment(string subscriptionId, string serviceName, string deploymentName, UpgradeDeploymentInput input, AsyncCallback callback, object state);
void EndUpgradeDeployment(IAsyncResult asyncResult);
/// <summary>
/// Initiates an deployment upgrade through the slot name.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "POST", UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/deploymentslots/{deploymentSlot}/?comp=upgrade")]
IAsyncResult BeginUpgradeDeploymentBySlot(string subscriptionId, string serviceName, string deploymentSlot, UpgradeDeploymentInput input, AsyncCallback callback, object state);
void EndUpgradeDeploymentBySlot(IAsyncResult asyncResult);
/// <summary>
/// Initiates an deployment upgrade.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "POST", UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/deployments/{deploymentName}/?comp=walkupgradedomain")]
IAsyncResult BeginWalkUpgradeDomain(string subscriptionId, string serviceName, string deploymentName, WalkUpgradeDomainInput input, AsyncCallback callback, object state);
void EndWalkUpgradeDomain(IAsyncResult asyncResult);
/// <summary>
/// Initiates an deployment upgrade through the slot name.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "POST", UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/deploymentslots/{deploymentSlot}/?comp=walkupgradedomain")]
IAsyncResult BeginWalkUpgradeDomainBySlot(string subscriptionId, string serviceName, string deploymentSlot, WalkUpgradeDomainInput input, AsyncCallback callback, object state);
void EndWalkUpgradeDomainBySlot(IAsyncResult asyncResult);
/// <summary>
/// Lists the affinity groups associated with the specified subscription.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebGet(UriTemplate = @"{subscriptionId}/affinitygroups")]
IAsyncResult BeginListAffinityGroups(string subscriptionId, AsyncCallback callback, object state);
AffinityGroupList EndListAffinityGroups(IAsyncResult asyncResult);
/// <summary>
/// Get properties for the specified affinity group.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebGet(UriTemplate = @"{subscriptionId}/affinitygroups/{affinityGroupName}")]
IAsyncResult BeginGetAffinityGroup(string subscriptionId, string affinityGroupName, AsyncCallback callback, object state);
AffinityGroup EndGetAffinityGroup(IAsyncResult asyncResult);
/// <summary>
/// Lists the certificates associated with a given subscription.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebGet(UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/certificates")]
IAsyncResult BeginListCertificates(string subscriptionId, string serviceName, AsyncCallback callback, object state);
CertificateList EndListCertificates(IAsyncResult asyncResult);
/// <summary>
/// Gets public data for the given certificate.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebGet(UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/certificates/{thumbprintalgorithm}-{thumbprint_in_hex}")]
IAsyncResult BeginGetCertificate(string subscriptionId, string serviceName, string thumbprintalgorithm, string thumbprint_in_hex, AsyncCallback callback, object state);
Certificate EndGetCertificate(IAsyncResult asyncResult);
/// <summary>
/// Adds certificates to the given subscription.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "POST", UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/certificates")]
IAsyncResult BeginAddCertificates(string subscriptionId, string serviceName, CertificateFileInput input, AsyncCallback callback, object state);
void EndAddCertificates(IAsyncResult asyncResult);
/// <summary>
/// Deletes the given certificate.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "DELETE", UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}/certificates/{thumbprintalgorithm}-{thumbprint_in_hex}")]
IAsyncResult BeginDeleteCertificate(string subscriptionId, string serviceName, string thumbprintalgorithm, string thumbprint_in_hex, AsyncCallback callback, object state);
void EndDeleteCertificate(IAsyncResult asyncResult);
/// <summary>
/// Lists the hosted services associated with a given subscription.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebGet(UriTemplate = @"{subscriptionId}/services/hostedservices")]
IAsyncResult BeginListHostedServices(string subscriptionId, AsyncCallback callback, object state);
HostedServiceList EndListHostedServices(IAsyncResult asyncResult);
/// <summary>
/// Gets the properties for the specified hosted service.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebGet(UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}")]
IAsyncResult BeginGetHostedService(string subscriptionId, string serviceName, AsyncCallback callback, object state);
HostedService EndGetHostedService(IAsyncResult asyncResult);
/// <summary>
/// Gets the detailed properties for the specified hosted service.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebGet(UriTemplate = @"{subscriptionId}/services/hostedservices/{serviceName}?embed-detail={embedDetail}")]
IAsyncResult BeginGetHostedServiceWithDetails(string subscriptionId, string serviceName, bool embedDetail, AsyncCallback callback, object state);
HostedService EndGetHostedServiceWithDetails(IAsyncResult asyncResult);
/// <summary>
/// Lists the storage services associated with a given subscription.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebGet(UriTemplate = @"{subscriptionId}/services/storageservices")]
IAsyncResult BeginListStorageServices(string subscriptionId, AsyncCallback callback, object state);
StorageServiceList EndListStorageServices(IAsyncResult asyncResult);
/// <summary>
/// Gets a storage service.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebGet(UriTemplate = @"{subscriptionId}/services/storageservices/{serviceName}")]
IAsyncResult BeginGetStorageService(string subscriptionId, string serviceName, AsyncCallback callback, object state);
StorageService EndGetStorageService(IAsyncResult asyncResult);
/// <summary>
/// Gets the key of a storage service.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebGet(UriTemplate = @"{subscriptionId}/services/storageservices/{serviceName}/keys")]
IAsyncResult BeginGetStorageKeys(string subscriptionId, string serviceName, AsyncCallback callback, object state);
StorageService EndGetStorageKeys(IAsyncResult asyncResult);
/// <summary>
/// Regenerates keys associated with a storage service.
/// </summary>
[OperationContract(AsyncPattern = true)]
[WebInvoke(Method = "POST", UriTemplate = @"{subscriptionId}/services/storageservices/{serviceName}/keys?action=regenerate")]
IAsyncResult BeginRegenerateStorageServiceKeys(string subscriptionId, string serviceName, RegenerateKeysInput regenerateKeys, AsyncCallback callback, object state);
StorageService EndRegenerateStorageServiceKeys(IAsyncResult asyncResult);
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/IAzureServiceManagement.cs
|
C#
|
bsd
| 14,526
|
#region Copyright (c) Lokad 2009-2010
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
#endregion
using System;
using System.ServiceModel;
using System.ServiceModel.Security;
using System.Threading;
using Lokad.Cloud.Storage.Shared.Policies;
namespace Lokad.Cloud.Management.Azure
{
/// <summary>
/// Azure retry policies for corner-situation and server errors.
/// </summary>
public static class AzureManagementPolicies
{
/// <summary>
/// Retry policy to temporarily back off in case of transient Azure server
/// errors, system overload or in case the denial of service detection system
/// thinks we're a too heavy user. Blocks the thread while backing off to
/// prevent further requests for a while (per thread).
/// </summary>
public static Storage.Shared.Policies.ActionPolicy TransientServerErrorBackOff { get; private set; }
/// <summary>
/// Static Constructor
/// </summary>
static AzureManagementPolicies()
{
// Initialize Policies
TransientServerErrorBackOff = Storage.Shared.Policies.ActionPolicy.With(TransientServerErrorExceptionFilter)
.Retry(30, OnTransientServerErrorRetry);
}
static void OnTransientServerErrorRetry(Exception exception, int count)
{
// quadratic backoff, capped at 5 minutes
var c = count + 1;
Thread.Sleep(TimeSpan.FromSeconds(Math.Min(300, c * c)));
}
static bool TransientServerErrorExceptionFilter(Exception exception)
{
// NOTE: We observed Azure hiccups that caused transport security
// to momentarily fail, causing a MessageSecurity exception (#1405).
// We thus tread this exception as a transient error.
// In case it is a permanent error it will still show up,
// although delayed by the 30 retrials.
if (exception is EndpointNotFoundException
|| exception is TimeoutException
|| exception is MessageSecurityException)
{
return true;
}
return false;
}
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/AzureManagementPolicies.cs
|
C#
|
bsd
| 2,032
|
#region Copyright (c) Lokad 2010, Microsoft
// This code is released under the terms of the new BSD licence.
// URL: http://www.lokad.com/
//
// Based on Microsoft Sample Code from http://code.msdn.microsoft.com/azurecmdlets
//---------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
// OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//---------------------------------------------------------------------------------
#endregion
// TODO: To be replaced with official REST client once available
namespace Lokad.Cloud.Management.Azure
{
internal static class ApiConstants
{
public const string ServiceEndpoint = "https://management.core.windows.net";
public const string XmlNamespace = "http://schemas.microsoft.com/windowsazure";
public const string VersionHeaderName = "x-ms-version";
public const string OperationTrackingIdHeader = "x-ms-request-id";
public const string VersionHeaderContent = "2009-10-01";
}
}
|
zyyin2005-lokadclone
|
Source/Lokad.Cloud.Framework/Management/Azure/ApiConstants.cs
|
C#
|
bsd
| 1,227
|