Merge: dev to default
This commit is contained in:
commit
8219ae3a68
10 changed files with 483 additions and 382 deletions
|
@ -1,4 +1,4 @@
|
||||||
// Copyright (c) 2012, Outercurve Foundation.
|
// Copyright (c) 2012, Outercurve Foundation.
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without modification,
|
// Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
@ -80,7 +80,7 @@ namespace WebsitePanel.Installer.Core
|
||||||
|
|
||||||
private WebClient fileLoader;
|
private WebClient fileLoader;
|
||||||
|
|
||||||
public BitlyLoader(string remoteFile)
|
internal BitlyLoader(string remoteFile)
|
||||||
: base(remoteFile)
|
: base(remoteFile)
|
||||||
{
|
{
|
||||||
InitFileLoader();
|
InitFileLoader();
|
||||||
|
@ -115,7 +115,7 @@ namespace WebsitePanel.Installer.Core
|
||||||
|
|
||||||
Log.WriteStart("Downloading file");
|
Log.WriteStart("Downloading file");
|
||||||
Log.WriteInfo("Downloading file \"{0}\" to \"{1}\"", remoteFile, tmpFile);
|
Log.WriteInfo("Downloading file \"{0}\" to \"{1}\"", remoteFile, tmpFile);
|
||||||
|
|
||||||
// Attach event handlers to track status of the download process
|
// Attach event handlers to track status of the download process
|
||||||
fileLoader.DownloadProgressChanged += (obj, e) =>
|
fileLoader.DownloadProgressChanged += (obj, e) =>
|
||||||
{
|
{
|
||||||
|
@ -145,7 +145,7 @@ namespace WebsitePanel.Installer.Core
|
||||||
|
|
||||||
fileLoader.DownloadFileAsync(new Uri(remoteFile), tmpFile);
|
fileLoader.DownloadFileAsync(new Uri(remoteFile), tmpFile);
|
||||||
RaiseOnStatusChangedEvent(DownloadingSetupFilesMessage);
|
RaiseOnStatusChangedEvent(DownloadingSetupFilesMessage);
|
||||||
|
|
||||||
autoEvent.WaitOne();
|
autoEvent.WaitOne();
|
||||||
}
|
}
|
||||||
}, ct);
|
}, ct);
|
||||||
|
@ -175,7 +175,7 @@ namespace WebsitePanel.Installer.Core
|
||||||
public event EventHandler<LoaderEventArgs<Int32>> ProgressChanged;
|
public event EventHandler<LoaderEventArgs<Int32>> ProgressChanged;
|
||||||
public event EventHandler<EventArgs> OperationCompleted;
|
public event EventHandler<EventArgs> OperationCompleted;
|
||||||
|
|
||||||
public Loader(string remoteFile)
|
internal Loader(string remoteFile)
|
||||||
{
|
{
|
||||||
this.remoteFile = remoteFile;
|
this.remoteFile = remoteFile;
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ namespace WebsitePanel.Installer.Core
|
||||||
// Download the file requested
|
// Download the file requested
|
||||||
Task downloadFileTask = GetDownloadFileTask(remoteFile, tmpFile, token);
|
Task downloadFileTask = GetDownloadFileTask(remoteFile, tmpFile, token);
|
||||||
// Move the file downloaded from temporary location to Data folder
|
// Move the file downloaded from temporary location to Data folder
|
||||||
var moveFileTask = downloadFileTask.ContinueWith((t) =>
|
var moveFileTask = downloadFileTask.ContinueWith((t) =>
|
||||||
{
|
{
|
||||||
if (File.Exists(tmpFile))
|
if (File.Exists(tmpFile))
|
||||||
{
|
{
|
||||||
|
@ -312,7 +312,7 @@ namespace WebsitePanel.Installer.Core
|
||||||
{
|
{
|
||||||
RaiseOnOperationCompletedEvent();
|
RaiseOnOperationCompletedEvent();
|
||||||
}, token);
|
}, token);
|
||||||
|
|
||||||
downloadFileTask.Start();
|
downloadFileTask.Start();
|
||||||
downloadFileTask.Wait();
|
downloadFileTask.Wait();
|
||||||
}
|
}
|
||||||
|
@ -527,4 +527,4 @@ namespace WebsitePanel.Installer.Core
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -337,10 +337,13 @@ namespace WebsitePanel.SilentInstaller
|
||||||
string installerPath = Utils.GetDbString(row["InstallerPath"]);
|
string installerPath = Utils.GetDbString(row["InstallerPath"]);
|
||||||
string installerType = Utils.GetDbString(row["InstallerType"]);
|
string installerType = Utils.GetDbString(row["InstallerType"]);
|
||||||
|
|
||||||
|
// Get appropriate loader to download the app distributive
|
||||||
|
var loader = LoaderFactory.CreateFileLoader(fileName);
|
||||||
|
// Mimic synchronous download process for the console app
|
||||||
|
AutoResetEvent autoEvent = new AutoResetEvent(false);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// download installer
|
|
||||||
var loader = new Loader(fileName);
|
|
||||||
//
|
//
|
||||||
loader.OperationCompleted += new EventHandler<EventArgs>((object sender, EventArgs e) =>
|
loader.OperationCompleted += new EventHandler<EventArgs>((object sender, EventArgs e) =>
|
||||||
{
|
{
|
||||||
|
@ -374,25 +377,26 @@ namespace WebsitePanel.SilentInstaller
|
||||||
Log.WriteEnd("Installer finished");
|
Log.WriteEnd("Installer finished");
|
||||||
// Remove temporary directory
|
// Remove temporary directory
|
||||||
FileUtils.DeleteTempDirectory();
|
FileUtils.DeleteTempDirectory();
|
||||||
|
// We are done
|
||||||
|
autoEvent.Set();
|
||||||
});
|
});
|
||||||
|
// TODO: Add cleanup for events.
|
||||||
loader.OperationFailed += new EventHandler<LoaderEventArgs<Exception>>(loader_OperationFailed);
|
loader.OperationFailed += new EventHandler<LoaderEventArgs<Exception>>(loader_OperationFailed);
|
||||||
loader.ProgressChanged += new EventHandler<LoaderEventArgs<int>>(loader_ProgressChanged);
|
loader.ProgressChanged += new EventHandler<LoaderEventArgs<int>>(loader_ProgressChanged);
|
||||||
loader.StatusChanged += new EventHandler<LoaderEventArgs<string>>(loader_StatusChanged);
|
loader.StatusChanged += new EventHandler<LoaderEventArgs<string>>(loader_StatusChanged);
|
||||||
//
|
//
|
||||||
loader.LoadAppDistributive();
|
loader.LoadAppDistributive();
|
||||||
|
// Wait until the download is complete
|
||||||
|
autoEvent.WaitOne();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.WriteError("Installer error", ex);
|
Log.WriteError("Installer error", ex);
|
||||||
//AppContext.AppForm.ShowError(ex);
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
//this.componentSettingsXml = null;
|
autoEvent.Set();
|
||||||
//this.componentCode = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loader_StatusChanged(object sender, LoaderEventArgs<string> e)
|
static void loader_StatusChanged(object sender, LoaderEventArgs<string> e)
|
||||||
|
|
|
@ -232,7 +232,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
);
|
);
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
throw new Exception("Authentication token is invalid or borken");
|
throw new Exception("Authentication token is invalid or broken");
|
||||||
|
|
||||||
SecurityContext.SetThreadPrincipal(user);
|
SecurityContext.SetThreadPrincipal(user);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2700,7 +2700,7 @@ namespace WebsitePanel.EnterpriseServer
|
||||||
public static NetworkAdapterDetails GetExternalNetworkAdapterDetails(int itemId)
|
public static NetworkAdapterDetails GetExternalNetworkAdapterDetails(int itemId)
|
||||||
{
|
{
|
||||||
// load service item
|
// load service item
|
||||||
VirtualMachine vm = (VirtualMachine)PackageController.GetPackageItem(itemId);
|
VMInfo vm = (VMInfo)PackageController.GetPackageItem(itemId);
|
||||||
if (vm == null)
|
if (vm == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
|
|
@ -40,361 +40,366 @@ using WebsitePanel.Server.Utils;
|
||||||
|
|
||||||
namespace WebsitePanel.Providers.FTP
|
namespace WebsitePanel.Providers.FTP
|
||||||
{
|
{
|
||||||
public class FileZilla : HostingServiceProviderBase, IFtpServer
|
public class FileZilla : HostingServiceProviderBase, IFtpServer
|
||||||
{
|
{
|
||||||
#region Constants
|
#region Constants
|
||||||
|
|
||||||
private const string FILEZILLA_REG = @"SOFTWARE\FileZilla Server";
|
private const string FILEZILLA_REG = @"SOFTWARE\FileZilla Server";
|
||||||
private const string FILEZILLA_REG_X64 = @"SOFTWARE\Wow6432Node\FileZilla Server";
|
private const string FILEZILLA_REG_X64 = @"SOFTWARE\Wow6432Node\FileZilla Server";
|
||||||
private const string FILEZILLA_SERVER_FILE = "FileZilla Server.xml";
|
private const string FILEZILLA_SERVER_FILE = "FileZilla Server.xml";
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Properties
|
#region Properties
|
||||||
protected virtual string FileZillaFolder
|
protected virtual string FileZillaFolder
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
RegistryKey fzKey = Registry.LocalMachine.OpenSubKey(FILEZILLA_REG) ??
|
RegistryKey fzKey = Registry.LocalMachine.OpenSubKey(FILEZILLA_REG) ??
|
||||||
Registry.LocalMachine.OpenSubKey(FILEZILLA_REG_X64);
|
Registry.LocalMachine.OpenSubKey(FILEZILLA_REG_X64);
|
||||||
|
|
||||||
if (fzKey == null)
|
if (fzKey == null)
|
||||||
throw new Exception("FileZilla registry key was not found: " + FILEZILLA_REG);
|
throw new Exception("FileZilla registry key was not found: " + FILEZILLA_REG);
|
||||||
|
|
||||||
return (string)fzKey.GetValue("Install_Dir");
|
return (string)fzKey.GetValue("Install_Dir");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Sites
|
#region Sites
|
||||||
|
|
||||||
public virtual void ChangeSiteState(string siteId, ServerState state)
|
public virtual void ChangeSiteState(string siteId, ServerState state)
|
||||||
{
|
{
|
||||||
// not implemented
|
// not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual string CreateSite(FtpSite site)
|
public virtual string CreateSite(FtpSite site)
|
||||||
{
|
{
|
||||||
// not implemented
|
// not implemented
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void DeleteSite(string siteId)
|
public virtual void DeleteSite(string siteId)
|
||||||
{
|
{
|
||||||
// not implemented
|
// not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual FtpSite GetSite(string siteId)
|
public virtual FtpSite GetSite(string siteId)
|
||||||
{
|
{
|
||||||
// not implemented
|
// not implemented
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual FtpSite[] GetSites()
|
public virtual FtpSite[] GetSites()
|
||||||
{
|
{
|
||||||
// not implemented
|
// not implemented
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool SiteExists(string siteId)
|
public virtual bool SiteExists(string siteId)
|
||||||
{
|
{
|
||||||
// not implemented
|
// not implemented
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual ServerState GetSiteState(string siteId)
|
public virtual ServerState GetSiteState(string siteId)
|
||||||
{
|
{
|
||||||
// not implemented
|
// not implemented
|
||||||
return ServerState.Started;
|
return ServerState.Started;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void UpdateSite(FtpSite site)
|
public virtual void UpdateSite(FtpSite site)
|
||||||
{
|
{
|
||||||
// not implemented
|
// not implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Accounts
|
#region Accounts
|
||||||
|
|
||||||
public virtual bool AccountExists(string accountName)
|
public virtual bool AccountExists(string accountName)
|
||||||
{
|
{
|
||||||
XmlDocument doc = GetFileZillaConfig();
|
XmlDocument doc = GetFileZillaConfig();
|
||||||
XmlNode nodeUser = doc.SelectSingleNode("/FileZillaServer/Users/User[@Name='" + accountName + "']");
|
XmlNode nodeUser = doc.SelectSingleNode("/FileZillaServer/Users/User[@Name='" + accountName + "']");
|
||||||
return (nodeUser != null);
|
return (nodeUser != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual FtpAccount GetAccount(string accountName)
|
public virtual FtpAccount GetAccount(string accountName)
|
||||||
{
|
{
|
||||||
XmlDocument doc = GetFileZillaConfig();
|
XmlDocument doc = GetFileZillaConfig();
|
||||||
XmlNode nodeUser = doc.SelectSingleNode("/FileZillaServer/Users/User[@Name='" + accountName + "']");
|
XmlNode nodeUser = doc.SelectSingleNode("/FileZillaServer/Users/User[@Name='" + accountName + "']");
|
||||||
if (nodeUser == null)
|
if (nodeUser == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return CreateAccountFromXmlNode(nodeUser, false);
|
return CreateAccountFromXmlNode(nodeUser, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual FtpAccount[] GetAccounts()
|
public virtual FtpAccount[] GetAccounts()
|
||||||
{
|
{
|
||||||
XmlDocument doc = GetFileZillaConfig();
|
XmlDocument doc = GetFileZillaConfig();
|
||||||
XmlNodeList nodeUsers = doc.SelectNodes("/FileZillaServer/Users/User");
|
XmlNodeList nodeUsers = doc.SelectNodes("/FileZillaServer/Users/User");
|
||||||
|
|
||||||
List<FtpAccount> accounts = new List<FtpAccount>();
|
List<FtpAccount> accounts = new List<FtpAccount>();
|
||||||
foreach (XmlNode nodeUser in nodeUsers)
|
foreach (XmlNode nodeUser in nodeUsers)
|
||||||
accounts.Add(CreateAccountFromXmlNode(nodeUser, true));
|
accounts.Add(CreateAccountFromXmlNode(nodeUser, true));
|
||||||
|
|
||||||
return accounts.ToArray();
|
return accounts.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void CreateAccount(FtpAccount account)
|
public virtual void CreateAccount(FtpAccount account)
|
||||||
{
|
{
|
||||||
Log.WriteInfo("GetFileZillaConfig");
|
Log.WriteInfo("GetFileZillaConfig");
|
||||||
XmlDocument doc = GetFileZillaConfig();
|
XmlDocument doc = GetFileZillaConfig();
|
||||||
|
|
||||||
|
|
||||||
Log.WriteInfo("Find users nodes");
|
Log.WriteInfo("Find users nodes");
|
||||||
// find users node
|
// find users node
|
||||||
XmlNode nodeUsers = doc.SelectSingleNode("/FileZillaServer/Users");
|
XmlNode fzServerNode = doc.SelectSingleNode("/FileZillaServer");
|
||||||
|
XmlNode fzAccountsNode = fzServerNode.SelectSingleNode("/Users");
|
||||||
XmlElement nodeUser = doc.CreateElement("User");
|
if (fzAccountsNode == null)
|
||||||
if (nodeUsers != null) nodeUsers.AppendChild(nodeUser);
|
{
|
||||||
|
fzAccountsNode = doc.CreateElement("Users");
|
||||||
|
fzServerNode.AppendChild(fzAccountsNode);
|
||||||
|
}
|
||||||
|
|
||||||
// set properties
|
XmlElement fzAccountNode = doc.CreateElement("User");
|
||||||
nodeUser.SetAttribute("Name", account.Name);
|
fzAccountsNode.AppendChild(fzAccountNode);
|
||||||
SetOption(nodeUser, "Pass", MD5(account.Password));
|
// set properties
|
||||||
SetOption(nodeUser, "Group", "");
|
fzAccountNode.SetAttribute("Name", account.Name);
|
||||||
SetOption(nodeUser, "Bypass server userlimit", "0");
|
SetOption(fzAccountNode, "Pass", MD5(account.Password));
|
||||||
SetOption(nodeUser, "User Limit", "0");
|
SetOption(fzAccountNode, "Group", "");
|
||||||
SetOption(nodeUser, "IP Limit", "0");
|
SetOption(fzAccountNode, "Bypass server userlimit", "0");
|
||||||
SetOption(nodeUser, "Enabled", BoolToString(account.Enabled));
|
SetOption(fzAccountNode, "User Limit", "0");
|
||||||
SetOption(nodeUser, "Comments", "");
|
SetOption(fzAccountNode, "IP Limit", "0");
|
||||||
SetOption(nodeUser, "ForceSsl", "0");
|
SetOption(fzAccountNode, "Enabled", BoolToString(account.Enabled));
|
||||||
|
SetOption(fzAccountNode, "Comments", "");
|
||||||
|
SetOption(fzAccountNode, "ForceSsl", "0");
|
||||||
|
|
||||||
// IP filter
|
// IP filter
|
||||||
XmlElement nodeIPFilter = doc.CreateElement("IpFilter");
|
XmlElement nodeIPFilter = doc.CreateElement("IpFilter");
|
||||||
nodeUser.AppendChild(nodeIPFilter);
|
fzAccountNode.AppendChild(nodeIPFilter);
|
||||||
|
|
||||||
XmlElement nodeDisallowed = doc.CreateElement("Disallowed");
|
XmlElement nodeDisallowed = doc.CreateElement("Disallowed");
|
||||||
nodeIPFilter.AppendChild(nodeDisallowed);
|
nodeIPFilter.AppendChild(nodeDisallowed);
|
||||||
|
|
||||||
XmlElement nodeAllowed = doc.CreateElement("Allowed");
|
XmlElement nodeAllowed = doc.CreateElement("Allowed");
|
||||||
nodeIPFilter.AppendChild(nodeAllowed);
|
nodeIPFilter.AppendChild(nodeAllowed);
|
||||||
|
|
||||||
// folder
|
// folder
|
||||||
XmlElement nodePermissions = doc.CreateElement("Permissions");
|
XmlElement nodePermissions = doc.CreateElement("Permissions");
|
||||||
nodeUser.AppendChild(nodePermissions);
|
fzAccountNode.AppendChild(nodePermissions);
|
||||||
|
|
||||||
XmlElement nodePermission = doc.CreateElement("Permission");
|
XmlElement nodePermission = doc.CreateElement("Permission");
|
||||||
nodePermissions.AppendChild(nodePermission);
|
nodePermissions.AppendChild(nodePermission);
|
||||||
|
|
||||||
// folder settings
|
// folder settings
|
||||||
nodePermission.SetAttribute("Dir", account.Folder);
|
nodePermission.SetAttribute("Dir", account.Folder);
|
||||||
SetOption(nodePermission, "FileRead", BoolToString(account.CanRead));
|
SetOption(nodePermission, "FileRead", BoolToString(account.CanRead));
|
||||||
SetOption(nodePermission, "FileWrite", BoolToString(account.CanWrite));
|
SetOption(nodePermission, "FileWrite", BoolToString(account.CanWrite));
|
||||||
SetOption(nodePermission, "FileDelete", BoolToString(account.CanWrite));
|
SetOption(nodePermission, "FileDelete", BoolToString(account.CanWrite));
|
||||||
SetOption(nodePermission, "DirCreate", BoolToString(account.CanWrite));
|
SetOption(nodePermission, "DirCreate", BoolToString(account.CanWrite));
|
||||||
SetOption(nodePermission, "DirDelete", BoolToString(account.CanWrite));
|
SetOption(nodePermission, "DirDelete", BoolToString(account.CanWrite));
|
||||||
SetOption(nodePermission, "DirList", BoolToString(account.CanRead));
|
SetOption(nodePermission, "DirList", BoolToString(account.CanRead));
|
||||||
SetOption(nodePermission, "DirSubdirs", BoolToString(account.CanRead));
|
SetOption(nodePermission, "DirSubdirs", BoolToString(account.CanRead));
|
||||||
SetOption(nodePermission, "IsHome", "1");
|
SetOption(nodePermission, "IsHome", "1");
|
||||||
SetOption(nodePermission, "AutoCreate", "0");
|
SetOption(nodePermission, "AutoCreate", "0");
|
||||||
|
|
||||||
// speed limits
|
// speed limits
|
||||||
XmlElement nodeSpeedLimits = doc.CreateElement("SpeedLimits");
|
XmlElement nodeSpeedLimits = doc.CreateElement("SpeedLimits");
|
||||||
nodeUser.AppendChild(nodeSpeedLimits);
|
fzAccountNode.AppendChild(nodeSpeedLimits);
|
||||||
nodeSpeedLimits.SetAttribute("DlType", "0");
|
nodeSpeedLimits.SetAttribute("DlType", "0");
|
||||||
nodeSpeedLimits.SetAttribute("DlLimit", "10");
|
nodeSpeedLimits.SetAttribute("DlLimit", "10");
|
||||||
nodeSpeedLimits.SetAttribute("ServerDlLimitBypass", "0");
|
nodeSpeedLimits.SetAttribute("ServerDlLimitBypass", "0");
|
||||||
nodeSpeedLimits.SetAttribute("UlType", "0");
|
nodeSpeedLimits.SetAttribute("UlType", "0");
|
||||||
nodeSpeedLimits.SetAttribute("UlLimit", "10");
|
nodeSpeedLimits.SetAttribute("UlLimit", "10");
|
||||||
nodeSpeedLimits.SetAttribute("ServerUlLimitBypass", "0");
|
nodeSpeedLimits.SetAttribute("ServerUlLimitBypass", "0");
|
||||||
|
|
||||||
XmlElement nodeDownload = doc.CreateElement("Download");
|
XmlElement nodeDownload = doc.CreateElement("Download");
|
||||||
nodeSpeedLimits.AppendChild(nodeDownload);
|
nodeSpeedLimits.AppendChild(nodeDownload);
|
||||||
|
|
||||||
XmlElement nodeUpload = doc.CreateElement("Upload");
|
XmlElement nodeUpload = doc.CreateElement("Upload");
|
||||||
nodeSpeedLimits.AppendChild(nodeUpload);
|
nodeSpeedLimits.AppendChild(nodeUpload);
|
||||||
|
|
||||||
// save document
|
// save document
|
||||||
doc.Save(GetFileZillaConfigPath());
|
doc.Save(GetFileZillaConfigPath());
|
||||||
|
|
||||||
// reload config
|
// reload config
|
||||||
ReloadFileZillaConfig();
|
ReloadFileZillaConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void UpdateAccount(FtpAccount account)
|
public virtual void UpdateAccount(FtpAccount account)
|
||||||
{
|
{
|
||||||
XmlDocument doc = GetFileZillaConfig();
|
XmlDocument doc = GetFileZillaConfig();
|
||||||
XmlNode nodeUser = doc.SelectSingleNode("/FileZillaServer/Users/User[@Name='" + account.Name + "']");
|
XmlNode nodeUser = doc.SelectSingleNode("/FileZillaServer/Users/User[@Name='" + account.Name + "']");
|
||||||
if (nodeUser == null)
|
if (nodeUser == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// update user
|
// update user
|
||||||
if(!String.IsNullOrEmpty(account.Password))
|
if(!String.IsNullOrEmpty(account.Password))
|
||||||
SetOption(nodeUser, "Pass", MD5(account.Password));
|
SetOption(nodeUser, "Pass", MD5(account.Password));
|
||||||
SetOption(nodeUser, "Enabled", BoolToString(account.Enabled));
|
SetOption(nodeUser, "Enabled", BoolToString(account.Enabled));
|
||||||
|
|
||||||
// update folder
|
// update folder
|
||||||
XmlNode nodePermission = nodeUser.SelectSingleNode("Permissions/Permission");
|
XmlNode nodePermission = nodeUser.SelectSingleNode("Permissions/Permission");
|
||||||
if (nodePermission != null)
|
if (nodePermission != null)
|
||||||
{
|
{
|
||||||
((XmlElement)nodePermission).SetAttribute("Dir", account.Folder);
|
((XmlElement)nodePermission).SetAttribute("Dir", account.Folder);
|
||||||
SetOption(nodePermission, "FileRead", BoolToString(account.CanRead));
|
SetOption(nodePermission, "FileRead", BoolToString(account.CanRead));
|
||||||
SetOption(nodePermission, "FileWrite", BoolToString(account.CanWrite));
|
SetOption(nodePermission, "FileWrite", BoolToString(account.CanWrite));
|
||||||
SetOption(nodePermission, "FileDelete", BoolToString(account.CanWrite));
|
SetOption(nodePermission, "FileDelete", BoolToString(account.CanWrite));
|
||||||
SetOption(nodePermission, "DirCreate", BoolToString(account.CanWrite));
|
SetOption(nodePermission, "DirCreate", BoolToString(account.CanWrite));
|
||||||
SetOption(nodePermission, "DirDelete", BoolToString(account.CanWrite));
|
SetOption(nodePermission, "DirDelete", BoolToString(account.CanWrite));
|
||||||
SetOption(nodePermission, "DirList", BoolToString(account.CanRead));
|
SetOption(nodePermission, "DirList", BoolToString(account.CanRead));
|
||||||
SetOption(nodePermission, "DirSubdirs", BoolToString(account.CanRead));
|
SetOption(nodePermission, "DirSubdirs", BoolToString(account.CanRead));
|
||||||
}
|
}
|
||||||
|
|
||||||
// save document
|
// save document
|
||||||
doc.Save(GetFileZillaConfigPath());
|
doc.Save(GetFileZillaConfigPath());
|
||||||
|
|
||||||
// reload config
|
// reload config
|
||||||
ReloadFileZillaConfig();
|
ReloadFileZillaConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void DeleteAccount(string accountName)
|
public virtual void DeleteAccount(string accountName)
|
||||||
{
|
{
|
||||||
XmlDocument doc = GetFileZillaConfig();
|
XmlDocument doc = GetFileZillaConfig();
|
||||||
XmlNode nodeUser = doc.SelectSingleNode("/FileZillaServer/Users/User[@Name='" + accountName + "']");
|
XmlNode nodeUser = doc.SelectSingleNode("/FileZillaServer/Users/User[@Name='" + accountName + "']");
|
||||||
if (nodeUser == null)
|
if (nodeUser == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// delete account
|
// delete account
|
||||||
nodeUser.ParentNode.RemoveChild(nodeUser);
|
nodeUser.ParentNode.RemoveChild(nodeUser);
|
||||||
|
|
||||||
// save document
|
// save document
|
||||||
doc.Save(GetFileZillaConfigPath());
|
doc.Save(GetFileZillaConfigPath());
|
||||||
|
|
||||||
// reload config
|
// reload config
|
||||||
ReloadFileZillaConfig();
|
ReloadFileZillaConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
public override void ChangeServiceItemsState(ServiceProviderItem[] items, bool enabled)
|
public override void ChangeServiceItemsState(ServiceProviderItem[] items, bool enabled)
|
||||||
{
|
{
|
||||||
foreach (ServiceProviderItem item in items)
|
foreach (ServiceProviderItem item in items)
|
||||||
{
|
{
|
||||||
if (item is FtpAccount)
|
if (item is FtpAccount)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// change FTP account state
|
// change FTP account state
|
||||||
FtpAccount account = GetAccount(item.Name);
|
FtpAccount account = GetAccount(item.Name);
|
||||||
account.Enabled = enabled;
|
account.Enabled = enabled;
|
||||||
UpdateAccount(account);
|
UpdateAccount(account);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.WriteError(String.Format("Error switching '{0}' {1}", item.Name, item.GetType().Name), ex);
|
Log.WriteError(String.Format("Error switching '{0}' {1}", item.Name, item.GetType().Name), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DeleteServiceItems(ServiceProviderItem[] items)
|
public override void DeleteServiceItems(ServiceProviderItem[] items)
|
||||||
{
|
{
|
||||||
foreach (ServiceProviderItem item in items)
|
foreach (ServiceProviderItem item in items)
|
||||||
{
|
{
|
||||||
if (item is FtpAccount)
|
if (item is FtpAccount)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// delete FTP account
|
// delete FTP account
|
||||||
DeleteAccount(item.Name);
|
DeleteAccount(item.Name);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Log.WriteError(String.Format("Error deleting '{0}' {1}", item.Name, item.GetType().Name), ex);
|
Log.WriteError(String.Format("Error deleting '{0}' {1}", item.Name, item.GetType().Name), ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Private Helpers
|
#region Private Helpers
|
||||||
private string BoolToString(bool val)
|
private string BoolToString(bool val)
|
||||||
{
|
{
|
||||||
return val ? "1" : "0";
|
return val ? "1" : "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetOption(XmlNode parentNode, string name, string val)
|
private void SetOption(XmlNode parentNode, string name, string val)
|
||||||
{
|
{
|
||||||
XmlNode option = parentNode.SelectSingleNode("Option[@Name='" + name + "']");
|
XmlNode option = parentNode.SelectSingleNode("Option[@Name='" + name + "']");
|
||||||
if (option == null)
|
if (option == null)
|
||||||
{
|
{
|
||||||
option = parentNode.OwnerDocument.CreateElement("Option");
|
option = parentNode.OwnerDocument.CreateElement("Option");
|
||||||
parentNode.AppendChild(option);
|
parentNode.AppendChild(option);
|
||||||
((XmlElement)option).SetAttribute("Name", name);
|
((XmlElement)option).SetAttribute("Name", name);
|
||||||
}
|
}
|
||||||
option.InnerText = val;
|
option.InnerText = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FtpAccount CreateAccountFromXmlNode(XmlNode nodeUser, bool excludeDetails)
|
private FtpAccount CreateAccountFromXmlNode(XmlNode nodeUser, bool excludeDetails)
|
||||||
{
|
{
|
||||||
FtpAccount account = new FtpAccount();
|
FtpAccount account = new FtpAccount();
|
||||||
account.Name = nodeUser.Attributes["Name"].Value;
|
account.Name = nodeUser.Attributes["Name"].Value;
|
||||||
|
|
||||||
if (!excludeDetails)
|
if (!excludeDetails)
|
||||||
{
|
{
|
||||||
account.Password = nodeUser.SelectSingleNode("Option[@Name='Pass']").InnerText;
|
account.Password = nodeUser.SelectSingleNode("Option[@Name='Pass']").InnerText;
|
||||||
account.Enabled = (nodeUser.SelectSingleNode("Option[@Name='Enabled']").InnerText == "1");
|
account.Enabled = (nodeUser.SelectSingleNode("Option[@Name='Enabled']").InnerText == "1");
|
||||||
XmlNode nodeFolder = nodeUser.SelectSingleNode("Permissions/Permission");
|
XmlNode nodeFolder = nodeUser.SelectSingleNode("Permissions/Permission");
|
||||||
if (nodeFolder != null)
|
if (nodeFolder != null)
|
||||||
{
|
{
|
||||||
account.Folder = nodeFolder.Attributes["Dir"].Value;
|
account.Folder = nodeFolder.Attributes["Dir"].Value;
|
||||||
account.CanRead = (nodeFolder.SelectSingleNode("Option[@Name='FileRead']").InnerText == "1");
|
account.CanRead = (nodeFolder.SelectSingleNode("Option[@Name='FileRead']").InnerText == "1");
|
||||||
account.CanWrite = (nodeFolder.SelectSingleNode("Option[@Name='FileWrite']").InnerText == "1");
|
account.CanWrite = (nodeFolder.SelectSingleNode("Option[@Name='FileWrite']").InnerText == "1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
private XmlDocument GetFileZillaConfig()
|
private XmlDocument GetFileZillaConfig()
|
||||||
{
|
{
|
||||||
string path = GetFileZillaConfigPath();
|
string path = GetFileZillaConfigPath();
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
throw new Exception("FileZilla configuration file was not found: " + path);
|
throw new Exception("FileZilla configuration file was not found: " + path);
|
||||||
|
|
||||||
XmlDocument doc = new XmlDocument();
|
XmlDocument doc = new XmlDocument();
|
||||||
doc.Load(path);
|
doc.Load(path);
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetFileZillaConfigPath()
|
private string GetFileZillaConfigPath()
|
||||||
{
|
{
|
||||||
return Path.Combine(FileZillaFolder, FILEZILLA_SERVER_FILE);
|
return Path.Combine(FileZillaFolder, FILEZILLA_SERVER_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string MD5(string str)
|
private string MD5(string str)
|
||||||
{
|
{
|
||||||
System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding();
|
System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding();
|
||||||
byte[] bytes = ue.GetBytes(str);
|
byte[] bytes = ue.GetBytes(str);
|
||||||
|
|
||||||
// encrypt bytes
|
// encrypt bytes
|
||||||
System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
|
System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
|
||||||
byte[] hashBytes = md5.ComputeHash(bytes);
|
byte[] hashBytes = md5.ComputeHash(bytes);
|
||||||
|
|
||||||
// Convert the encrypted bytes back to a string (base 16)
|
// Convert the encrypted bytes back to a string (base 16)
|
||||||
string hashString = "";
|
string hashString = "";
|
||||||
|
|
||||||
for (int i = 0; i < hashBytes.Length; i++)
|
for (int i = 0; i < hashBytes.Length; i++)
|
||||||
hashString += Convert.ToString(hashBytes[i], 16).PadLeft(2, '0');
|
hashString += Convert.ToString(hashBytes[i], 16).PadLeft(2, '0');
|
||||||
|
|
||||||
return hashString.PadLeft(32, '0');
|
return hashString.PadLeft(32, '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReloadFileZillaConfig()
|
private void ReloadFileZillaConfig()
|
||||||
{
|
{
|
||||||
FileUtils.ExecuteSystemCommand(
|
FileUtils.ExecuteSystemCommand(
|
||||||
Path.Combine(FileZillaFolder, "FileZilla Server.exe"),
|
Path.Combine(FileZillaFolder, "FileZilla Server.exe"),
|
||||||
"/reload-config");
|
"/reload-config");
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public override bool IsInstalled()
|
public override bool IsInstalled()
|
||||||
{
|
{
|
||||||
|
@ -423,5 +428,5 @@ namespace WebsitePanel.Providers.FTP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,14 +38,98 @@ using System.Reflection;
|
||||||
using Ionic.Zip;
|
using Ionic.Zip;
|
||||||
using WebsitePanel.Providers.OS;
|
using WebsitePanel.Providers.OS;
|
||||||
|
|
||||||
|
|
||||||
namespace WebsitePanel.Providers.Utils
|
namespace WebsitePanel.Providers.Utils
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Defines a contract that a system command provider needs to implement.
|
||||||
|
/// </summary>
|
||||||
|
public interface ICommandLineProvider
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Executes the file specifed as if you were executing it via command-line interface.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">Path to the executable file (eq. .exe, .bat, .cmd and etc).</param>
|
||||||
|
/// <param name="args">Arguments to pass to the executable file</param>
|
||||||
|
/// <param name="outputFile">Path to the output file if you want the output to be written somewhere.</param>
|
||||||
|
/// <returns>Output of the command being executed.</returns>
|
||||||
|
string Execute(string filePath, string args, string outputFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Provides a default implementation of running system commands.
|
||||||
|
/// </summary>
|
||||||
|
public sealed class DefaultCommandLineProvider : ICommandLineProvider
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new process and executes the file specifed as if you were executing it via command-line interface.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">Path to the executable file (eq. .exe, .bat, .cmd and etc).</param>
|
||||||
|
/// <param name="args">Arguments to pass to the executable file</param>
|
||||||
|
/// <param name="outputFile">Path to the output file if you want the output to be written somewhere.</param>
|
||||||
|
/// <returns>Output of the command being executed.</returns>
|
||||||
|
public string Execute(string filePath, string args, string outputFile)
|
||||||
|
{
|
||||||
|
// launch system process
|
||||||
|
ProcessStartInfo startInfo = new ProcessStartInfo(filePath, args);
|
||||||
|
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
||||||
|
startInfo.RedirectStandardOutput = true;
|
||||||
|
startInfo.UseShellExecute = false;
|
||||||
|
startInfo.CreateNoWindow = true;
|
||||||
|
|
||||||
|
// get working directory from executable path
|
||||||
|
startInfo.WorkingDirectory = Path.GetDirectoryName(filePath);
|
||||||
|
Process proc = Process.Start(startInfo);
|
||||||
|
|
||||||
|
// analyze results
|
||||||
|
StreamReader reader = proc.StandardOutput;
|
||||||
|
string results = "";
|
||||||
|
if (!String.IsNullOrEmpty(outputFile))
|
||||||
|
{
|
||||||
|
// stream to writer
|
||||||
|
StreamWriter writer = new StreamWriter(outputFile);
|
||||||
|
int BUFFER_LENGTH = 2048;
|
||||||
|
int readBytes = 0;
|
||||||
|
char[] buffer = new char[BUFFER_LENGTH];
|
||||||
|
while ((readBytes = reader.Read(buffer, 0, BUFFER_LENGTH)) > 0)
|
||||||
|
{
|
||||||
|
writer.Write(buffer, 0, readBytes);
|
||||||
|
}
|
||||||
|
writer.Close();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// return as string
|
||||||
|
results = reader.ReadToEnd();
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Summary description for FileUtils.
|
/// Summary description for FileUtils.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FileUtils
|
public class FileUtils
|
||||||
{
|
{
|
||||||
|
private static ICommandLineProvider CliProvider;
|
||||||
|
|
||||||
|
static FileUtils()
|
||||||
|
{
|
||||||
|
SetDefaultCliProvider(new DefaultCommandLineProvider());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes command-line provider for the utility class. Yet this is not a perfect way to inverse control over CLI processing
|
||||||
|
/// but it does its job for the testing purposes.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="provider">An instance of a command-line provider to initialize the utility with.</param>
|
||||||
|
public static void SetDefaultCliProvider(ICommandLineProvider provider)
|
||||||
|
{
|
||||||
|
Debug.Assert(provider != null, "Command line provider is null");
|
||||||
|
CliProvider = provider;
|
||||||
|
}
|
||||||
|
|
||||||
public static string EvaluateSystemVariables(string str)
|
public static string EvaluateSystemVariables(string str)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(str))
|
if (String.IsNullOrEmpty(str))
|
||||||
|
@ -616,45 +700,17 @@ namespace WebsitePanel.Providers.Utils
|
||||||
return ExecuteSystemCommand(cmd, args, null);
|
return ExecuteSystemCommand(cmd, args, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Executes the file specifed as if you were executing it via command-line interface.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">Path to the executable file (eq. .exe, .bat, .cmd and etc).</param>
|
||||||
|
/// <param name="args">Arguments to pass to the executable file</param>
|
||||||
|
/// <param name="outputFile">Path to the output file if you want the output to be written somewhere.</param>
|
||||||
|
/// <returns>Output of the command being executed.</returns>
|
||||||
public static string ExecuteSystemCommand(string cmd, string args, string outputFile)
|
public static string ExecuteSystemCommand(string cmd, string args, string outputFile)
|
||||||
{
|
{
|
||||||
// launch system process
|
// launch system process
|
||||||
ProcessStartInfo startInfo = new ProcessStartInfo(cmd, args);
|
return CliProvider.Execute(cmd, args, outputFile);
|
||||||
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
|
||||||
startInfo.RedirectStandardOutput = true;
|
|
||||||
startInfo.StandardOutputEncoding = Encoding.UTF8;
|
|
||||||
startInfo.UseShellExecute = false;
|
|
||||||
startInfo.CreateNoWindow = true;
|
|
||||||
|
|
||||||
// get working directory from executable path
|
|
||||||
startInfo.WorkingDirectory = Path.GetDirectoryName(cmd);
|
|
||||||
Process proc = Process.Start(startInfo);
|
|
||||||
|
|
||||||
|
|
||||||
// analyze results
|
|
||||||
StreamReader reader = proc.StandardOutput;
|
|
||||||
string results = "";
|
|
||||||
if (!String.IsNullOrEmpty(outputFile))
|
|
||||||
{
|
|
||||||
// stream to writer
|
|
||||||
StreamWriter writer = new StreamWriter(outputFile);
|
|
||||||
int BUFFER_LENGTH = 2048;
|
|
||||||
int readBytes = 0;
|
|
||||||
char[] buffer = new char[BUFFER_LENGTH];
|
|
||||||
while ((readBytes = reader.Read(buffer, 0, BUFFER_LENGTH)) > 0)
|
|
||||||
{
|
|
||||||
writer.Write(buffer, 0, readBytes);
|
|
||||||
}
|
|
||||||
writer.Close();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// return as string
|
|
||||||
results = reader.ReadToEnd();
|
|
||||||
}
|
|
||||||
reader.Close();
|
|
||||||
|
|
||||||
return results;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ExecuteCmdCommand(string command)
|
public static void ExecuteCmdCommand(string command)
|
||||||
|
|
|
@ -29,9 +29,54 @@
|
||||||
using WebsitePanel.EnterpriseServer;
|
using WebsitePanel.EnterpriseServer;
|
||||||
using WebsitePanel.Providers.Virtualization;
|
using WebsitePanel.Providers.Virtualization;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace WebsitePanel.Portal
|
namespace WebsitePanel.Portal
|
||||||
{
|
{
|
||||||
|
// TODO: Move this extension to a separate file later.
|
||||||
|
public static class VirtualMachinesExtensions
|
||||||
|
{
|
||||||
|
#region Privates with specific purposes (eq. caching, usability, performance and etc)
|
||||||
|
/// <summary>
|
||||||
|
/// This method supports the Portal internal infrastructure and is not intended to be used directly from your code. Gets a cached copy of virtual machine object of the specified type or retrieves it for the first time and then caches it.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">Type of virtual machine to be retrieved (possible types are VirtualMachine|VMInfo)</typeparam>
|
||||||
|
/// <param name="cacheIdentityKey">Virtual machine item id</param>
|
||||||
|
/// <param name="getVmFunc">Function to retrieve the virtual machine data from Enterprise Server</param>
|
||||||
|
/// <returns>An instance of the specified virtual machine</returns>
|
||||||
|
internal static T GetCachedVirtualMachine<T>(object cacheIdentityKey, Func<T> getVmFunc)
|
||||||
|
{
|
||||||
|
// TODO: Make this method private when all dependents will be consolidated in the extension.
|
||||||
|
string cacheKey = "CachedVirtualMachine_" + cacheIdentityKey;
|
||||||
|
if (HttpContext.Current.Items[cacheKey] != null)
|
||||||
|
return (T)HttpContext.Current.Items[cacheKey];
|
||||||
|
|
||||||
|
// load virtual machine
|
||||||
|
T virtualMachine = getVmFunc();
|
||||||
|
|
||||||
|
// place to cache
|
||||||
|
if (virtualMachine != null)
|
||||||
|
HttpContext.Current.Items[cacheKey] = virtualMachine;
|
||||||
|
|
||||||
|
return virtualMachine;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Extension methods
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a cached copy of virtual machine object of the specified type or retrieves it for the first time and then caches it.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client"></param>
|
||||||
|
/// <param name="itemId">Virtual machine id</param>
|
||||||
|
/// <returns>An instance of the virtual machine speficied</returns>
|
||||||
|
public static VMInfo GetCachedVirtualMachine(this esVirtualizationServerForPrivateCloud client, int itemId)
|
||||||
|
{
|
||||||
|
return GetCachedVirtualMachine<VMInfo>(
|
||||||
|
itemId, () => ES.Services.VPSPC.GetVirtualMachineItem(itemId));
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
public class VirtualMachinesHelper
|
public class VirtualMachinesHelper
|
||||||
{
|
{
|
||||||
public static bool IsVirtualMachineManagementAllowed(int packageId)
|
public static bool IsVirtualMachineManagementAllowed(int packageId)
|
||||||
|
@ -57,20 +102,11 @@ namespace WebsitePanel.Portal
|
||||||
return manageAllowed;
|
return manageAllowed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Move this method to the corresponding extension later.
|
||||||
public static VirtualMachine GetCachedVirtualMachine(int itemId)
|
public static VirtualMachine GetCachedVirtualMachine(int itemId)
|
||||||
{
|
{
|
||||||
string key = "CachedVirtualMachine" + itemId;
|
return VirtualMachinesExtensions.GetCachedVirtualMachine<VirtualMachine>(
|
||||||
if (HttpContext.Current.Items[key] != null)
|
itemId, () => ES.Services.VPS.GetVirtualMachineItem(itemId));
|
||||||
return (VirtualMachine)HttpContext.Current.Items[key];
|
|
||||||
|
|
||||||
// load virtual machine
|
|
||||||
VirtualMachine vm = ES.Services.VPS.GetVirtualMachineItem(itemId);
|
|
||||||
|
|
||||||
// place to cache
|
|
||||||
if (vm != null)
|
|
||||||
HttpContext.Current.Items[key] = vm;
|
|
||||||
|
|
||||||
return vm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Virtual Machines
|
#region Virtual Machines
|
||||||
|
|
|
@ -40,13 +40,14 @@ namespace WebsitePanel.Portal.VPSForPC.RemoteDesktop
|
||||||
resolution.Text = Request["Resolution"];
|
resolution.Text = Request["Resolution"];
|
||||||
|
|
||||||
// load server info
|
// load server info
|
||||||
VirtualMachine vm = VirtualMachinesHelper.GetCachedVirtualMachine(PanelRequest.ItemID);
|
VMInfo vm = ES.Services.VPSPC.GetCachedVirtualMachine(PanelRequest.ItemID);
|
||||||
litServerName.Text = vm.Name + " - ";
|
litServerName.Text = vm.Name + " - ";
|
||||||
username.Text = "Administrator";
|
username.Text = "Administrator";
|
||||||
password.Text = vm.AdministratorPassword;
|
// TODO: Review VMInfo class fields and underlying data for correctness
|
||||||
|
password.Text = vm.AdminPassword;
|
||||||
|
|
||||||
// load external network parameters
|
// load external network parameters
|
||||||
NetworkAdapterDetails nic = ES.Services.VPS.GetExternalNetworkAdapterDetails(PanelRequest.ItemID);
|
NetworkAdapterDetails nic = ES.Services.VPSPC.GetExternalNetworkAdapterDetails(PanelRequest.ItemID);
|
||||||
if (nic.IPAddresses.Length > 0)
|
if (nic.IPAddresses.Length > 0)
|
||||||
{
|
{
|
||||||
NetworkAdapterIPAddress ip = nic.IPAddresses[0];
|
NetworkAdapterIPAddress ip = nic.IPAddresses[0];
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="C:\Program Files\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
|
<Import Project="$(MSBuildExtensionsPath)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Version>1.2.2.0</Version>
|
<Version>1.2.2.0</Version>
|
||||||
<FileVersion>1.2.2.1</FileVersion>
|
<FileVersion>1.2.2.1</FileVersion>
|
||||||
<VersionLabel>1.2.2</VersionLabel>
|
<VersionLabel>1.2.2</VersionLabel>
|
||||||
<ReleaseDate>2012-05-13</ReleaseDate>
|
<ReleaseDate>2012-08-01</ReleaseDate>
|
||||||
<BuildConfiguration>Release</BuildConfiguration>
|
<BuildConfiguration>Release</BuildConfiguration>
|
||||||
<RootFolder>..</RootFolder>
|
<RootFolder>..</RootFolder>
|
||||||
<TrunkFolder>$(RootFolder)\WebsitePanel</TrunkFolder>
|
<TrunkFolder>$(RootFolder)\WebsitePanel</TrunkFolder>
|
||||||
|
@ -15,12 +15,13 @@
|
||||||
<BuildFolder>$(TrunkFolder)\Build\$(BuildConfiguration)</BuildFolder>
|
<BuildFolder>$(TrunkFolder)\Build\$(BuildConfiguration)</BuildFolder>
|
||||||
<DeployFolder>$(TrunkFolder)\Deploy\$(BuildConfiguration)</DeployFolder>
|
<DeployFolder>$(TrunkFolder)\Deploy\$(BuildConfiguration)</DeployFolder>
|
||||||
|
|
||||||
<PreviousBuildFolder>C:\Projects\WebsitePanel-1.2.1\$(BuildConfiguration)</PreviousBuildFolder>
|
<PreviousBuildFolder>$(RootFolder)\..\prev\$(BuildConfiguration)</PreviousBuildFolder>
|
||||||
|
|
||||||
<DiffCmd>$(TrunkFolder)\Tools\Diff.exe</DiffCmd>
|
<DiffCmd>$(TrunkFolder)\Tools\Diff.exe</DiffCmd>
|
||||||
<SqlCmd>"C:\Program Files\Microsoft SQL Server\110\Tools\Binn\sqlcmd.exe" -S (local)\SQLEXPRESS -E</SqlCmd>
|
<SqlCmd>"$(ProgramFiles)\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -S (local)\SQLEXPRESS -E</SqlCmd>
|
||||||
|
|
||||||
<MSDeployPath>"C:\Program Files\IIS\Microsoft Web Deploy V2\msdeploy.exe"</MSDeployPath>
|
<MSDeployPath Condition="Exists('$(ProgramFiles)\IIS\Microsoft Web Deploy\msdeploy.exe')">"$(ProgramFiles)\IIS\Microsoft Web Deploy\msdeploy.exe"</MSDeployPath>
|
||||||
|
<MSDeployPath Condition="Exists('$(ProgramFiles)\IIS\Microsoft Web Deploy V2\msdeploy.exe')">"$(ProgramFiles)\IIS\Microsoft Web Deploy V2\msdeploy.exe"</MSDeployPath>
|
||||||
|
|
||||||
<DataBaseName>WebsitePanel_build</DataBaseName>
|
<DataBaseName>WebsitePanel_build</DataBaseName>
|
||||||
<MSDeployConnectionString>server=(local)\SQLEXPRESS;database=$(DataBaseName);Integrated Security=true;</MSDeployConnectionString>
|
<MSDeployConnectionString>server=(local)\SQLEXPRESS;database=$(DataBaseName);Integrated Security=true;</MSDeployConnectionString>
|
||||||
|
@ -31,7 +32,8 @@
|
||||||
<ImportCsvSrc>$(TrunkFolder)\Sources\Tools\WebsitePanel.Import.CsvBulk\bin\$(BuildConfiguration)</ImportCsvSrc>
|
<ImportCsvSrc>$(TrunkFolder)\Sources\Tools\WebsitePanel.Import.CsvBulk\bin\$(BuildConfiguration)</ImportCsvSrc>
|
||||||
<ImportEnterpriseSrc>$(TrunkFolder)\Sources\Tools\WebsitePanel.Import.Enterprise\bin\$(BuildConfiguration)</ImportEnterpriseSrc>
|
<ImportEnterpriseSrc>$(TrunkFolder)\Sources\Tools\WebsitePanel.Import.Enterprise\bin\$(BuildConfiguration)</ImportEnterpriseSrc>
|
||||||
<AWStatsViewerSrc>$(TrunkFolder)\Sources\Tools\WebsitePanel.AWStats.Viewer</AWStatsViewerSrc>
|
<AWStatsViewerSrc>$(TrunkFolder)\Sources\Tools\WebsitePanel.AWStats.Viewer</AWStatsViewerSrc>
|
||||||
<WSPTransportAgentSrc>$(TrunkFolder)\Sources\Tools\WSPTransportAgent</WSPTransportAgentSrc>
|
|
||||||
|
<WSPTransportAgentSrc>$(TrunkFolder)\Sources\Tools\WSPTransportAgent</WSPTransportAgentSrc>
|
||||||
|
|
||||||
<ServerBuild>$(BuildFolder)\Server</ServerBuild>
|
<ServerBuild>$(BuildFolder)\Server</ServerBuild>
|
||||||
<EnterpriseServerBuild>$(BuildFolder)\EnterpriseServer</EnterpriseServerBuild>
|
<EnterpriseServerBuild>$(BuildFolder)\EnterpriseServer</EnterpriseServerBuild>
|
||||||
|
@ -39,17 +41,14 @@
|
||||||
<ImportCsvBuild>$(BuildFolder)\Import.CsvBulk</ImportCsvBuild>
|
<ImportCsvBuild>$(BuildFolder)\Import.CsvBulk</ImportCsvBuild>
|
||||||
<ImportEnterpriseBuild>$(BuildFolder)\Import.Enterprise</ImportEnterpriseBuild>
|
<ImportEnterpriseBuild>$(BuildFolder)\Import.Enterprise</ImportEnterpriseBuild>
|
||||||
<AWStatsViewerBuild>$(BuildFolder)\AWStats.Viewer</AWStatsViewerBuild>
|
<AWStatsViewerBuild>$(BuildFolder)\AWStats.Viewer</AWStatsViewerBuild>
|
||||||
<WSPTransportAgentBuild>$(BuildFolder)\WSPTransportAgent</WSPTransportAgentBuild>
|
|
||||||
|
|
||||||
|
<WSPTransportAgentBuild>$(BuildFolder)\WSPTransportAgent</WSPTransportAgentBuild>
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
|
</PropertyGroup>
|
||||||
<Target Name="GenerateBuildVersionFiles" Inputs="build.xml" Outputs="$(TrunkFolder)\Sources\VersionInfo.cs;$(TrunkFolder)\Sources\VersionInfo.vb">
|
|
||||||
<AssemblyInfo CodeLanguage="CS" OutputFile="$(TrunkFolder)\Sources\VersionInfo.cs" AssemblyCompany="Outercurve Foundation" AssemblyCopyright="Copyright © 2012 Outercurve Foundation."
|
<Target Name="GenerateBuildVersionFiles" Inputs="build.xml" Outputs="$(TrunkFolder)\Sources\VersionInfo.cs;$(TrunkFolder)\Sources\VersionInfo.vb">
|
||||||
AssemblyVersion="$(Version)" AssemblyFileVersion="$(FileVersion)" AssemblyInformationalVersion="$(VersionLabel)" />
|
<AssemblyInfo CodeLanguage="CS" OutputFile="$(TrunkFolder)\Sources\VersionInfo.cs" AssemblyCompany="Outercurve Foundation" AssemblyCopyright="Copyright © 2012 Outercurve Foundation." AssemblyVersion="$(Version)" AssemblyFileVersion="$(FileVersion)" AssemblyInformationalVersion="$(VersionLabel)" />
|
||||||
<AssemblyInfo CodeLanguage="VB" OutputFile="$(TrunkFolder)\Sources\VersionInfo.vb" AssemblyCompany="Outercurve Foundation" AssemblyCopyright="Copyright © 2012 Outercurve Foundation."
|
<AssemblyInfo CodeLanguage="VB" OutputFile="$(TrunkFolder)\Sources\VersionInfo.vb" AssemblyCompany="Outercurve Foundation" AssemblyCopyright="Copyright © 2012 Outercurve Foundation." AssemblyVersion="$(Version)" AssemblyFileVersion="$(FileVersion)" AssemblyInformationalVersion="$(VersionLabel)" />
|
||||||
AssemblyVersion="$(Version)" AssemblyFileVersion="$(FileVersion)" AssemblyInformationalVersion="$(VersionLabel)" />
|
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="CompileSources" DependsOnTargets="GenerateBuildVersionFiles">
|
<Target Name="CompileSources" DependsOnTargets="GenerateBuildVersionFiles">
|
||||||
|
@ -60,7 +59,7 @@
|
||||||
<MSBuild Projects="$(TrunkFolder)\Sources\Tools\WebsitePanel.Import.CsvBulk.sln" Properties="Configuration=$(BuildConfiguration)" />
|
<MSBuild Projects="$(TrunkFolder)\Sources\Tools\WebsitePanel.Import.CsvBulk.sln" Properties="Configuration=$(BuildConfiguration)" />
|
||||||
<MSBuild Projects="$(TrunkFolder)\Sources\Tools\WebsitePanel.Import.Enterprise.sln" Properties="Configuration=$(BuildConfiguration)" />
|
<MSBuild Projects="$(TrunkFolder)\Sources\Tools\WebsitePanel.Import.Enterprise.sln" Properties="Configuration=$(BuildConfiguration)" />
|
||||||
<MSBuild Projects="$(TrunkFolder)\Sources\Tools\WebsitePanel.AWStats.Viewer.sln" Properties="Configuration=$(BuildConfiguration)" />
|
<MSBuild Projects="$(TrunkFolder)\Sources\Tools\WebsitePanel.AWStats.Viewer.sln" Properties="Configuration=$(BuildConfiguration)" />
|
||||||
<MSBuild Projects="$(TrunkFolder)\Sources\Tools\WSPTransportAgent.sln" Properties="Configuration=$(BuildConfiguration)" />
|
<MSBuild Projects="$(TrunkFolder)\Sources\Tools\WSPTransportAgent.sln" Properties="Configuration=$(BuildConfiguration)" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="PrepareBuilds" DependsOnTargets="CompileSources">
|
<Target Name="PrepareBuilds" DependsOnTargets="CompileSources">
|
||||||
|
@ -71,7 +70,7 @@
|
||||||
<RemoveDir Directories="$(ImportCsvBuild)"/>
|
<RemoveDir Directories="$(ImportCsvBuild)"/>
|
||||||
<RemoveDir Directories="$(ImportEnterpriseBuild)"/>
|
<RemoveDir Directories="$(ImportEnterpriseBuild)"/>
|
||||||
<RemoveDir Directories="$(AWStatsViewerBuild)"/>
|
<RemoveDir Directories="$(AWStatsViewerBuild)"/>
|
||||||
<RemoveDir Directories="$(WSPTransportAgentBuild)"/>
|
<RemoveDir Directories="$(WSPTransportAgentBuild)"/>
|
||||||
<RemoveDir Directories="$(BuildFolder)"/>
|
<RemoveDir Directories="$(BuildFolder)"/>
|
||||||
|
|
||||||
<MakeDir Directories="$(BuildFolder)"/>
|
<MakeDir Directories="$(BuildFolder)"/>
|
||||||
|
@ -81,7 +80,7 @@
|
||||||
<MakeDir Directories="$(ImportCsvBuild)"/>
|
<MakeDir Directories="$(ImportCsvBuild)"/>
|
||||||
<MakeDir Directories="$(ImportEnterpriseBuild)"/>
|
<MakeDir Directories="$(ImportEnterpriseBuild)"/>
|
||||||
<MakeDir Directories="$(AWStatsViewerBuild)"/>
|
<MakeDir Directories="$(AWStatsViewerBuild)"/>
|
||||||
<MakeDir Directories="$(WSPTransportAgentBuild)"/>
|
<MakeDir Directories="$(WSPTransportAgentBuild)"/>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="CreateServerBuild" DependsOnTargets="PrepareBuilds">
|
<Target Name="CreateServerBuild" DependsOnTargets="PrepareBuilds">
|
||||||
|
@ -191,7 +190,7 @@
|
||||||
<!-- Do nothing -->
|
<!-- Do nothing -->
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<Target Name="CreateWSPTransportAgentBuild" DependsOnTargets="CreateImportEnterpriseBuild">
|
<Target Name="CreateWSPTransportAgentBuild" DependsOnTargets="CreateImportEnterpriseBuild">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<WSPTransportAgentBuildExclude Include="$(WSPTransportAgentSrc)\**\.svn\**" />
|
<WSPTransportAgentBuildExclude Include="$(WSPTransportAgentSrc)\**\.svn\**" />
|
||||||
<WSPTransportAgentBuildExclude Include="$(WSPTransportAgentSrc)\**\obj\**" />
|
<WSPTransportAgentBuildExclude Include="$(WSPTransportAgentSrc)\**\obj\**" />
|
||||||
|
@ -228,7 +227,7 @@
|
||||||
<ImportCsvInstall>$(ToolsFolder)\Import.CsvBulk</ImportCsvInstall>
|
<ImportCsvInstall>$(ToolsFolder)\Import.CsvBulk</ImportCsvInstall>
|
||||||
<ImportEnterpriseInstall>$(ToolsFolder)\Import.Enterprise</ImportEnterpriseInstall>
|
<ImportEnterpriseInstall>$(ToolsFolder)\Import.Enterprise</ImportEnterpriseInstall>
|
||||||
<AWStatsViewerInstall>$(ToolsFolder)\AWStats.Viewer</AWStatsViewerInstall>
|
<AWStatsViewerInstall>$(ToolsFolder)\AWStats.Viewer</AWStatsViewerInstall>
|
||||||
<WSPTransportAgentInstall>$(ToolsFolder)\WSPTransportAgent</WSPTransportAgentInstall>
|
<WSPTransportAgentInstall>$(ToolsFolder)\WSPTransportAgent</WSPTransportAgentInstall>
|
||||||
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
@ -349,8 +348,8 @@
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<DatabaseFolder>$(DeployFolder)\Database</DatabaseFolder>
|
<DatabaseFolder>$(DeployFolder)\Database</DatabaseFolder>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Target Name="CreateEnterpriseServerDatabase" DependsOnTargets="CreatePortalUpdate">
|
<Target Name="CreateEnterpriseServerDatabase" DependsOnTargets="CreatePortalUpdate">
|
||||||
<MakeDir Directories="$(DatabaseFolder)"/>
|
<MakeDir Directories="$(DatabaseFolder)"/>
|
||||||
|
|
||||||
<Exec Command="$(SqlCmd) -Q "IF DB_ID (N'$(DataBaseName)') IS NOT NULL DROP DATABASE $(DataBaseName)"" />
|
<Exec Command="$(SqlCmd) -Q "IF DB_ID (N'$(DataBaseName)') IS NOT NULL DROP DATABASE $(DataBaseName)"" />
|
||||||
|
@ -461,7 +460,7 @@
|
||||||
<Zip Files="@(ImportCsvInstallFiles)" ZipFileName="$(ToolsFolder)\WebsitePanel-Import-CsvBulk-$(FileVersion).zip" WorkingDirectory="$(ImportCsvInstall)" />
|
<Zip Files="@(ImportCsvInstallFiles)" ZipFileName="$(ToolsFolder)\WebsitePanel-Import-CsvBulk-$(FileVersion).zip" WorkingDirectory="$(ImportCsvInstall)" />
|
||||||
<Zip Files="@(ImportEnterpriseInstallFiles)" ZipFileName="$(ToolsFolder)\WebsitePanel-Import-Enterprise-$(FileVersion).zip" WorkingDirectory="$(ImportEnterpriseInstall)" />
|
<Zip Files="@(ImportEnterpriseInstallFiles)" ZipFileName="$(ToolsFolder)\WebsitePanel-Import-Enterprise-$(FileVersion).zip" WorkingDirectory="$(ImportEnterpriseInstall)" />
|
||||||
<Zip Files="@(AWStatsViewerInstallFiles)" ZipFileName="$(ToolsFolder)\WebsitePanel-AWStatsViewer-$(FileVersion).zip" WorkingDirectory="$(AWStatsViewerInstall)" />
|
<Zip Files="@(AWStatsViewerInstallFiles)" ZipFileName="$(ToolsFolder)\WebsitePanel-AWStatsViewer-$(FileVersion).zip" WorkingDirectory="$(AWStatsViewerInstall)" />
|
||||||
<Zip Files="@(WSPTransportAgentInstallFiles)" ZipFileName="$(ToolsFolder)\WebsitePanel-WSPTransportAgent-$(FileVersion).zip" WorkingDirectory="$(WSPTransportAgentInstall)" />
|
<Zip Files="@(WSPTransportAgentInstallFiles)" ZipFileName="$(ToolsFolder)\WebsitePanel-WSPTransportAgent-$(FileVersion).zip" WorkingDirectory="$(WSPTransportAgentInstall)" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe build.xml /target:Deploy /property:BuildConfiguration=Debug /v:n /fileLogger /m
|
%windir%\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe build.xml /target:Deploy /property:BuildConfiguration=Debug /v:n /fileLogger /m
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue