Made XenOvfApi project use log4net for logging (before it was using own logging,

leftover from the time when the OVF wizards were a XenCenter plugin; the latter
has now been removed).

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2014-01-06 12:31:19 +00:00
parent 7e73622570
commit b191cf5522
13 changed files with 287 additions and 819 deletions

View File

@ -31,7 +31,6 @@
using System;
using System.IO;
using XenCenterLib.Archive;
using XenCenterLib.Compression;
using XenOvf.Definitions;
using XenOvf.Utilities;
@ -40,6 +39,8 @@ namespace XenOvf
{
public class OvfCompressor
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Set to TRUE to Cancel current Compression process.
/// </summary>
@ -167,8 +168,8 @@ namespace XenOvf
{
if (ex is OperationCanceledException)
throw;
Log.Warning("Uncompression issue: {0}", ex);
Log.Warning("Previous warning may be ok, continuing with import, failures continue then this is the issue");
log.WarnFormat("Uncompression issue: {0}", ex);
log.Warn("Previous warning may be ok, continuing with import, failures continue then this is the issue");
}
finally
{
@ -202,12 +203,12 @@ namespace XenOvf
{
if (file.compression == null)
{
Log.Info("File {0} was not marked as compressed, skipped.", file.href);
log.InfoFormat("File {0} was not marked as compressed, skipped.", file.href);
continue;
}
if (file.compression.ToLower() != "gzip" && file.compression.ToLower() != "bzip2")
{
Log.Error("Invalid compression method File: {0} Method: {1}, must be Gzip or BZip2", file.href, file.compression);
log.ErrorFormat("Invalid compression method File: {0} Method: {1}, must be Gzip or BZip2", file.href, file.compression);
continue;
}
@ -251,14 +252,14 @@ namespace XenOvf
}
catch (EndOfStreamException eose)
{
Log.Error("End of Stream: {0}", eose.Message);
log.ErrorFormat("End of Stream: {0}", eose.Message);
}
catch (Exception ex)
{
if (ex is OperationCanceledException)
throw;
var message = string.Format(Messages.COMPRESS_FAILED, filename);
Log.Error("{0} {1}", message, ex.Message);
log.ErrorFormat("{0} {1}", message, ex.Message);
throw new Exception(message, ex);
}
finally

View File

@ -153,13 +153,13 @@ namespace XenOvf
{
if (Properties.Settings.Default.useGZip)
{
Log.Info("OVF.ConvertOVFtoOVA GZIP compression stream inserted");
log.Info("OVF.ConvertOVFtoOVA GZIP compression stream inserted");
FileStream fsStream = new FileStream(ovafilename + ".gz", FileMode.CreateNew, FileAccess.Write, FileShare.None);
ovaStream = CompressionFactory.Writer(CompressionFactory.Type.Gz, fsStream);
}
else
{
Log.Info("OVF.ConvertOVFtoOVA BZIP2 compression stream inserted");
log.Info("OVF.ConvertOVFtoOVA BZIP2 compression stream inserted");
FileStream fsStream = new FileStream(ovafilename + ".bz2", FileMode.CreateNew, FileAccess.Write, FileShare.None);
ovaStream = CompressionFactory.Writer(CompressionFactory.Type.Bz2, fsStream);
}
@ -178,7 +178,7 @@ namespace XenOvf
if (File.Exists(ovfFileName))
{
Log.Info("OVF.ConvertOVFtoOVA: added file: {0}", ovfFileName);
log.InfoFormat("OVF.ConvertOVFtoOVA: added file: {0}", ovfFileName);
AddFileToArchiveWriter(tar, ovfFileName);
if (cleanup) File.Delete(ovfFileName);
}
@ -191,13 +191,13 @@ namespace XenOvf
if (File.Exists(manifestfile))
{
AddFileToArchiveWriter(tar, manifestfile);
Log.Info("OVF.ConvertOVFtoOVA: added file: {0}", manifestfile);
log.InfoFormat("OVF.ConvertOVFtoOVA: added file: {0}", manifestfile);
if (cleanup) File.Delete(manifestfile);
// Cannot exist with out manifest file.
if (File.Exists(signaturefile))
{
AddFileToArchiveWriter(tar, signaturefile);
Log.Info("OVF.ConvertOVFtoOVA: added file: {0}", signaturefile);
log.InfoFormat("OVF.ConvertOVFtoOVA: added file: {0}", signaturefile);
if (cleanup) File.Delete(signaturefile);
}
}
@ -208,7 +208,7 @@ namespace XenOvf
foreach (File_Type file in filelist)
{
AddFileToArchiveWriter(tar, file.href);
Log.Info("OVF.ConvertOVFtoOVA: added file: {0}", file.href);
log.InfoFormat("OVF.ConvertOVFtoOVA: added file: {0}", file.href);
if (cleanup) File.Delete(file.href);
}
}
@ -223,7 +223,7 @@ namespace XenOvf
}
catch (Exception ex)
{
Log.Error("{0} {1}", Messages.CONVERSION_FAILED, ex.Message);
log.ErrorFormat("{0} {1}", Messages.CONVERSION_FAILED, ex.Message);
throw new Exception(Messages.CONVERSION_FAILED, ex);
}
finally
@ -235,7 +235,7 @@ namespace XenOvf
File.Delete(_touchFile);
}
}
Log.Debug("OVF.ConvertOVFtoOVA completed");
log.Debug("OVF.ConvertOVFtoOVA completed");
}
private static void AddFileToArchiveWriter(ArchiveWriter tar, string fileName)
@ -288,7 +288,7 @@ namespace XenOvf
}
#endregion
FinalizeEnvelope(env);
Log.Debug("OVF.Create completed, {0}", ovfName);
log.DebugFormat("OVF.Create completed, {0}", ovfName);
return env;
}
/// <summary>
@ -317,7 +317,7 @@ namespace XenOvf
XenXva xenobj = Tools.DeserializeOvaXml(ovaxml);
EnvelopeType env = ConvertFromXenOVA(xenobj, vhdExports, ovfFilePath, ovfName, lang);
string xmlstring = Tools.Serialize(env, typeof(EnvelopeType), Tools.LoadNamespaces());
Log.Debug("OVF.ConvertXVAtoOVF completed");
log.Debug("OVF.ConvertXVAtoOVF completed");
return xmlstring;
}
/// <summary>
@ -438,7 +438,7 @@ namespace XenOvf
{
EnvelopeType env = ConvertFromHyperVXml(hvobj, ovfName, lang);
xmlstring = Tools.Serialize(env, typeof(EnvelopeType), Tools.LoadNamespaces());
Log.Debug("XenOvf::ConvertHyperVtoOVF completed");
log.Debug("XenOvf::ConvertHyperVtoOVF completed");
}
else
{
@ -594,7 +594,7 @@ namespace XenOvf
}
else
{
Log.Error("Could not find the details for disk, {0}", reference);
log.ErrorFormat("Could not find the details for disk, {0}", reference);
}
AtVDI = false;
}
@ -612,7 +612,7 @@ namespace XenOvf
}
}
FinalizeEnvelope(env);
Log.Debug("OVF.ConvertFromXenOVA completed {0}", ovfname);
log.DebugFormat("OVF.ConvertFromXenOVA completed {0}", ovfname);
mappings.Clear();
return env;
}
@ -673,7 +673,7 @@ namespace XenOvf
}
FinalizeEnvelope(env);
Log.Debug("OVF.ConvertFromXenOVAv1 completed {0}", ovfname);
log.DebugFormat("OVF.ConvertFromXenOVAv1 completed {0}", ovfname);
mappings.Clear();
return env;
}
@ -971,7 +971,7 @@ namespace XenOvf
}
FinalizeEnvelope(env);
Log.Debug("OVF.ConvertFromVPCXml completed {0}", ovfname);
log.DebugFormat("OVF.ConvertFromVPCXml completed {0}", ovfname);
mappings.Clear();
return env;
}
@ -1138,7 +1138,7 @@ namespace XenOvf
AddOtherSystemSettingData(env, vsId, lang, "HVM_boot_params", Properties.Settings.Default.xenBootOrder, _ovfrm.GetString("XENSERVER_SPECIFIC_DESCRIPTION"));
AddOtherSystemSettingData(env, vsId, lang, "platform", Properties.Settings.Default.xenPlatformSetting, _ovfrm.GetString("XENSERVER_PLATFORM_DESCRIPTION"));
FinalizeEnvelope(env);
Log.Debug("OVF.ConvertFromVMXcfg completed {0}", ovfname);
log.DebugFormat("OVF.ConvertFromVMXcfg completed {0}", ovfname);
mappings.Clear();
return env;
}
@ -1265,7 +1265,7 @@ namespace XenOvf
}
}
}
Log.Debug("OVF.TransformXvaOvf_VM completed {0}", vsId);
log.DebugFormat("OVF.TransformXvaOvf_VM completed {0}", vsId);
}
private void TransformXvaOvf_VBD(EnvelopeType env, string vsId, string lang, XenStruct vmstruct)
{
@ -1374,7 +1374,7 @@ namespace XenOvf
{
AddCDROM(env, vsId, diskId, caption, description);
}
Log.Debug("OVF.TransformXvaOvf_VBD completed {0}", vsId);
log.DebugFormat("OVF.TransformXvaOvf_VBD completed {0}", vsId);
}
private void TransformXvaOvf_VIF(EnvelopeType env, string vsId, string lang, XenStruct vmstruct)
{
@ -1420,7 +1420,7 @@ namespace XenOvf
}
}
AddNetwork(env, vsId, lang, vifuuid, null, mac);
Log.Debug("OVF.TransformXvaOvf_VIF completed {0}", vsId);
log.DebugFormat("OVF.TransformXvaOvf_VIF completed {0}", vsId);
}
private void TransformXvaOvf_Network(EnvelopeType env, string vsId, string lang, string refId, XenStruct vmstruct)
{
@ -1459,7 +1459,7 @@ namespace XenOvf
break;
}
}
Log.Debug("OVF.TransformXvaOvf_Network completed {0}", vsId);
log.DebugFormat("OVF.TransformXvaOvf_Network completed {0}", vsId);
}
private void TransformXvaOvf_VDI(EnvelopeType env, string vsId, string lang, string refId, DiskInfo di, XenStruct vmstruct)
{
@ -1490,7 +1490,7 @@ namespace XenOvf
}
freespace = capacity - filesize;
UpdateDisk(env, vsId, instanceId, description, vhdfilename, filesize, capacity, freespace);
Log.Debug("OVF.TransformXvaOvf_VDI completed {0}", vsId);
log.DebugFormat("OVF.TransformXvaOvf_VDI completed {0}", vsId);
}
private void TransformXvaOvf_SR(EnvelopeType env, string vsId, string lang, XenStruct vmstruct)
{
@ -1499,7 +1499,7 @@ namespace XenOvf
// even if the VM is in this SR it may not exist in the target server therefore
// it is not required in the OVF.
//
Log.Debug("OVF.TransformXvaOvf_SR completed {0}", vsId);
log.DebugFormat("OVF.TransformXvaOvf_SR completed {0}", vsId);
}
@ -1530,11 +1530,11 @@ namespace XenOvf
Win32_ComputerSystem = mgtobj; // only want one.
break;
}
Log.Debug("OVF.CollectionInformation {0}.{1}", "Win32_ComputerSystem", 1);
log.Debug("OVF.CollectionInformation Win32_ComputerSystem.1");
}
catch (Exception ex)
{
Log.Warning("OVF.CollectionInformation: call to Win32_ComputerSystem failed. Exception: {0}", ex.Message);
log.WarnFormat("OVF.CollectionInformation: call to Win32_ComputerSystem failed. Exception: {0}", ex.Message);
}
finally
{
@ -1553,11 +1553,11 @@ namespace XenOvf
Win32_Processor.Add(mgtobj); // only want one.
break;
}
Log.Debug("OVF.CollectionInformation {0}.{1}", "Win32_Processor", Win32_Processor.Count);
log.DebugFormat("OVF.CollectionInformation Win32_Processor.{0}", Win32_Processor.Count);
}
catch (Exception ex)
{
Log.Warning("OVF.CollectionInformation: call to Win32_Processor failed. Exception: {0}", ex.Message);
log.WarnFormat("OVF.CollectionInformation: call to Win32_Processor failed. Exception: {0}", ex.Message);
}
finally
{
@ -1575,11 +1575,11 @@ namespace XenOvf
{
Win32_CDROMDrive.Add(mgtobj);
}
Log.Debug("OVF.CollectionInformation {0}.{1}", "Win32_CDROMDrive", Win32_CDROMDrive.Count);
log.DebugFormat("OVF.CollectionInformation Win32_CDROMDrive.{0}", Win32_CDROMDrive.Count);
}
catch (Exception ex)
{
Log.Warning("OVF.CollectionInformation: call to Win32_CDROMDrive failed. Exception: {0}", ex.Message);
log.WarnFormat("OVF.CollectionInformation: call to Win32_CDROMDrive failed. Exception: {0}", ex.Message);
}
finally
{
@ -1597,11 +1597,11 @@ namespace XenOvf
{
Win32_DiskDrive.Add(mgtobj);
}
Log.Debug("OVF.CollectionInformation {0}.{1}", "Win32_DiskDrive", Win32_DiskDrive.Count);
log.DebugFormat("OVF.CollectionInformation Win32_DiskDrive.{0}", Win32_DiskDrive.Count);
}
catch (Exception ex)
{
Log.Warning("OVF.CollectionInformation: call to Win32_CDROMDrive failed. Exception: {0}", ex.Message);
log.WarnFormat("OVF.CollectionInformation: call to Win32_CDROMDrive failed. Exception: {0}", ex.Message);
}
finally
{
@ -1619,11 +1619,11 @@ namespace XenOvf
{
Win32_NetworkAdapter.Add(mgtobj);
}
Log.Debug("OVF.CollectionInformation {0}.{1}", "Win32_NetworkAdapter", Win32_NetworkAdapter.Count);
log.DebugFormat("OVF.CollectionInformation Win32_NetworkAdapter.{0}", Win32_NetworkAdapter.Count);
}
catch (Exception ex)
{
Log.Warning("OVF.CollectionInformation: call to Win32_NetworkAdapter failed. Exception: {0}", ex.Message);
log.WarnFormat("OVF.CollectionInformation: call to Win32_NetworkAdapter failed. Exception: {0}", ex.Message);
}
finally
{
@ -1641,11 +1641,11 @@ namespace XenOvf
{
Win32_IDEController.Add(mgtobj);
}
Log.Debug("OVF.CollectionInformation {0}.{1}", "Win32_IDEController", Win32_IDEController.Count);
log.DebugFormat("OVF.CollectionInformation Win32_IDEController.{0}", Win32_IDEController.Count);
}
catch (Exception ex)
{
Log.Warning("OVF.CollectionInformation: call for Win32_IDEController failed. Exception: {0}", ex.Message);
log.WarnFormat("OVF.CollectionInformation: call for Win32_IDEController failed. Exception: {0}", ex.Message);
}
finally
{
@ -1663,11 +1663,11 @@ namespace XenOvf
{
Win32_SCSIController.Add(mgtobj);
}
Log.Debug("OVF.CollectionInformation {0}.{1}", "Win32_SCSIController", Win32_SCSIController.Count);
log.DebugFormat("OVF.CollectionInformation Win32_SCSIController.{0}", Win32_SCSIController.Count);
}
catch (Exception ex)
{
Log.Warning("OVF.CollectionInformation: call for Win32_SCSIController failed. Exception: {0}", ex.Message);
log.WarnFormat("OVF.CollectionInformation: call for Win32_SCSIController failed. Exception: {0}", ex.Message);
}
finally
{
@ -1685,11 +1685,11 @@ namespace XenOvf
{
Win32_DiskPartition.Add(mgtobj);
}
Log.Debug("OVF.CollectionInformation {0}.{1}", "Win32_DiskPartition", Win32_DiskPartition.Count);
log.DebugFormat("OVF.CollectionInformation Win32_DiskPartition.{0}", Win32_DiskPartition.Count);
}
catch (Exception ex)
{
Log.Warning("OVF.CollectionInformation: call for Win32_DiskPartition failed. Exception: {0}", ex.Message);
log.WarnFormat("OVF.CollectionInformation: call for Win32_DiskPartition failed. Exception: {0}", ex.Message);
}
finally
{
@ -1707,11 +1707,11 @@ namespace XenOvf
{
Win32_DiskDriveToDiskPartition.Add(mgtobj);
}
Log.Debug("OVF.CollectionInformation {0}.{1}", "Win32_DiskDriveToDiskPartition", Win32_DiskDriveToDiskPartition.Count);
log.DebugFormat("OVF.CollectionInformation Win32_DiskDriveToDiskPartition.{0}", Win32_DiskDriveToDiskPartition.Count);
}
catch (Exception ex)
{
Log.Warning("OVF.CollectionInformation: call for Win32_DiskDriveToDiskPartition failed, Exception: {0}", ex.Message);
log.WarnFormat("OVF.CollectionInformation: call for Win32_DiskDriveToDiskPartition failed, Exception: {0}", ex.Message);
}
finally
{
@ -1781,9 +1781,9 @@ namespace XenOvf
description,
Guid.NewGuid().ToString(),
"301");
Log.Warning("System definition not available, created defaults");
log.Warn("System definition not available, created defaults");
}
Log.Debug("OVF.AddVssd completed");
log.Debug("OVF.AddVssd completed");
}
private void AddNetworks(EnvelopeType ovfEnv, string vsId)
@ -1880,9 +1880,9 @@ namespace XenOvf
}
else
{
Log.Warning("No networks defined, If a network interface is required, the administrator will need to add it after import of OVF/OVA Package.");
log.Warn("No networks defined, If a network interface is required, the administrator will need to add it after import of OVF/OVA Package.");
}
Log.Debug("OVF.AddNetworks completed {0}", vsId);
log.DebugFormat("OVF.AddNetworks completed {0}", vsId);
}
private void AddCPUs(EnvelopeType ovfEnv, string vsId)
@ -1917,9 +1917,9 @@ namespace XenOvf
else
{
SetCPUs(ovfEnv, vsId, 1);
Log.Warning("OVF.AddCPUs, set using default (1) CPU");
log.Warn("OVF.AddCPUs, set using default (1) CPU");
}
Log.Debug("OVF.AddCPUs completed {0} cpus {1}", vsId, cpucount);
log.DebugFormat("OVF.AddCPUs completed {0} cpus {1}", vsId, cpucount);
}
private void AddMemory(EnvelopeType ovfEnv, string vsId)
@ -1951,11 +1951,11 @@ namespace XenOvf
}
else
{
Log.Warning("OVF.AddMemory: could not determine system memory, defaulting to 512MB");
log.Warn("OVF.AddMemory: could not determine system memory, defaulting to 512MB");
memory = 512L;
}
SetMemory(ovfEnv, vsId, memory, "byte * 2^20");
Log.Debug("OVF.AddMemory completed {0} memory {1} ({2})", vsId, memory, "byte * 2 ^ 20");
log.DebugFormat("OVF.AddMemory completed {0} memory {1} (byte * 2 ^ 20)", vsId, memory);
}
private void CreateConnectedDevices(EnvelopeType ovfEnv, string vsId, DiskInfo[] vhdExports)
@ -1987,7 +1987,7 @@ namespace XenOvf
if (deviceid == null)
{
Log.Trace("No device id defined, continuing");
traceLog.Debug("No device id defined, continuing");
continue;
}
List<ManagementObject> ControllerAssociations = FindDeviceReferences("Win32_IDEControllerDevice", deviceid);
@ -2007,7 +2007,7 @@ namespace XenOvf
}
if (_dependent == null)
{
Log.Trace("PCI Association not available, continuing.");
traceLog.Debug("PCI Association not available, continuing.");
continue;
}
#endregion
@ -2018,7 +2018,7 @@ namespace XenOvf
if (startswith.ToUpper().StartsWith(@"IDEDISK"))
{
Log.Debug("OVF.CreateConnectedDevices Checking IDEDISK");
log.Debug("OVF.CreateConnectedDevices Checking IDEDISK");
foreach (ManagementObject md in Win32_DiskDrive)
{
#region FIND BY PROPERTIES NOT EXPLICID
@ -2052,7 +2052,7 @@ namespace XenOvf
{
try
{
Log.Debug("OVF.CreateConnectedDevices: Dependent: {0} Device: {1}", dependentId, _deviceid);
log.DebugFormat("OVF.CreateConnectedDevices: Dependent: {0} Device: {1}", dependentId, _deviceid);
string diskInstanceId = Guid.NewGuid().ToString();
int lastAmp = dependentId.LastIndexOf('&');
if (lastAmp < 0) lastAmp = 0;
@ -2075,12 +2075,12 @@ namespace XenOvf
Convert.ToUInt64(di.PhysicalSize), Convert.ToUInt64(di.CapacitySize));
AddDeviceToController(ovfEnv, vsId, diskInstanceId, controllerInstanceId, address);
di.Added = true;
Log.Debug("OVF.CreateConnectedDevices: {0} ({1}) added to {2}", di.DriveId, di.VhdFileName, dependentId);
log.DebugFormat("OVF.CreateConnectedDevices: {0} ({1}) added to {2}", di.DriveId, di.VhdFileName, dependentId);
}
catch (Exception ex)
{
string msg = string.Format("{0} [{1}] controller connection could not be identified.", "IDEDISK", _pnpdeviceid);
Log.Error("OVF.CreateConnectedDevices: {0}", msg);
log.ErrorFormat("OVF.CreateConnectedDevices: {0}", msg);
throw new Exception(msg, ex);
}
}
@ -2090,7 +2090,7 @@ namespace XenOvf
}
else if (startswith.ToUpper().StartsWith(@"IDECDROM"))
{
Log.Debug("OVF.CreateConnectedDevices Checking IDECDROM");
log.Debug("OVF.CreateConnectedDevices Checking IDECDROM");
foreach (ManagementObject md in Win32_CDROMDrive)
{
#region FIND BY PROPERTIES NOT EXPLICID
@ -2104,14 +2104,14 @@ namespace XenOvf
}
if (_pnpdeviceid == null)
{
Log.Trace("PNPDeviceID not available, continuing.");
traceLog.Debug("PNPDeviceID not available, continuing.");
continue;
}
#endregion
_pnpdeviceid = _pnpdeviceid.Replace(@"\", "");
if (_pnpdeviceid.Equals(dependentId))
{
Log.Debug("OVF.CreateConnectedDevices: Dependent: {0} Device: {1}", dependentId, _pnpdeviceid);
log.DebugFormat("OVF.CreateConnectedDevices: Dependent: {0} Device: {1}", dependentId, _pnpdeviceid);
try
{
string diskInstanceId = Guid.NewGuid().ToString();
@ -2127,11 +2127,11 @@ namespace XenOvf
}
AddCDROM(ovfEnv, vsId, diskInstanceId, _ovfrm.GetString("RASD_16_CAPTION"), _ovfrm.GetString("RASD_16_ELEMENTNAME"));
AddDeviceToController(ovfEnv, vsId, diskInstanceId, controllerInstanceId, address);
Log.Debug("OVF.CreateConnectedDevices: {0} added to {1}", "CDROM", dependentId);
log.DebugFormat("OVF.CreateConnectedDevices: CDROM added to {0}", dependentId);
}
catch
{
Log.Warning("OVF.CreateConnectedDevices: {0} [{1}] controller connection could not be identified, skipped.", "CDROM", _pnpdeviceid);
log.WarnFormat("OVF.CreateConnectedDevices: CDROM [{0}] controller connection could not be identified, skipped.", _pnpdeviceid);
}
}
}
@ -2141,9 +2141,9 @@ namespace XenOvf
}
else
{
Log.Info("OVF.CreateConnectedDevices NO IDE controllers detected.");
log.Info("OVF.CreateConnectedDevices NO IDE controllers detected.");
}
Log.Debug("OVF.CreateConnectedDevices IDE Controllers completed.");
log.Debug("OVF.CreateConnectedDevices IDE Controllers completed.");
#endregion
#region SCSI
@ -2162,7 +2162,7 @@ namespace XenOvf
}
if (_deviceid == null)
{
Log.Trace("SCSI DeviceID not available, continuing.");
traceLog.Debug("SCSI DeviceID not available, continuing.");
continue;
}
#endregion
@ -2171,7 +2171,7 @@ namespace XenOvf
if (ControllerAssociations == null || ControllerAssociations.Count <= 0)
{
Log.Trace("No Controller associations for {0}", _deviceid);
traceLog.DebugFormat("No Controller associations for {0}", _deviceid);
continue;
}
@ -2189,7 +2189,7 @@ namespace XenOvf
}
if (_dependent == null)
{
Log.Trace("SCSI Association not available, continuing.");
traceLog.Debug("SCSI Association not available, continuing.");
continue;
}
#endregion
@ -2244,7 +2244,7 @@ namespace XenOvf
}
if (__deviceid == null)
{
Log.Trace("SCSI DeviceID not available, continuing.");
traceLog.Debug("SCSI DeviceID not available, continuing.");
continue;
}
#endregion
@ -2262,7 +2262,7 @@ namespace XenOvf
AddDisk(ovfEnv, vsId, diskInstanceId, lang, di.VhdFileName, bootable, _ovfrm.GetString("RASD_19_CAPTION"), _description, Convert.ToUInt64(di.PhysicalSize), Convert.ToUInt64(di.CapacitySize));
AddDeviceToController(ovfEnv, vsId, diskInstanceId, controllerInstanceId, Convert.ToString(__scsiport));
di.Added = true;
Log.Debug("CreateConnectedDevices: {0} ({1}) added to {2}", di.DriveId, di.VhdFileName, dependentId);
log.DebugFormat("CreateConnectedDevices: {0} ({1}) added to {2}", di.DriveId, di.VhdFileName, dependentId);
}
}
}
@ -2308,7 +2308,7 @@ namespace XenOvf
}
if (__deviceid == null)
{
Log.Trace("SCSI DeviceID not available, continuing.");
traceLog.Debug("SCSI DeviceID not available, continuing.");
continue;
}
#endregion
@ -2319,7 +2319,7 @@ namespace XenOvf
string caption = string.Format(_ovfrm.GetString("RASD_CONTROLLER_SCSI_DESCRIPTION"), __scsibus, __scsilogicalunit, __scsiport, __scsitargetid);
AddCDROM(ovfEnv, vsId, diskInstanceId, caption, _ovfrm.GetString("RASD_16_DESCRIPTION"));
AddDeviceToController(ovfEnv, vsId, diskInstanceId, controllerInstanceId, Convert.ToString(__scsiport));
Log.Debug("CreateConnectedDevices: {0} added to {1}", "CDROM", dependentId);
log.DebugFormat("CreateConnectedDevices: CDROM added to {0}", dependentId);
}
}
}
@ -2328,9 +2328,9 @@ namespace XenOvf
}
else
{
Log.Info("OVF.CreateConnectedDevices no SCSI Controllers detected.");
log.Info("OVF.CreateConnectedDevices no SCSI Controllers detected.");
}
Log.Debug("OVF.CreateConnectedDevices SCSI Controllers completed {0} ", vsId);
log.DebugFormat("OVF.CreateConnectedDevices SCSI Controllers completed {0} ", vsId);
#endregion
#region OTHER CONTROLLER DISKS
@ -2369,10 +2369,10 @@ namespace XenOvf
bool bootable = IsBootDisk(di.DriveId);
AddDisk(ovfEnv, vsId, diskInstanceId, lang, di.VhdFileName, bootable, _ovfrm.GetString("RASD_19_CAPTION"), _mediatype, Convert.ToUInt64(di.PhysicalSize), Convert.ToUInt64(di.CapacitySize));
di.Added = true;
Log.Debug("CreateConnectedDevices: {0} ({1}) added to {2}", di.DriveId, di.VhdFileName, _mediatype);
log.DebugFormat("CreateConnectedDevices: {0} ({1}) added to {2}", di.DriveId, di.VhdFileName, _mediatype);
}
}
Log.Debug("OVF.CreateConnectedDevices OTHER Controllers completed {0} ", vsId);
log.DebugFormat("OVF.CreateConnectedDevices OTHER Controllers completed {0} ", vsId);
#endregion
#region CHECK ALL DISKS WERE DEFINED
@ -2382,14 +2382,14 @@ namespace XenOvf
{
AddDisk(ovfEnv, vsId, Guid.NewGuid().ToString(), lang, di.VhdFileName, false, _ovfrm.GetString("RASD_19_CAPTION"), _ovfrm.GetString("RASD_19_DESCRIPTION"), Convert.ToUInt64(di.PhysicalSize), Convert.ToUInt64(di.CapacitySize));
di.Added = true;
Log.Warning("CreateConnectedDevices: MANUAL Update of OVF REQUIRED TO DEFINE: Disk Size and Capacity");
Log.Warning("CreateConnectedDevices: {0} ({1}) NOT FOUND, added as Unknown with 0 Size", di.DriveId, di.VhdFileName);
log.Warn("CreateConnectedDevices: MANUAL Update of OVF REQUIRED TO DEFINE: Disk Size and Capacity");
log.WarnFormat("CreateConnectedDevices: {0} ({1}) NOT FOUND, added as Unknown with 0 Size", di.DriveId, di.VhdFileName);
}
}
#endregion
Log.Debug("OVF.CreateConnectedDevices completed {0} ", vsId);
log.DebugFormat("OVF.CreateConnectedDevices completed {0} ", vsId);
}
#endregion
}
}
}

View File

@ -47,6 +47,10 @@ namespace XenOvf
{
public partial class OVF
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly log4net.ILog auditLog = log4net.LogManager.GetLogger("Audit");
private static readonly log4net.ILog traceLog = log4net.LogManager.GetLogger("Trace");
/// <summary>
/// Event Registration of changes in Ovf state.
/// </summary>
@ -83,8 +87,8 @@ namespace XenOvf
public OVF()
{
UnLoad();
Log.Info("XenOvf.Message.resources {0}", Messages.RESOURCES_LOADED);
Log.Info("XenOvf.Content.resources {0}", Messages.RESOURCES_LOADED);
log.InfoFormat("XenOvf.Message.resources {0}", Messages.RESOURCES_LOADED);
log.InfoFormat("XenOvf.Content.resources {0}", Messages.RESOURCES_LOADED);
}
#endregion
@ -141,10 +145,15 @@ namespace XenOvf
/// <param name="filename"></param>
public static void SaveAs(string OvfXml, string filename)
{
Log.Debug("OVF.SaveAs: {0}", filename);
if (OvfXml == null || filename == null)
log.DebugFormat("OVF.SaveAs: {0}", filename);
if (OvfXml == null)
{
Log.Error("SaveAs::NULL input cannot save OvfXml[{0}] Filename[{1}]", (OvfXml == null) ? "NULL" : "OK", (filename == null) ? "NULL" : "OK");
log.Error("SaveAs: cannot save NULL string OvfXml");
throw new ArgumentNullException();
}
if (filename == null)
{
log.Error("SaveAs: cannot save OvfXml. Filename was NULL");
throw new ArgumentNullException();
}
@ -162,7 +171,7 @@ namespace XenOvf
}
catch (Exception ex)
{
Log.Error("File handling error. {0}", ex.Message);
log.ErrorFormat("File handling error. {0}", ex.Message);
}
FileStream fs = null;
StreamWriter sw = null;
@ -175,8 +184,8 @@ namespace XenOvf
}
catch (Exception ex)
{
Log.Error("SaveAs FAILED: {0} with {1}", filename, ex.Message);
throw ex;
log.ErrorFormat("SaveAs FAILED: {0} with {1}", filename, ex.Message);
throw;
}
finally
{
@ -184,7 +193,7 @@ namespace XenOvf
if (fs != null) fs.Close();
}
if (File.Exists(oldfile)) { File.Delete(oldfile); }
Log.Debug("OVF.SaveAs completed");
log.Debug("OVF.SaveAs completed");
}
#endregion
@ -264,12 +273,12 @@ namespace XenOvf
{
if (File.Exists(findfile))
{
Log.Info("File: OVF: {0} found file with (.{1}) extension", filename, extension);
log.InfoFormat("File: OVF: {0} found file with (.{1}) extension", filename, extension);
foundfile = true;
}
else
{
Log.Info("File: OVF: {0} did not find file with (.{1}) extension", filename, extension);
log.InfoFormat("File: OVF: {0} did not find file with (.{1}) extension", filename, extension);
foundfile = false;
}
}
@ -287,7 +296,7 @@ namespace XenOvf
{
if (ext.ToLower().EndsWith("gz") || ext.ToLower().EndsWith("bz2")) // need to decompress.
{
Log.Info("OVA is compressed, de-compression stream inserted");
log.Info("OVA is compressed, de-compression stream inserted");
string ovaext = Path.GetExtension(ovfname);
if (ovaext.ToLower().EndsWith("ova"))
{
@ -333,10 +342,10 @@ namespace XenOvf
while(tar.HasNext())
{
string ovaext = Path.GetExtension(tar.CurrentFileName());
Log.Debug("OVA: File: {0}", tar.CurrentFileName());
log.DebugFormat("OVA: File: {0}", tar.CurrentFileName());
if (tar.CurrentFileName() != null && ovaext.ToLower().Contains(extension.ToLower()))
{
Log.Info("OVF: File: {0} found file with (.{1}) extension", tar.CurrentFileName(), extension);
log.InfoFormat("OVF: File: {0} found file with (.{1}) extension", tar.CurrentFileName(), extension);
foundfile = true;
break;
}
@ -352,7 +361,7 @@ namespace XenOvf
}
catch (Exception ex)
{
Log.Error("OVA search FAILED with {0}", ex.Message);
log.ErrorFormat("OVA search FAILED with {0}", ex.Message);
throw;
}
finally
@ -365,7 +374,7 @@ namespace XenOvf
}
else
{
Log.Info("Unknown extension {0}", ext);
log.InfoFormat("Unknown extension {0}", ext);
foundfile = false;
}
return foundfile;
@ -460,7 +469,7 @@ namespace XenOvf
AddRasdToAllVHS(ovfObj, vsId, rasd);
Log.Debug("OVF.AddCDDrive completed");
log.Debug("OVF.AddCDDrive completed");
return rasd.InstanceID.Value;
}
/// <summary>
@ -495,7 +504,7 @@ namespace XenOvf
AddControllerToVHS(vhs, lang, type, deviceId, iteration);
}
Log.Debug("OVF.AddController completed");
log.Debug("OVF.AddController completed");
}
/// <summary>
/// Add a controller to the mix.
@ -555,7 +564,7 @@ namespace XenOvf
vhs.Item = rasds.ToArray();
Log.Debug("OVF.AddController completed");
log.Debug("OVF.AddController completed");
}
/// <summary>
///
@ -666,7 +675,7 @@ namespace XenOvf
}
}
}
Log.Debug("OVF.AddDeviceToController completed");
log.Debug("OVF.AddDeviceToController completed");
return;
}
/// <summary>
@ -797,7 +806,7 @@ namespace XenOvf
ovfEnv.Sections = sections.ToArray();
ovfEnv.References.File = files.ToArray();
Log.Debug("OVF.AddDisk completed");
log.Debug("OVF.AddDisk completed");
}
/// <summary>
///
@ -1095,7 +1104,7 @@ namespace XenOvf
netsection.Network = ns.ToArray();
sections.Add(netsection);
ovfEnv.Sections = sections.ToArray();
Log.Debug("OVF.AddNetwork completed");
log.Debug("OVF.AddNetwork completed");
}
/// <summary>
///
@ -1171,7 +1180,7 @@ namespace XenOvf
throw new ArgumentNullException(Messages.FAILED_TO_ADD_OS_SECTION);
}
AddContent((VirtualSystemCollection_Type)ovfEnv.Item, vsId, oss);
Log.Debug("OVF.AddOperatingSystemSection completed {0}", vsId);
log.DebugFormat("OVF.AddOperatingSystemSection completed {0}", vsId);
}
/// <summary>
///
@ -1211,7 +1220,7 @@ namespace XenOvf
if (vhs == null)
{
Log.Warning("OVF.AddOtherSystemSettingData: could not find 'xen' or 'hvm' system type VHS, skipping.");
log.Warn("OVF.AddOtherSystemSettingData: could not find 'xen' or 'hvm' system type VHS, skipping.");
return null;
}
@ -1238,7 +1247,7 @@ namespace XenOvf
xencfg.Add(xenother);
vhs.VirtualSystemOtherConfigurationData = xencfg.ToArray();
Log.Debug("OVF.AddOtherSystemSettingData completed");
log.Debug("OVF.AddOtherSystemSettingData completed");
return xenother.id;
}
@ -1457,7 +1466,7 @@ namespace XenOvf
string elementname = _ovfrm.GetString("RASD_UNKNOWN_ELEMENTNAME");
if (lRasd.ElementName != null && !string.IsNullOrEmpty(lRasd.ElementName.Value))
elementname = lRasd.ElementName.Value;
Log.Debug("OVF.AddRasd added: {0}:{1}", elementname, lRasd.InstanceID.Value);
log.DebugFormat("OVF.AddRasd added: {0}:{1}", elementname, lRasd.InstanceID.Value);
return lRasd.InstanceID.Value;
}
/// <summary>
@ -1586,7 +1595,7 @@ namespace XenOvf
sections.Add(startupSection);
env.Sections = sections.ToArray();
Log.Debug("OVF.AddStartupOptions completed");
log.Debug("OVF.AddStartupOptions completed");
return startupSection.Id;
}
@ -1685,7 +1694,7 @@ namespace XenOvf
throw new ArgumentNullException(Messages.FAILED_TO_ADD_VIRTUAL_HARDWARE_SECTION);
}
AddContent((VirtualSystemCollection_Type)ovfEnv.Item, vsId, vhs);
Log.Debug("OVF.AddVirtualHardwareSection completed {0}", vsId);
log.DebugFormat("OVF.AddVirtualHardwareSection completed {0}", vsId);
return vhs.Id;
}
/// <summary>
@ -1750,7 +1759,7 @@ namespace XenOvf
AddVirtualSystem(ovfObj, vs);
AddOperatingSystemSection(ovfObj, vs.id, lang, null, null);
Log.Debug("OVF.AddVirtualSystem(obj,lang,ovfname) completed");
log.Debug("OVF.AddVirtualSystem(obj,lang,ovfname) completed");
return vs.id;
}
/// <summary>
@ -1771,7 +1780,7 @@ namespace XenOvf
}
virtualsystems.Add(vs);
((VirtualSystemCollection_Type)ovfEnv.Item).Content = virtualsystems.ToArray();
Log.Debug("OVF.AddVirtualSystem(obj, vs)");
log.Debug("OVF.AddVirtualSystem(obj, vs)");
}
/// <summary>
///
@ -1819,7 +1828,7 @@ namespace XenOvf
}
vhs.System = vssd;
Log.Debug("OVF.AddVirtualSystemSettingData completed");
log.Debug("OVF.AddVirtualSystemSettingData completed");
}
#endregion
@ -1882,7 +1891,7 @@ namespace XenOvf
vscontent.id = Guid.NewGuid().ToString();
vscontent.Content = null;
Log.Debug("OVF.CreateEnvelope {0} created {1}", ovfEnv.Name, ovfEnv.id);
log.DebugFormat("OVF.CreateEnvelope {0} created {1}", ovfEnv.Name, ovfEnv.id);
return ovfEnv;
}
@ -1974,7 +1983,7 @@ namespace XenOvf
rasd.Connection[0].Value = sb.ToString();
}
}
Log.Debug("OVF.RemoveConnectionInRASD completed {0}", vsId);
log.DebugFormat("OVF.RemoveConnectionInRASD completed {0}", vsId);
return rasd;
}
/// <summary>
@ -2288,13 +2297,13 @@ namespace XenOvf
string elementname = _ovfrm.GetString("RASD_UNKNOWN_ELEMENTNAME");
if (!string.IsNullOrEmpty(_rasd.ElementName.Value))
elementname = _rasd.ElementName.Value;
Log.Debug("OVF.RemoveRasd deleted: {0}:{1}", elementname, _rasd.InstanceID.Value);
log.DebugFormat("OVF.RemoveRasd deleted: {0}:{1}", elementname, _rasd.InstanceID.Value);
}
}
}
vhs.Item = rasds.ToArray();
}
Log.Debug("OVF.RemoveRasd completed");
log.Debug("OVF.RemoveRasd completed");
}
/// <summary>
///
@ -2464,7 +2473,7 @@ namespace XenOvf
}
}
}
Log.Trace("UpdateAnnotation Exit");
traceLog.Debug("UpdateAnnotation Exit");
}
/// <summary>
/// Add a CD/DVD Drive
@ -2513,7 +2522,7 @@ namespace XenOvf
rasd.Description = new cimString(description);
}
Log.Debug("OVF.UpdateCDROM Exit");
log.Debug("OVF.UpdateCDROM Exit");
}
/// <summary>
/// Add a controller to the mix.
@ -2560,7 +2569,7 @@ namespace XenOvf
rasd.Address.Value = Convert.ToString(iteration);
}
Log.Debug("OVF.UpdateController exit");
log.Debug("OVF.UpdateController exit");
}
/// <summary>
/// Update a defined Deployment Option
@ -2667,7 +2676,7 @@ namespace XenOvf
{
if (_rasd.ResourceType.Value == 15 || _rasd.ResourceType.Value == 16)
{
Log.Info("Found CD in connection, skipped");
log.Info("Found CD in connection, skipped");
break;
}
rasdList.Add(_rasd);
@ -2741,7 +2750,7 @@ namespace XenOvf
disk.populatedSizeSpecified = true;
}
file.href = string.Format(Properties.Settings.Default.FileURI, vhdFileName);
Log.Debug("OVF.UpdateDisk.1 completed");
log.Debug("OVF.UpdateDisk.1 completed");
}
/// <summary>
/// Update a EULA to the OVF
@ -2800,7 +2809,7 @@ namespace XenOvf
PropertyInfo p = targetobj.GetType().GetProperty(fieldname);
if (p == null)
{
Log.Error("PROPERTY: {0}.{1} does not exist", targetobj.GetType().Name, fieldname);
log.ErrorFormat("PROPERTY: {0}.{1} does not exist", targetobj.GetType().Name, fieldname);
}
else
{
@ -2841,10 +2850,10 @@ namespace XenOvf
}
else
{
Log.Error("{0} has no set method, read only", p.Name);
log.ErrorFormat("{0} has no set method, read only", p.Name);
}
}
Log.Debug("OVF.UpdateField completed {0}", fieldname);
log.DebugFormat("OVF.UpdateField completed {0}", fieldname);
}
/// <summary>
/// Update DISK information by RASD InstanceID
@ -2867,12 +2876,12 @@ namespace XenOvf
}
else
{
Log.Error("Cannot replace {0} with {1} because OVF does not contain a References Section.", oldfilename, newfilename);
log.ErrorFormat("Cannot replace {0} with {1} because OVF does not contain a References Section.", oldfilename, newfilename);
throw new ArgumentException(Messages.OVF_REFERENCE_SECTION_MISSING);
}
#endregion
Log.Debug("OVF.UpdateFilename completed");
log.Debug("OVF.UpdateFilename completed");
}
/// <summary>
///
@ -2925,7 +2934,7 @@ namespace XenOvf
}
#endregion
Log.Debug("OVF.UpdateFileSize completed");
log.Debug("OVF.UpdateFileSize completed");
}
/// <summary>
/// The InstallSection indicates that the virtual machine needs to be booted once in order to install and or configure the guest software.
@ -3009,7 +3018,7 @@ namespace XenOvf
rasd.Address = null;
}
}
Log.Debug("OVF.UpdateNetwork completed");
log.Debug("OVF.UpdateNetwork completed");
}
/// <summary>
/// Update the Operating System Section
@ -3403,7 +3412,7 @@ namespace XenOvf
}
}
}
Log.Debug("OVF.UpdateResourceAllocationSettingData completed");
log.Debug("OVF.UpdateResourceAllocationSettingData completed");
}
/// <summary>
/// Startup Section wrapper.
@ -3539,7 +3548,7 @@ namespace XenOvf
}
else
{
Log.Info("No String Section, operation skipped");
log.Info("No String Section, operation skipped");
return message;
}
if (currentLanguage == null)
@ -3605,7 +3614,7 @@ namespace XenOvf
{
vs.Name = new Msg_Type[1] { new Msg_Type(AddToStringSection(ovfObj, lang, name), name) };
}
Log.Debug("OVF.UpdateVirtualSystem completed");
log.Debug("OVF.UpdateVirtualSystem completed");
}
/// <summary>
/// Update the name field, over write[0] if present add if not.
@ -3669,7 +3678,7 @@ namespace XenOvf
}
UpdateField(vhs.System, fieldname, value);
}
Log.Debug("OVF.UpdateResourceAllocationSettingData completed");
log.Debug("OVF.UpdateResourceAllocationSettingData completed");
}
/// <summary>
///
@ -3688,7 +3697,7 @@ namespace XenOvf
vhs.System.InstanceID = new cimString(Guid.NewGuid().ToString());
}
UpdateField(vhs.System, fieldname, value);
Log.Debug("OVF.UpdateResourceAllocationSettingData completed");
log.Debug("OVF.UpdateResourceAllocationSettingData completed");
}
#endregion
@ -3859,7 +3868,7 @@ namespace XenOvf
}
}
}
Log.Debug("OVF.FindDiskRasds completed, {0} found", diskRasds.Count);
log.DebugFormat("OVF.FindDiskRasds completed, {0} found", diskRasds.Count);
return diskRasds.ToArray();
}
/// <summary>
@ -3886,7 +3895,7 @@ namespace XenOvf
returnRasds.AddRange(FindRasdByType(item, resourceType));
}
}
Log.Debug("OVF.FindRasdByType completed");
log.Debug("OVF.FindRasdByType completed");
return returnRasds.ToArray();
}
/// <summary>
@ -3910,7 +3919,7 @@ namespace XenOvf
rasds.Add(_rasd);
}
}
Log.Debug("OVF.FindRasdByType completed, {0} found", rasds.Count);
log.DebugFormat("OVF.FindRasdByType completed, {0} found", rasds.Count);
return rasds.ToArray();
}
/// <summary>
@ -3939,7 +3948,7 @@ namespace XenOvf
break;
}
Log.Debug("OVF.FindRasdById completed");
log.Debug("OVF.FindRasdById completed");
return returnRasd;
}
/// <summary>
@ -3959,11 +3968,11 @@ namespace XenOvf
{
if (_rasd.InstanceID.Value.Equals(instanceId))
{
Log.Debug("OVF.FindRasdById completed, found");
log.Debug("OVF.FindRasdById completed, found");
return _rasd;
}
}
Log.Debug("OVF.FindRasdById completed, not found");
log.Debug("OVF.FindRasdById completed, not found");
return null;
}
/// <summary>
@ -4207,7 +4216,7 @@ namespace XenOvf
{
systemIds.Add(vSystem.id);
}
Log.Debug("OVF.FindSystemIds completed, {0} found", systemIds.Count);
log.DebugFormat("OVF.FindSystemIds completed, {0} found", systemIds.Count);
return systemIds.ToArray();
}
/// <summary>
@ -4573,7 +4582,7 @@ namespace XenOvf
}
}
Log.Debug("OVF.FindSizes: Id {0} Size {1} Type {2}", diskDetails.DriveId, diskDetails.CapacitySize, (diskDetails.DiskType == 0) ? "HDD" : "CD/DVD/Other");
log.DebugFormat("OVF.FindSizes: Id {0} Size {1} Type {2}", diskDetails.DriveId, diskDetails.CapacitySize, (diskDetails.DiskType == 0) ? "HDD" : "CD/DVD/Other");
di.Add(diskDetails);
AtVDI = false;
}
@ -4615,7 +4624,7 @@ namespace XenOvf
}
}
mappings.Clear();
Log.Debug("OVF.FindSizes completed");
log.Debug("OVF.FindSizes completed");
return di.ToArray();
}
/// <summary>
@ -4789,7 +4798,7 @@ namespace XenOvf
}
}
Log.Debug("OVF.FindVirtualHardwareSection {0} found.", vhs.Count);
log.DebugFormat("OVF.FindVirtualHardwareSection {0} found.", vhs.Count);
return vhs.ToArray();
}
/// <summary>
@ -4827,7 +4836,7 @@ namespace XenOvf
}
}
Log.Debug("OVF.FindVirtualHardwareSection completed {0} ", vsId);
log.DebugFormat("OVF.FindVirtualHardwareSection completed {0} ", vsId);
return vhs;
}
/// <summary>
@ -4853,15 +4862,15 @@ namespace XenOvf
if (_vhs.System == null)
{
vhs = _vhs;
Log.Info("Import.Process: Found an Unknown Virtual Hardware Section (Rating: 5) [Unknown]");
Log.Info("Import.Process: Results may vary depending on hard disk image format.");
log.Info("Import.Process: Found an Unknown Virtual Hardware Section (Rating: 5) [Unknown]");
log.Info("Import.Process: Results may vary depending on hard disk image format.");
priority = 5;
}
else if (_vhs.System.VirtualSystemType.Value.ToLower().StartsWith(typeAffinity))
{
vhs = _vhs;
priority = 0;
Log.Info("Import.Process: Found closest affinity Virtual Hardware Section (Rating: 0) [{0}]", _vhs.System.VirtualSystemType.Value);
log.InfoFormat("Import.Process: Found closest affinity Virtual Hardware Section (Rating: 0) [{0}]", _vhs.System.VirtualSystemType.Value);
break;
}
else if (_vhs.System.VirtualSystemType.Value.ToLower().StartsWith("xen") ||
@ -4871,7 +4880,7 @@ namespace XenOvf
{
vhs = _vhs;
priority = 1;
Log.Info("Import.Process: Found a XEN PV'd Virtual Hardware Section (Rating: 1) [{0}]", _vhs.System.VirtualSystemType.Value);
log.InfoFormat("Import.Process: Found a XEN PV'd Virtual Hardware Section (Rating: 1) [{0}]", _vhs.System.VirtualSystemType.Value);
}
}
else if (_vhs.System.VirtualSystemType.Value.ToLower().StartsWith("hvm") ||
@ -4881,7 +4890,7 @@ namespace XenOvf
{
vhs = _vhs;
priority = 2;
Log.Info("Import.Process: Found a XEN Non-PV'd Virtual Hardware Section (Rating: 2) [{0}]", _vhs.System.VirtualSystemType.Value);
log.InfoFormat("Import.Process: Found a XEN Non-PV'd Virtual Hardware Section (Rating: 2) [{0}]", _vhs.System.VirtualSystemType.Value);
}
}
else if (_vhs.System.VirtualSystemType.Value.ToLower().StartsWith("301"))
@ -4891,7 +4900,7 @@ namespace XenOvf
vhs = _vhs;
priority = 3;
}
Log.Info("Import.Process: Found a Microsoft Virtual Hardware Section (Rating: 3) [{0}]", _vhs.System.VirtualSystemType.Value);
log.InfoFormat("Import.Process: Found a Microsoft Virtual Hardware Section (Rating: 3) [{0}]", _vhs.System.VirtualSystemType.Value);
}
else if (_vhs.System.VirtualSystemType.Value.ToLower().StartsWith("vmx"))
{
@ -4899,7 +4908,7 @@ namespace XenOvf
{
vhs = _vhs;
priority = 4;
Log.Info("Import.Process: Found a VMWare Virtual Hardware Section (Rating: 4) [{0}]", _vhs.System.VirtualSystemType.Value);
log.InfoFormat("Import.Process: Found a VMWare Virtual Hardware Section (Rating: 4) [{0}]", _vhs.System.VirtualSystemType.Value);
}
}
else
@ -4907,8 +4916,8 @@ namespace XenOvf
if (priority >= 5)
{
vhs = _vhs;
Log.Info("Import.Process: Found an Unknown Virtual Hardware Section (Rating: 5) [{0}]", _vhs.System.VirtualSystemType.Value);
Log.Info("Import.Process: Results may vary depending on hard disk image format.");
log.InfoFormat("Import.Process: Found an Unknown Virtual Hardware Section (Rating: 5) [{0}]", _vhs.System.VirtualSystemType.Value);
log.InfoFormat("Import.Process: Results may vary depending on hard disk image format.");
priority = 5;
}
}
@ -4917,7 +4926,7 @@ namespace XenOvf
if (vhs == null)
{
Log.Error("Import.Process: No VirtualHardwareSection_Type Exists");
log.Error("Import.Process: No VirtualHardwareSection_Type Exists");
throw new InvalidDataException(Messages.OVF_VHS_MISSING);
}
return vhs;
@ -4975,7 +4984,7 @@ namespace XenOvf
vhs.Item = rasds.ToArray();
}
Log.Debug("OVF.SetCPUs completed");
log.Debug("OVF.SetCPUs completed");
}
/// <summary>
/// Set Memory Setting Information
@ -5039,7 +5048,7 @@ namespace XenOvf
vhs.Item = rasds.ToArray();
}
Log.Debug("OVF.SetMemory completed");
log.Debug("OVF.SetMemory completed");
}
/// <summary>
/// Helper to set the target userdevice to connect the resources.
@ -5055,7 +5064,7 @@ namespace XenOvf
if (nbr < 0 || nbr > 15)
{
var message = string.Format(Messages.OVF_DEVICE_OUT_OF_RANGE, device);
Log.Error(message);
log.Error(message);
throw new ArgumentOutOfRangeException(message);
}
@ -5066,7 +5075,7 @@ namespace XenOvf
}
rasd.AddressOnParent.Value = device;
Log.Debug("OVF.SetTargetDeviceInRASD completed {0} device {1}", vsId, device);
log.DebugFormat("OVF.SetTargetDeviceInRASD completed {0} device {1}", vsId, device);
}
/// <summary>
/// Helper to add an ISO into the Envelope
@ -5078,7 +5087,7 @@ namespace XenOvf
public static void SetTargetISOSRInRASD(EnvelopeType ovfObj, string vsId, string rasdId, string sruuid)
{
SetConnectionInRASD(ovfObj, vsId, rasdId, Properties.Settings.Default.xenSRKey, sruuid);
Log.Debug("OVF.SetTargetISOSRInRASD completed {0}", vsId);
log.DebugFormat("OVF.SetTargetISOSRInRASD completed {0}", vsId);
}
/// <summary>
/// Helper to set the destination Storage Repository for the VM drives.
@ -5090,7 +5099,7 @@ namespace XenOvf
public static void SetTargetSRInRASD(EnvelopeType ovfObj, string vsId, string rasdId, string sruuid)
{
SetConnectionInRASD(ovfObj, vsId, rasdId, Properties.Settings.Default.xenSRKey, sruuid);
Log.Debug("OVF.SetTargetSRInRASD completed {0}", vsId);
log.DebugFormat("OVF.SetTargetSRInRASD completed {0}", vsId);
}
/// <summary>
@ -5103,7 +5112,7 @@ namespace XenOvf
public static void SetTargetVDIInRASD(EnvelopeType ovfObj, string vsId, string rasdId, string vdiuuid)
{
SetConnectionInRASD(ovfObj, vsId, rasdId, Properties.Settings.Default.xenVDIKey, vdiuuid);
Log.Debug("OVF.SetTargetVDIInRASD completed {0}", vsId);
log.DebugFormat("OVF.SetTargetVDIInRASD completed {0}", vsId);
}
/// <summary>
@ -5116,7 +5125,7 @@ namespace XenOvf
public static void SetTargetNetworkInRASD(EnvelopeType ovfObj, string vsId, string rasdId, string netuuid)
{
SetConnectionInRASD(ovfObj, vsId, rasdId, Properties.Settings.Default.xenNetworkKey, netuuid);
Log.Debug("OVF.SetTargetNetworkInRASD completed {0}", vsId);
log.DebugFormat("OVF.SetTargetNetworkInRASD completed {0}", vsId);
}
/// <summary>
/// Add information to the RASD.Connection[0].Value, This field is used to define
@ -5162,7 +5171,7 @@ namespace XenOvf
{
rasd.Connection = new cimString[] { new cimString(string.Format("{0}{1}", prompt, uuid)) };
}
Log.Debug("OVF.SetConnectionInRASD completed {0}", vsId);
log.DebugFormat("OVF.SetConnectionInRASD completed {0}", vsId);
return rasd;
}
/// <summary>
@ -5244,7 +5253,7 @@ namespace XenOvf
{
ident = vhs.System.InstanceID.Value;
}
Log.Info("Booting a Paravirtualized disk to CDROM is not valid, skipping: {0}", ident);
log.InfoFormat("Booting a Paravirtualized disk to CDROM is not valid, skipping: {0}", ident);
continue;
}
}
@ -5286,7 +5295,7 @@ namespace XenOvf
}
else
{
Log.Warning("SetRunOnceBootCDROM: Missing ISO: {0} find and copy to: {1}", srcFile, destFile);
log.WarnFormat("SetRunOnceBootCDROM: Missing ISO: {0} find and copy to: {1}", srcFile, destFile);
}
}
return cdId;
@ -5355,7 +5364,7 @@ namespace XenOvf
{
_processId = System.Diagnostics.Process.GetCurrentProcess().Id;
_touchFile = Path.Combine(pathToOva, "xen__" + _processId);
Log.Info("OVF.OpenOva: TouchFile: {0}", _touchFile);
log.InfoFormat("OVF.OpenOva: TouchFile: {0}", _touchFile);
if (!File.Exists(_touchFile))
{
FileStream fs = File.Create(_touchFile); fs.Close();
@ -5373,7 +5382,7 @@ namespace XenOvf
{
if (ext.ToLower().EndsWith("gz") || ext.ToLower().EndsWith("bz2")) // need to decompress.
{
Log.Info("OVA is compressed, de-compression stream inserted");
log.Info("OVA is compressed, de-compression stream inserted");
ovafilename = string.Format(@"{0}", Path.GetFileNameWithoutExtension(ovaFileName));
string ovaext = Path.GetExtension(ovafilename);
if (ovaext.ToLower().EndsWith("ova"))
@ -5411,8 +5420,8 @@ namespace XenOvf
inputStream.Close();
inputStream = null;
}
Log.Error("OVF.OpenOva: open failure {0}", ex.Message);
throw ex;
log.ErrorFormat("OVF.OpenOva: open failure {0}", ex.Message);
throw;
}
#endregion
@ -5425,7 +5434,7 @@ namespace XenOvf
}
catch (Exception ex)
{
Log.Error("OVF.OpenOva: Exception: {0}", ex.Message);
log.ErrorFormat("OVF.OpenOva: Exception: {0}", ex.Message);
}
finally
{
@ -5445,14 +5454,14 @@ namespace XenOvf
inputStream = null;
}
Directory.SetCurrentDirectory(origDir);
Log.Debug("OVF.OpenOva: Finally block");
log.Debug("OVF.OpenOva: Finally block");
}
#endregion
Log.Debug("OVF.OpenOva completed");
log.Debug("OVF.OpenOva completed");
}
else
{
Log.Info("OVF.OpenOva: Previously Opened, using extracted files.");
log.Info("OVF.OpenOva: Previously Opened, using extracted files.");
}
}
/// <summary>
@ -5473,7 +5482,7 @@ namespace XenOvf
if (ovapath.ToLower().EndsWith("gz") || ovapath.ToLower().EndsWith("bz2")) // need to decompress.
{
Log.Info("OVA is compressed, de-compression stream inserted");
log.Info("OVA is compressed, de-compression stream inserted");
string ovaext = Path.GetExtension(Path.GetFileNameWithoutExtension(ovapath));
if (ovaext.ToLower().EndsWith("ova"))
@ -5583,7 +5592,7 @@ namespace XenOvf
if (systems.Count <= 0)
{
Log.Error("Finalize Envelope FAILED, no Virtual Systems Defined.");
log.Error("Finalize Envelope FAILED, no Virtual Systems Defined.");
return;
}
@ -5652,7 +5661,7 @@ namespace XenOvf
{
ovfEnv.Item = (Content_Type)systems[0];
}
Log.Debug("OVF.FinalizeEnvelope completed.");
log.Debug("OVF.FinalizeEnvelope completed.");
}
/// <summary>
///
@ -5995,12 +6004,12 @@ namespace XenOvf
bool useHostResource = false;
if (Tools.ValidateProperty("HostResource", rasd))
{
Log.Debug("Using HostResource to find Disk");
log.Debug("Using HostResource to find Disk");
useHostResource = true;
}
else
{
Log.Debug("Using InstanceID to find Disk");
log.Debug("Using InstanceID to find Disk");
}
foreach (VirtualDiskDesc_Type disk in disks)
@ -6102,7 +6111,7 @@ namespace XenOvf
}
}
}
Log.Debug("OVF.AddContent completed {0}", vsId);
log.DebugFormat("OVF.AddContent completed {0}", vsId);
}
private static void AddRasdToAllVHS(EnvelopeType ovfEnv, string vsId, RASD_Type rasd)
{
@ -6143,7 +6152,7 @@ namespace XenOvf
}
if (antecedent == null)
{
Log.Trace("PCI Association not available, continuing.");
traceLog.Debug("PCI Association not available, continuing.");
continue;
}
#endregion
@ -6152,7 +6161,7 @@ namespace XenOvf
References.Add(mgtobj);
}
}
Log.Debug("OVF.FindDeviceReferences completed {0} {1}", classname, deviceId);
log.DebugFormat("OVF.FindDeviceReferences completed {0} {1}", classname, deviceId);
return References;
}
private bool IsBootDisk(string deviceID)
@ -6178,7 +6187,7 @@ namespace XenOvf
}
if (_antecedent == null || _dependent == null)
{
Log.Trace("Win32_DiskDriveToDiskPartition Association not available, continuing.");
traceLog.Debug("Win32_DiskDriveToDiskPartition Association not available, continuing.");
continue;
}
#endregion
@ -6203,7 +6212,7 @@ namespace XenOvf
}
if (_deviceid == null)
{
Log.Trace("Win32_DiskPartition DeviceID not available, continuing.");
traceLog.Debug("Win32_DiskPartition DeviceID not available, continuing.");
continue;
}
#endregion
@ -6217,9 +6226,9 @@ namespace XenOvf
}
catch (Exception ex)
{
Log.Error("OVF.IsBootDisk failed, could not determine if bootable, {0}", ex.Message);
log.ErrorFormat("OVF.IsBootDisk failed, could not determine if bootable, {0}", ex.Message);
}
Log.Debug("OVF.IsBootDisk completed Bootable = {0}", bootable);
log.DebugFormat("OVF.IsBootDisk completed Bootable = {0}", bootable);
return bootable;
}
private bool FillEmptyRequiredFields(RASD_Type rasd)

View File

@ -534,7 +534,7 @@ namespace XenOvf
if (!fileDigest.WasVerified)
{
// A manifest entry was missing.
XenOvf.Utilities.Log.Error(string.Format(Messages.FILE_MISSING, fileDigest.Name));
log.ErrorFormat(string.Format(Messages.FILE_MISSING, fileDigest.Name));
}
}
@ -551,6 +551,8 @@ namespace XenOvf
// Abstract class to access any time of package.
public abstract class Package
{
protected static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Package factory.
public static Package Create(string path)
{

View File

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.5472
// Runtime Version:4.0.30319.18408
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -12,7 +12,7 @@ namespace XenOvf.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@ -41,51 +41,6 @@ namespace XenOvf.Properties {
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Audit, Error, Warning")]
public string LogLevel {
get {
return ((string)(this["LogLevel"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("XenApplianceWizard.log")]
public string LogFile {
get {
return ((string)(this["LogFile"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Audit, Console")]
public string LogType {
get {
return ((string)(this["LogType"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("XenLocalOVF")]
public string LogSource {
get {
return ((string)(this["LogSource"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("ApplicationData")]
public string LogPath {
get {
return ((string)(this["LogPath"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("XenServer P2V (Orela) Server")]
@ -375,15 +330,6 @@ namespace XenOvf.Properties {
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Plain//Stamp")]
public string LogFormat {
get {
return ((string)(this["LogFormat"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute(".vhd,.pvp,.vmdk,.mf,.cert,.xva,.ovf,.wim,.vdi,.sdi,.iso,.gz")]
@ -673,15 +619,6 @@ namespace XenOvf.Properties {
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("off//XenOvfLogFwd.dll,XenOvfLogFwd.Log4Net")]
public string LogForwarding {
get {
return ((string)(this["LogForwarding"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("128")]
@ -803,15 +740,6 @@ namespace XenOvf.Properties {
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Citrix\\XenCenter\\logs")]
public string LogSubPath {
get {
return ((string)(this["LogSubPath"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("4096")]

View File

@ -8,21 +8,6 @@
<Setting Name="winFileFormatURI" Type="System.String" Scope="Application">
<Value Profile="(Default)">http://www.microsoft.com/technet/virtualserver/downloads/vhdspec.mspx</Value>
</Setting>
<Setting Name="LogLevel" Type="System.String" Scope="Application">
<Value Profile="(Default)">Audit, Error, Warning</Value>
</Setting>
<Setting Name="LogFile" Type="System.String" Scope="Application">
<Value Profile="(Default)">XenApplianceWizard.log</Value>
</Setting>
<Setting Name="LogType" Type="System.String" Scope="Application">
<Value Profile="(Default)">Audit, Console</Value>
</Setting>
<Setting Name="LogSource" Type="System.String" Scope="Application">
<Value Profile="(Default)">XenLocalOVF</Value>
</Setting>
<Setting Name="LogPath" Type="System.String" Scope="Application">
<Value Profile="(Default)">ApplicationData</Value>
</Setting>
<Setting Name="p2vTemplate" Type="System.String" Scope="Application">
<Value Profile="(Default)">XenServer P2V (Orela) Server</Value>
</Setting>
@ -119,9 +104,6 @@
<Setting Name="vmwEnvelopeNamespace" Type="System.String" Scope="Application">
<Value Profile="(Default)">http://www.vmware.com/schema/ovf/1/envelope</Value>
</Setting>
<Setting Name="LogFormat" Type="System.String" Scope="Application">
<Value Profile="(Default)">Plain//Stamp</Value>
</Setting>
<Setting Name="knownFileExtensions" Type="System.String" Scope="Application">
<Value Profile="(Default)">.vhd,.pvp,.vmdk,.mf,.cert,.xva,.ovf,.wim,.vdi,.sdi,.iso,.gz</Value>
</Setting>
@ -218,9 +200,6 @@
<Setting Name="xenLinuxFixUpDisk" Type="System.String" Scope="Application">
<Value Profile="(Default)">External Tools\xenserver-linuxfixup-disk.iso</Value>
</Setting>
<Setting Name="LogForwarding" Type="System.String" Scope="Application">
<Value Profile="(Default)">off//XenOvfLogFwd.dll,XenOvfLogFwd.Log4Net</Value>
</Setting>
<Setting Name="minPasswordStrength" Type="System.Double" Scope="Application">
<Value Profile="(Default)">128</Value>
</Setting>
@ -276,9 +255,6 @@
<Setting Name="securityVersion" Type="System.String" Scope="Application">
<Value Profile="(Default)">1.3.1</Value>
</Setting>
<Setting Name="LogSubPath" Type="System.String" Scope="Application">
<Value Profile="(Default)">Citrix\XenCenter\logs</Value>
</Setting>
<Setting Name="CompressBufferSize" Type="System.Int32" Scope="Application">
<Value Profile="(Default)">4096</Value>
</Setting>

View File

@ -115,7 +115,7 @@ namespace XenOvf
CryptoFileWrapper(env, ovfFileName, password, true);
if (_cancelEncrypt)
{
Log.Info("Encrypt: CANCELLED successfully.");
log.Info("Encrypt: CANCELLED successfully.");
}
else
{
@ -146,7 +146,7 @@ namespace XenOvf
CryptoFileWrapper(env, ovfFileName, password, false);
if (_cancelEncrypt)
{
Log.Info("Encrypt: CANCELLED successfully.");
log.Info("Encrypt: CANCELLED successfully.");
}
else
{
@ -370,14 +370,7 @@ namespace XenOvf
}
}
if (isValid)
{
Log.Audit(Messages.PASSWORD_SUCCESS);
}
else
{
Log.Audit(Messages.PASSWORD_FAILED);
}
auditLog.Debug(isValid ? Messages.PASSWORD_SUCCESS : Messages.PASSWORD_FAILED);
return isValid;
}
/// <summary>
@ -439,8 +432,8 @@ namespace XenOvf
}
catch (Exception ex)
{
Log.Error("OVF.Security.Manifest: {0}", ex.Message);
throw ex;
log.ErrorFormat("OVF.Security.Manifest: {0}", ex.Message);
throw;
}
if (ovfenv != null && ovfenv.References != null && ovfenv.References.File != null && ovfenv.References.File.Length > 0)
@ -480,7 +473,7 @@ namespace XenOvf
}
}
Log.Debug("OVF.Manifest completed");
log.Debug("OVF.Manifest completed");
}
@ -580,7 +573,7 @@ namespace XenOvf
(env.References.File == null) ||
(env.References.File.Length == 0))
{
Log.Info("OVF.Security: No files to encrypt/decrypt.");
log.Info("OVF.Security: No files to encrypt/decrypt.");
return;
}
try
@ -649,7 +642,7 @@ namespace XenOvf
}
else
{
Log.Info("File already encrypted, skipping. [{0}]", file.href);
log.InfoFormat("File already encrypted, skipping. [{0}]", file.href);
process = false;
}
}
@ -665,14 +658,14 @@ namespace XenOvf
else
{
process = false;
Log.Info("File is not encrypted, skipping. [{0}]", file.href);
log.InfoFormat("File is not encrypted, skipping. [{0}]", file.href);
}
}
if (process)
{
string fullname = string.Format(@"{0}\{1}", Path.GetDirectoryName(ovffilename), file.href);
Log.Debug(@"{0} : {1}", encrypt ? "Encrypt" : "Decrypt", fullname);
log.DebugFormat(encrypt ? "Encrypt: {0}" : "Decrypt: {0}", fullname);
ICryptoTransform trans = CryptoSetup(cryptoclassname, password, encrypt, version);
CryptoFile(trans, fullname, fullname + ".tmp", encrypt);
if (_cancelEncrypt)
@ -753,8 +746,8 @@ namespace XenOvf
}
catch (Exception ex)
{
Log.Error("OVF.Security: Cryptography error: {0}", ex.Message);
throw ex;
log.ErrorFormat("OVF.Security: Cryptography error: {0}", ex.Message);
throw;
}
}
private static CryptoStream CryptoStreamWrapper(Stream inputStream, string password, bool encrypt, string version)
@ -774,7 +767,7 @@ namespace XenOvf
private static ICryptoTransform CryptoSetup(string cryptoclassname, string password, bool encrypt, string version)
{
Log.Debug(@"{0} : using {1}", "CryptoSetup", cryptoclassname);
log.DebugFormat("CryptoSetup: using {0}", cryptoclassname);
SymmetricAlgorithm cryptObject = null;
try
{
@ -787,13 +780,13 @@ namespace XenOvf
}
catch (Exception ex)
{
Log.Error("Encryption class error: {0}", ex.Message);
log.ErrorFormat("Encryption class error: {0}", ex.Message);
throw;
}
if (cryptObject == null)
{
Log.Error("Encryption class could not be created");
log.Error("Encryption class could not be created");
throw new ArgumentNullException();
}
@ -882,7 +875,7 @@ namespace XenOvf
if (inputFile.Length > outputFile.Length && !_cancelEncrypt)
{
byte[] missing = new byte[inputFile.Length - outputFile.Length];
Log.Warning("PADDING Unencrypted VHD, with {0} zeros", (inputFile.Length - outputFile.Length));
log.WarnFormat("PADDING Unencrypted VHD, with {0} zeros", (inputFile.Length - outputFile.Length));
outputFile.Write(missing, 0, missing.Length);
}
}
@ -908,7 +901,7 @@ namespace XenOvf
catch (CryptographicException ce)
{
// If we get here the password is considered invalid
Log.Debug("InternalCheckPassword: Invalid password. {0}", ce.Message);
log.DebugFormat("InternalCheckPassword: Invalid password. {0}", ce.Message);
}
return isValid;
}
@ -918,19 +911,20 @@ namespace XenOvf
MemoryStream ms = new MemoryStream(bytearray);
MemoryStream os = new MemoryStream();
Stream checkStream = CryptoStreamWrapper(ms, password, false, version);
int r = -1;
while (true)
{
int r = -1;
try
{
r = checkStream.ReadByte();
}
catch (Exception ex)
{
Log.Equals("CRYPTO Error: {0}", ex.Message);
log.ErrorFormat("CRYPTO Error: {0}", ex.Message);
break;
}
if (r == -1) break;
if (r == -1)
break;
os.WriteByte((byte)r);
}
os.Position = 0;
@ -1045,4 +1039,4 @@ namespace XenOvf
}
}
}
}
}

View File

@ -1,452 +0,0 @@
/* Copyright (c) Citrix Systems Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms,
* with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
// ============================================================================
// Description: Utilitiy functions built on top of libxen for use in all
// providers.
// ============================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Security.Permissions;
using System.Text;
using System.Threading;
namespace XenOvf.Utilities
{
[Flags]
public enum EnumLogLevel { Off = 0, Audit = 1, Error = 2, Warning = 4, Info = 8, Trace = 16, Debug = 32 };
[Flags]
public enum EnumLogType { Off = 0, Audit = 1, Console = 2, File = 4, Event = 8, Exception = 16 };
public sealed class Log
{
private static FileStream fs;
private static string logpath = null;
private static string logfile = null;
private static object lockfile = new object();
private static object lockevent = new object();
private static object lockexcept = new object();
private static EnumLogLevel defaultLogLevel = (EnumLogLevel.Audit | EnumLogLevel.Error | EnumLogLevel.Warning);
private static EnumLogType defaultLogType = (EnumLogType.Audit | EnumLogType.Console | EnumLogType.File);
private static bool isconfigured = false;
private static EnumLogLevel curLevel = defaultLogLevel;
private static EnumLogType logType = defaultLogType;
private Log() { }
[SecurityPermission(SecurityAction.LinkDemand)]
public static string GetLogPath()
{
string path = null;
if (Properties.Settings.Default.LogPath.ToLower().StartsWith("installlocation"))
{
path = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location);
}
else if (Properties.Settings.Default.LogPath.ToLower().StartsWith("applicationdata"))
{
path = Path.Combine(System.Environment.GetEnvironmentVariable("APPDATA"), Properties.Settings.Default.LogSubPath);
}
else if (Properties.Settings.Default.LogPath.ToLower().StartsWith("programdata"))
{
path = Path.Combine(System.Environment.GetEnvironmentVariable("ProgramData"), Properties.Settings.Default.LogSubPath);
}
else
{
path = Properties.Settings.Default.LogPath;
}
return path;
}
[SecurityPermission(SecurityAction.LinkDemand)]
public static string GetLogFileName()
{
return logfile;
}
[SecurityPermission(SecurityAction.LinkDemand)]
public static void Trace(string format, params object[] args)
{
Write(EnumLogLevel.Trace, format, args);
}
[SecurityPermission(SecurityAction.LinkDemand)]
public static void Debug(string format, params object[] args)
{
Write(EnumLogLevel.Debug, format, args);
}
[SecurityPermission(SecurityAction.LinkDemand)]
public static void Info(string format, params object[] args)
{
Write(EnumLogLevel.Info, format, args);
}
[SecurityPermission(SecurityAction.LinkDemand)]
public static void Warning(string format, params object[] args)
{
Write(EnumLogLevel.Warning, format, args);
}
[SecurityPermission(SecurityAction.LinkDemand)]
public static void Error(string format, params object[] args)
{
Write(EnumLogLevel.Error, format, args);
}
[SecurityPermission(SecurityAction.LinkDemand)]
public static void Audit(string format, params object[] args)
{
Write(EnumLogLevel.Audit, format, args);
}
[SecurityPermission(SecurityAction.LinkDemand)]
public static void Bytes(byte[] bytes)
{
EnumLogLevel curLevel = (EnumLogLevel)Enum.Parse(typeof(EnumLogLevel), Properties.Settings.Default.LogLevel, true);
EnumLogType logType = (EnumLogType)Enum.Parse(typeof(EnumLogType), Properties.Settings.Default.LogType, true);
#region LOG TO CONSOLE
if (logType >= EnumLogType.Console)
{
Console.WriteLine(Encoding.ASCII.GetString(bytes));
}
#endregion
#region LOG TO FILE
if (logType >= EnumLogType.File)
{
lock (lockfile)
{
if (fs == null)
{
try
{
fs = new FileStream(logfile, FileMode.Create, FileAccess.Write, FileShare.Read);
}
catch (Exception ex)
{
throw new Exception("Cannot open Repository, try running as Administrator or change location of Log", ex);
}
}
if (fs != null)
{
try
{
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(Encoding.ASCII.GetString(bytes));
sw.Flush();
}
catch
{
// do nothing
}
finally
{
// do nothing
}
}
}
}
#endregion
}
[SecurityPermission(SecurityAction.LinkDemand)]
private static void Write(EnumLogLevel level, string format, params object[] args)
{
string forwardstatus = null;
string resetloglevel = null;
string resetlogtype = null;
if (Properties.Settings.Default.LogForwarding.Length > 0 &&
!Properties.Settings.Default.LogForwarding.ToLower().StartsWith("no") &&
!Properties.Settings.Default.LogForwarding.ToLower().StartsWith("off"))
{
try
{
Forward(Properties.Settings.Default.LogForwarding, level, format, args);
return;
}
catch
{
forwardstatus = "FWD: ";
}
}
if (logpath == null || logfile == null)
{
logpath = GetLogPath();
logfile = Path.Combine(logpath, Properties.Settings.Default.LogFile);
}
#region CONFIGURE TYPE AND LEVEL
if (!isconfigured)
{
if (Properties.Settings.Default.LogLevel.Length > 0)
{
try
{
curLevel = (EnumLogLevel)Enum.Parse(typeof(EnumLogLevel), Properties.Settings.Default.LogLevel, true);
}
catch
{
curLevel = defaultLogLevel;
resetloglevel = "--- Failure in determining configured log level, reset to: Audit, Error, Warning";
}
}
if (Properties.Settings.Default.LogType.Length > 0)
{
try
{
logType = (EnumLogType)Enum.Parse(typeof(EnumLogType), Properties.Settings.Default.LogType, true);
}
catch
{
logType = defaultLogType;
resetlogtype = "--- Failure in determining configure log type, reset to: Audit, Console, File";
}
}
if ((curLevel & EnumLogLevel.Audit) != EnumLogLevel.Audit)
{
curLevel |= EnumLogLevel.Audit;
}
if ((logType & EnumLogType.Audit) != EnumLogType.Audit)
{
logType |= EnumLogType.Audit;
}
isconfigured = true;
}
#endregion
string data = string.Format(format, args);
string message = null;
if (level == EnumLogLevel.Audit)
{
message = string.Format("{0}:{1}.{2}.{3}.{4}.{5}.{6},{7}:[{8}] {9}",
level,
DateTime.Now.Year,
DateTime.Now.Month,
DateTime.Now.Day,
DateTime.Now.Hour,
DateTime.Now.Minute,
DateTime.Now.Second,
DateTime.Now.Millisecond,
System.Security.Principal.WindowsIdentity.GetCurrent().Name,
data
);
}
else
{
if (Properties.Settings.Default.LogFormat.ToLower().Equals("plain"))
{
message = data;
}
else
{
message = string.Format("{0}:{1}.{2}.{3}.{4}.{5}.{6},{7}: {8}",
level,
DateTime.Now.Year,
DateTime.Now.Month,
DateTime.Now.Day,
DateTime.Now.Hour,
DateTime.Now.Minute,
DateTime.Now.Second,
DateTime.Now.Millisecond,
data
);
}
}
if (forwardstatus != null)
{
message = forwardstatus + message;
}
if (curLevel >= level && curLevel != EnumLogLevel.Off && logType != EnumLogType.Off)
{
#region LOG TO CONSOLE
if ((logType & EnumLogType.Console) == EnumLogType.Console)
{
if (resetloglevel != null)
{
Console.WriteLine(resetloglevel);
}
if (resetlogtype != null)
{
Console.WriteLine(resetlogtype);
}
Console.WriteLine(message);
}
#endregion
#region LOG TO FILE
if ((logType & EnumLogType.File) == EnumLogType.File)
{
lock (lockfile)
{
if (fs == null)
{
try
{
fs = new FileStream(logfile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
}
catch (Exception ex)
{
throw new Exception("Cannot open log file, try running as Administrator or change location of Log", ex);
}
}
if (fs != null)
{
try
{
StreamWriter sw = new StreamWriter(fs);
if (resetloglevel != null) { sw.WriteLine(resetloglevel); }
if (resetlogtype != null) { sw.WriteLine(resetlogtype); }
sw.WriteLine(message);
sw.Flush();
sw.Close();
}
catch
{
// do nothing
}
finally
{
if (fs != null) fs.Close();
fs = null;
}
}
}
}
#endregion
#region LOG TO EVENT
if ((logType & EnumLogType.Event) == EnumLogType.Event)
{
lock (lockevent)
{
if (!EventLog.SourceExists(Properties.Settings.Default.LogSource))
{
EventLog.CreateEventSource(Properties.Settings.Default.LogSource, "Application");
}
EventLogEntryType logtype = EventLogEntryType.Information;
switch(level)
{
case EnumLogLevel.Audit: { logtype = EventLogEntryType.SuccessAudit; break; }
case EnumLogLevel.Debug: { break; }
case EnumLogLevel.Error: { logtype = EventLogEntryType.Error; break; }
case EnumLogLevel.Info: { logtype = EventLogEntryType.Information; break; }
case EnumLogLevel.Warning: { break; }
case EnumLogLevel.Trace: { break; }
case EnumLogLevel.Off: { break; }
default: { break; }
}
EventLog.WriteEntry(Properties.Settings.Default.LogSource, message, logtype);
}
}
#endregion
#region LOG TO EXCEPTION
if ((logType & EnumLogType.Exception) == EnumLogType.Exception)
{
lock (lockexcept)
{
throw new Exception(message);
}
}
#endregion
#region LOG IN DebugView
if ((curLevel & EnumLogLevel.Debug) == EnumLogLevel.Debug)
{
if (resetloglevel != null) { System.Diagnostics.Debug.WriteLine(resetloglevel); }
if (resetlogtype != null) { System.Diagnostics.Debug.WriteLine(resetlogtype); }
System.Diagnostics.Debug.WriteLine(message);
}
#endregion
#region LOG IN TraceView
if ((curLevel & EnumLogLevel.Trace) == EnumLogLevel.Trace)
{
if (resetloglevel != null) { System.Diagnostics.Debug.WriteLine(resetloglevel); }
if (resetlogtype != null) { System.Diagnostics.Debug.WriteLine(resetlogtype); }
System.Diagnostics.Trace.WriteLine(message);
}
#endregion
}
resetloglevel = null;
resetlogtype = null;
}
private static void Forward(string AssemblyClassName, EnumLogLevel level, string format, params object[] args)
{
string[] _assemblyinfo = AssemblyClassName.Split(new char[] { ',' });
try
{
Assembly logassembly = null;
try
{
logassembly = Assembly.GetAssembly(Type.GetType(_assemblyinfo[1]));
}
catch { }
if (logassembly == null)
{
string asspath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), _assemblyinfo[0]);
logassembly = Assembly.LoadFrom(asspath);
}
Type LogClassType = logassembly.GetType(_assemblyinfo[1]);
MethodInfo mi = LogClassType.GetMethod(level.ToString());
List<object> newargs = new List<object>();
newargs.Add(format);
newargs.Add(args);
mi.Invoke(null, newargs.ToArray());
}
catch (Exception ex)
{
throw ex;
}
}
}
}

View File

@ -61,6 +61,8 @@ namespace XenOvf.Utilities
/// </summary>
public sealed class Tools
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private const long KB = 1024;
private const long MB = (KB * 1024);
private const long GB = (MB * 1024);
@ -106,8 +108,8 @@ namespace XenOvf.Utilities
}
catch (Exception ex)
{
Log.Error("Utilities.LoadFile: failed: {0}", ex.Message);
throw ex;
log.ErrorFormat("Utilities.LoadFile: failed: {0}", ex.Message);
throw;
}
finally
{
@ -144,7 +146,7 @@ namespace XenOvf.Utilities
}
catch (Exception ex)
{
Log.Debug("Tools.Deserialize failed attempt (may get retried)", ex.Message);
log.DebugFormat("Tools.Deserialize failed attempt (may get retried) {0}", ex.Message);
if (ex.InnerException != null && ex.InnerException.Message.ToLower().Contains("hexadecimal value 0x00"))
{
throw new InvalidDataException(Messages.INVALID_DATA_IN_OVF, ex);
@ -199,7 +201,7 @@ namespace XenOvf.Utilities
}
catch (Exception ex)
{
Log.Error("OVF.Tools.Serialize failed {0}", ex.Message);
log.ErrorFormat("OVF.Tools.Serialize failed {0}", ex.Message);
throw new CtxUtilitiesException(ex.Message,ex);
}
finally
@ -293,7 +295,7 @@ namespace XenOvf.Utilities
if (!File.Exists(ovfFilePath))
{
Log.Error("Utilities.LoadOvfXml: File not found: {0}", ovfFilePath);
log.ErrorFormat("Utilities.LoadOvfXml: File not found: {0}", ovfFilePath);
throw new FileNotFoundException(string.Format(Messages.FILE_MISSING, ovfFilePath));
}
@ -315,7 +317,7 @@ namespace XenOvf.Utilities
}
catch (Exception ex)
{
Log.Info("Attempt reading xml failed. {0}", ex.Message);
log.InfoFormat("Attempt reading xml failed. {0}", ex.Message);
}
if (ovfEnv != null && ovfEnv.AnyAttr != null)
@ -341,7 +343,7 @@ namespace XenOvf.Utilities
if (ovfEnv == null)
{
ovfEnv = LoadVmw35OvfXml(ovfxml);
Log.Error("Last Change Convert died.");
log.Error("Last Change Convert died.");
}
return ovfEnv;
@ -422,18 +424,18 @@ namespace XenOvf.Utilities
}
catch (XmlException xmlex)
{
Log.Error("ValidateXmlToSchema XML Exception: {0}", xmlex.Message);
{
log.ErrorFormat("ValidateXmlToSchema XML Exception: {0}", xmlex.Message);
throw new Exception(xmlex.Message, xmlex);
}
catch (XmlSchemaException schemaex)
{
Log.Error("ValidateXmlToSchema Schema Exception: {0}", schemaex.Message);
log.ErrorFormat("ValidateXmlToSchema Schema Exception: {0}", schemaex.Message);
throw new Exception(schemaex.Message, schemaex);
}
catch (Exception ex)
{
Log.Error("ValidateXmlToSchema Exception: {0}", ex.Message);
log.ErrorFormat("ValidateXmlToSchema Exception: {0}", ex.Message);
throw new Exception(ex.Message, ex);
}
finally
@ -584,7 +586,7 @@ namespace XenOvf.Utilities
private static void ShowSchemaValidationCompileErrors(object sender, ValidationEventArgs args)
{
Log.Error("ShowSchemaValidationCompileErrors: {0}", args.Message);
log.ErrorFormat("ShowSchemaValidationCompileErrors: {0}", args.Message);
}
private static bool ValidateField(string name, object target)
{
@ -613,7 +615,7 @@ namespace XenOvf.Utilities
.Replace("<Item", "<ovf:Item").Replace("</Item", "</ovf:Item");
EnvelopeType ovfEnv = (EnvelopeType)Deserialize(ovfxml, typeof(EnvelopeType));
Log.Debug("Finished LoadVmw40OvfXml");
log.Debug("Finished LoadVmw40OvfXml");
return ovfEnv;
}
private static EnvelopeType LoadVmw35OvfXml(string ovfxml)
@ -638,7 +640,7 @@ namespace XenOvf.Utilities
.Replace("<Item", "<ovf:Item").Replace("</Item", "</ovf:Item");
EnvelopeType ovfEnv = (EnvelopeType)Deserialize(ovfxml, typeof(EnvelopeType));
Log.Debug("Finished LoadVmw35OvfXml");
log.Debug("Finished LoadVmw35OvfXml");
return ovfEnv;
}
private static XenMember[] DeserializeXenMembers(XenMember[] members)
@ -719,19 +721,16 @@ namespace XenOvf.Utilities
}
catch (Exception ex)
{
Log.Error("Tools.Deserialize FAILED", ex.Message);
}
finally
{
log.ErrorFormat("Tools.Deserialize FAILED {0}", ex.Message);
}
return (T) new object();
}
private static void OpenArchive(string filename)
{
Log.Info("Utilities.OpenArchive: Opening OVF Archive: {0}", filename);
log.InfoFormat("Utilities.OpenArchive: Opening OVF Archive: {0}", filename);
if (!File.Exists(filename))
{
Log.Error("Utilities.OpenArchive: Cannot find file: {0}", filename);
log.ErrorFormat("Utilities.OpenArchive: Cannot find file: {0}", filename);
throw new FileNotFoundException(string.Format(Messages.FILE_MISSING, filename));
}
OVF.OpenOva(Path.GetDirectoryName(filename), Path.GetFileName(filename));

View File

@ -178,7 +178,7 @@ namespace XenOvf
{
isValid = false;
var message = string.Format(Messages.VALIDATION_INVALID_TYPE, ovfEnv.Item.GetType().ToString());
Log.Error(message);
log.Error(message);
validationErrorMessages.Add(message);
}
#endregion
@ -215,7 +215,11 @@ namespace XenOvf
if (!isValid)
{
bool enforceValidation = Properties.Settings.Default.enforceValidation;
Log.Error("OVF Failed Validation, {0}", enforceValidation ? "return failure" : "OVERRIDE return success");
log.Error(enforceValidation
? "OVF Failed Validation, return failure"
: "OVF Failed Validation, OVERRIDE return success");
if (!enforceValidation)
isValid = true;
}
@ -248,7 +252,7 @@ namespace XenOvf
}
if (ovfEnv.version == null)
{
Log.Warning("Version not set, applying 1.0.0");
log.Warn("Version not set, applying 1.0.0");
ovfEnv.version = "1.0.0";
}
}
@ -256,7 +260,7 @@ namespace XenOvf
{
isValid = false;
var message = string.Format(Messages.VALIDATION_INVALID_VERSION, ovfEnv.version);
Log.Warning(message);
log.Warn(message);
validationErrorMessages.Add(message);
}
}
@ -276,13 +280,13 @@ namespace XenOvf
{
if (!Properties.Settings.Default.knownFileExtensions.ToLower().Contains(ext))
{
Log.Warning(Messages.VALIDATION_INVALID_FILETYPE, file.href);
log.WarnFormat(Messages.VALIDATION_INVALID_FILETYPE, file.href);
}
}
else
{
var message = string.Format(Messages.VALIDATION_FILE_NOTFOUND, file.href);
Log.Error(message);
log.Error(message);
throw new Exception(message);
}
}
@ -308,14 +312,14 @@ namespace XenOvf
{
var message = string.Format(Messages.VALIDATION_FILE_NOTFOUND, file.href);
validationErrorMessages.Add(message);
Log.Error(message);
log.Error(message);
throw new Exception(message);
}
}
}
else
{
Log.Info("ValidateFiles: no attached files defined, continuing");
log.Info("ValidateFiles: no attached files defined, continuing");
return isValid;
}
if (isValid)
@ -354,7 +358,7 @@ namespace XenOvf
}
if (!validlink)
{
Log.Warning("Disk linkage [File to RASD] does not exist: {0}", file.href);
log.WarnFormat("Disk linkage [File to RASD] does not exist: {0}", file.href);
break;
}
}
@ -374,21 +378,21 @@ namespace XenOvf
if (rasd.VirtualQuantity == null || rasd.VirtualQuantity.Value <= 0)
{
var message = string.Format(Messages.VALIDATION_INVALID_CPU_QUANTITY, rasd.VirtualQuantity.Value);
Log.Error(message);
log.Error(message);
validationErrorMessages.Add(message);
break;
}
if (rasd.Limit != null && rasd.VirtualQuantity.Value > rasd.Limit.Value)
{
var message = string.Format(Messages.VALIDATION_INVALID_CPU_EXCEEDS_LIMIT, rasd.VirtualQuantity.Value, rasd.Limit.Value);
Log.Error(message);
log.Error(message);
validationErrorMessages.Add(message);
isValid = false;
break;
}
if (rasd.InstanceID == null || rasd.InstanceID.Value.Length <= 0)
{
Log.Info("CPU has an invalid InstanceID, creating new.");
log.Info("CPU has an invalid InstanceID, creating new.");
validationErrorMessages.Add(Messages.VALIDATION_INVALID_INSTANCEID);
rasd.InstanceID = new cimString(Guid.NewGuid().ToString());
break;
@ -409,21 +413,21 @@ namespace XenOvf
{
if (rasd.VirtualQuantity == null || rasd.VirtualQuantity.Value <= 0)
{
Log.Error("Memory invalid Virtual Quantity");
log.Error("Memory invalid Virtual Quantity");
validationErrorMessages.Add(Messages.VALIDATION_INVALID_MEMORY_QUANTITY);
isValid = false;
break;
}
if (rasd.AllocationUnits == null || rasd.AllocationUnits.Value.Length <= 0)
{
Log.Error("Memory AllocationUnits not valid");
log.Error("Memory AllocationUnits not valid");
validationErrorMessages.Add(Messages.VALIDATION_INVALID_MEMORY_ALLOCATIONUNITS);
isValid = false;
break;
}
if (rasd.InstanceID == null || rasd.InstanceID.Value.Length <= 0)
{
Log.Info("Memory has an invalid InstanceID, creating new.");
log.Info("Memory has an invalid InstanceID, creating new.");
validationErrorMessages.Add(Messages.VALIDATION_INVALID_INSTANCEID);
rasd.InstanceID = new cimString(Guid.NewGuid().ToString());
break;
@ -445,7 +449,7 @@ namespace XenOvf
bool linkage = false;
if (rasd.InstanceID == null || rasd.InstanceID.Value.Length <= 0)
{
Log.Info("Network has an invalid InstanceID, creating new.");
log.Info("Network has an invalid InstanceID, creating new.");
validationErrorMessages.Add(Messages.VALIDATION_INVALID_INSTANCEID);
rasd.InstanceID = new cimString(Guid.NewGuid().ToString());
break;
@ -465,7 +469,7 @@ namespace XenOvf
}
if (!linkage)
{
Log.Error(Messages.VALIDATION_NETWORK_NO_DEVICE);
log.Error(Messages.VALIDATION_NETWORK_NO_DEVICE);
validationErrorMessages.Add(Messages.VALIDATION_NETWORK_NO_DEVICE);
isValid = false;
break;
@ -530,7 +534,7 @@ namespace XenOvf
if (rasd.required)
{
var message = string.Format(Messages.VALIDATION_REQUIRED_ELEMENT_NOT_RECOGNIZED, rasd.ResourceType.Value, rasd.ElementName.Value);
Log.Error(message);
log.Error(message);
validationErrorMessages.Add(message);
isValid = false;
}
@ -560,7 +564,7 @@ namespace XenOvf
if (!isValid)
{
isValid = false;
Log.Error(Messages.VALIDATION_SCHEMA_FAILED);
log.Error(Messages.VALIDATION_SCHEMA_FAILED);
validationErrorMessages.Add(Messages.VALIDATION_SCHEMA_FAILED);
}
}
@ -580,7 +584,7 @@ namespace XenOvf
if (!Properties.Settings.Default.knownVirtualSystemTypes.Contains(vhs.System.VirtualSystemType.Value))
{
var message = string.Format(Messages.VALIDATION_UNKNOWN_HARDWARE_TYPE, vhs.System.VirtualSystemType.Value);
Log.Warning(message);
log.Warn(message);
validationErrorMessages.Add(message);
isValid = false;
}

View File

@ -39,6 +39,10 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=1.2.13.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\log4net\build\bin\net\2.0\release\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
@ -99,7 +103,6 @@
<Compile Include="Security.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Utilities\Log.cs" />
<Compile Include="Utilities\Utilities.cs" />
<Compile Include="Utilities\ValueMaps.cs" />
<Compile Include="Validation.cs">
@ -196,7 +199,7 @@
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
<UserProperties StartDate="20090814" AssemblyFileVersion="1" AssemblyVersion="1" Reset="1" />
<UserProperties Reset="1" AssemblyVersion="1" AssemblyFileVersion="1" StartDate="20090814" />
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@ -47,6 +47,8 @@ namespace XenOvfTransport
public class Export : XenOvfTransportBase
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static readonly log4net.ILog auditLog = log4net.LogManager.GetLogger("Audit");
private static readonly log4net.ILog traceLog = log4net.LogManager.GetLogger("Trace");
private const long KB = 1024;
private const long MB = (KB * 1024);
@ -90,7 +92,7 @@ namespace XenOvfTransport
try
{
log.InfoFormat("Export: {0}, {1}", ovfname, targetPath);
auditLog.DebugFormat("Export: {0}, {1}", ovfname, targetPath);
#region GET VM Reference
XenRef<VM> vmRef = null;
@ -110,7 +112,7 @@ namespace XenOvfTransport
{
List<XenRef<VM>> vmRefs = VM.get_by_name_label(xenSession, vmUuid);
vmRef = vmRefs[0];
log.DebugFormat("{0} VM(s) found by label {1}", vmRefs.Count, vmUuid);
traceLog.DebugFormat("{0} VM(s) found by label {1}", vmRefs.Count, vmUuid);
if (vmRefs.Count > 1)
log.WarnFormat("Only exporting FIRST VM with name {0}", vmUuid);
}

View File

@ -63,7 +63,9 @@ namespace XenOvfTransport
{
public class Import : XenOvfTransportBase
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly log4net.ILog auditLog = log4net.LogManager.GetLogger("Audit");
private static readonly log4net.ILog traceLog = log4net.LogManager.GetLogger("Trace");
private const long KB = 1024;
private const long MB = (KB * 1024);
@ -269,7 +271,7 @@ namespace XenOvfTransport
{
//FIND/SET THE NAME OF THE VM
ovfname = OVF.FindSystemName(ovfObj, vSystem.id);
log.InfoFormat("Import: {0}, {1}", ovfname, pathToOvf);
auditLog.DebugFormat("Import: {0}, {1}", ovfname, pathToOvf);
VirtualHardwareSection_Type vhs = OVF.FindVirtualHardwareSectionByAffinity(ovfObj, vSystem.id, "xen");
@ -974,7 +976,7 @@ namespace XenOvfTransport
}
else
{
log.DebugFormat("Directory ReparsePoint {0}", dir.FullName);
traceLog.InfoFormat("Directory ReparsePoint {0}", dir.FullName);
ReparsePoint rp = w.GetReparsePoint(dir.FullName);
ntfs.CreateDirectory(dir.FullName);
ntfs.SetReparsePoint(dir.FullName, rp);
@ -1009,7 +1011,7 @@ namespace XenOvfTransport
}
else
{
log.DebugFormat("Reparse Point: {0}", file.FullName);
traceLog.InfoFormat("Reparse Point: {0}", file.FullName);
ReparsePoint rp = w.GetReparsePoint(file.FullName);
ntfs.SetReparsePoint(file.FullName, rp);
}
@ -1598,11 +1600,11 @@ namespace XenOvfTransport
}
catch
{
log.Debug("Import.AddResourceSettingData: iso sr uuid not found, trying name_label");
traceLog.Debug("Import.AddResourceSettingData: iso sr uuid not found, trying name_label");
}
#endregion
#region TRY IS AS NAME_LABEL
#region TRY IT AS NAME_LABEL
try
{
List<XenRef<SR>> srrefList = SR.get_by_name_label(xenSession, isoUuid);
@ -1614,7 +1616,7 @@ namespace XenOvfTransport
}
catch
{
log.Debug("Import.AddResourceSettingData: iso sr uuid not found, looking for vdi...");
traceLog.Debug("Import.AddResourceSettingData: iso sr uuid not found, looking for vdi...");
}
#endregion
}
@ -1879,7 +1881,7 @@ namespace XenOvfTransport
}
catch
{
log.Debug("Import.AddResourceSettingData: SR missing... still looking..");
traceLog.Debug("Import.AddResourceSettingData: SR missing... still looking..");
}
if (srref == null)
{
@ -1890,7 +1892,7 @@ namespace XenOvfTransport
}
catch
{
log.Debug("Import.AddResourceSettingData: SR missing... still looking..");
traceLog.Debug("Import.AddResourceSettingData: SR missing... still looking..");
}
if (srlist != null && srlist.Count > 0)
{