Do not localise log entries or ellipsise names. Log exception stack traces where applicable.

Signed-off-by: Konstantina Chremmou <konstantina.chremmou@citrix.com>
This commit is contained in:
Konstantina Chremmou 2019-11-08 11:42:18 +00:00 committed by Mihaela Stoica
parent fb2edf99b8
commit f4265732ca
24 changed files with 87 additions and 102 deletions

View File

@ -44,8 +44,6 @@ namespace XenAdmin.Alerts
{
public class MessageAlert : Alert
{
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public XenAPI.Message Message;
public IXenObject XenObject;
@ -203,10 +201,7 @@ namespace XenAdmin.Alerts
case Message.MessageType.MULTIPATH_PERIODIC_ALERT:
if (XenObject != null)
{
log.InfoFormat("{0} - {1}", Title, Message.body);
return extractMultipathCurrentState(Message.body, FriendlyFormat());
}
break;
case Message.MessageType.WLB_CONSULTATION_FAILED:

View File

@ -147,10 +147,10 @@ namespace XenAdmin.Commands
private void DoDisconnect(IXenConnection connection)
{
string msg = string.Format(Messages.CONNECTION_CLOSED_NOTICE_TEXT, connection.Hostname);
log.Warn(msg);
ActionBase notice = new ActionBase(msg, msg, false, true);
notice.Pool = Helpers.GetPoolOfOne(connection);
notice.Host = Helpers.GetMaster(connection);
log.Warn($"Connection to {connection.Hostname} closed.");
MainWindowCommandInterface.CloseActiveWizards(connection);
XenDialogBase.CloseAll(connection);

View File

@ -68,7 +68,7 @@ namespace XenAdmin.Commands
foreach (Host host in selection.AsXenObjects<Host>())
{
string msg = string.Format(Messages.MAINWINDOW_LOG_REMOVECONNECTION, host.Connection.Hostname);
log.Info(msg);
log.Info($"Removed connection to {host.Connection.Hostname}");
new ActionBase(msg, msg, false, true);
MainWindowCommandInterface.CloseActiveWizards(host.Connection);
host.Connection.EndConnect();

View File

@ -473,8 +473,9 @@ namespace XenAdmin.Wizards.ImportWizard
private void m_networkGridView_DataError(object sender, DataGridViewDataErrorEventArgs e)
{
e.ThrowException = false;
log.Error(String.Format(Messages.NETWORKPICKER_LOG_VIF_ERROR, e.Exception.Message));
}
log.Error("Error from VIF table:", e.Exception);
}
private void m_networkGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
{

View File

@ -32,9 +32,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading;
using log4net;
using XenAdmin.Network;
using XenAPI;
@ -43,7 +41,7 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
{
public abstract class PlanAction : IEquatable<PlanAction>
{
protected static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private int _percentComplete;
public event Action<PlanAction> OnProgressChange;
@ -127,12 +125,11 @@ namespace XenAdmin.Wizards.PatchingWizard.PlanActions
}
catch (Exception e)
{
Failure f = e as Failure;
if (f != null && f.ErrorDescription != null && f.ErrorDescription.Count > 1 && f.ErrorDescription[1].Contains(FriendlyErrorNames.SR_BACKEND_FAILURE_432))
if (e is Failure f && f.ErrorDescription != null && f.ErrorDescription.Count > 1 && f.ErrorDescription[1].Contains(FriendlyErrorNames.SR_BACKEND_FAILURE_432))
{
// ignore this exception (CA-62989) in order to allow the Upgrade wizard to continue
// upgrading all the hosts in a pool. The detached SRs will be reported on Finish
log.Warn(Messages.STORAGELINK_SR_NEEDS_REATTACH, f);
log.Warn("There is a StorageLink Gateway SR that needs to be reattached.", f);
}
else
{

View File

@ -150,7 +150,7 @@ namespace XenAdmin.Actions
Exception e = null;
string resolvedName = "";
string sid = "";
log.DebugFormat("Resolving AD entries on pool '{0}'", Helpers.GetName(Connection).Ellipsise(50));
log.DebugFormat("Resolving AD entries on pool '{0}'.", Helpers.GetName(Connection));
foreach (string name in subjectNamesToAdd)
{
try
@ -192,7 +192,7 @@ namespace XenAdmin.Actions
{
Exception e = null;
Subject subject = null;
log.DebugFormat("Adding {0} new subjects on pool '{1}'", sidsToAdd.Count, Helpers.GetName(Connection).Ellipsise(50));
log.DebugFormat("Adding {0} new subjects on pool '{1}'", sidsToAdd.Count, Helpers.GetName(Connection));
foreach (string sid in sidsToAdd)
{
try
@ -242,7 +242,7 @@ namespace XenAdmin.Actions
private void removeSubjects()
{
Exception e = null;
log.DebugFormat("Removing {0} existing subjects on pool '{1}'", subjectsToRemove.Count, Helpers.GetName(Connection).Ellipsise(50));
log.DebugFormat("Removing {0} existing subjects on pool '{1}'.", subjectsToRemove.Count, Helpers.GetName(Connection));
string selfSid = Connection.Session.IsLocalSuperuser || Connection.Session.Subject == null
? ""
: Connection.Resolve(Connection.Session.Subject).subject_identifier;

View File

@ -74,7 +74,7 @@ namespace XenAdmin.Actions
protected override void Run()
{
log.DebugFormat("Enabling AD on pool '{0}'", Helpers.GetName(Connection).Ellipsise(50));
log.DebugFormat("Enabling AD on pool '{0}'", Helpers.GetName(Connection));
Dictionary<string, string> config = new Dictionary<string, string>();
config["domain"] = domain; // NB this line is now redundant, it is here to support the old now-superseded way of passing in the domain

View File

@ -83,8 +83,7 @@ namespace XenAdmin.Actions.DR
else
{
log.DebugFormat("Metadata session is NULL. Cannot recover {0} to Pool {1}",
Helpers.GetName(xenObject).Ellipsise(50),
Helpers.GetName(Pool).Ellipsise(50));
Helpers.GetName(xenObject), Helpers.GetName(Pool));
}
Description = String.Format(Messages.ACTION_DR_RECOVER_DONE, xenObject.Name());
}

View File

@ -131,12 +131,12 @@ namespace XenAdmin.Actions
XenRef<Pool_patch> patchRef = BringPatchToPoolForHost(host, patch);
Description = string.Format(Messages.APPLYING_PATCH, patch.Name(), host.Name());
log.Debug(Description);
log.DebugFormat("Applying update '{0}' to server '{1}'", patch.Name(), host.Name());
RelatedTask = Pool_patch.async_apply(Session, patchRef, host.opaque_ref);
PollToCompletion();
log.DebugFormat(Messages.APPLY_PATCH_LOG_MESSAGE, patch.Name(), host.Name(), Result);
log.DebugFormat("Applied update '{0}' to server '{1}'. Result: {2}.", patch.Name(), host.Name(), Result);
Description = string.Format(Messages.PATCH_APPLIED, patch.Name(), host.Name());
}
}

View File

@ -59,7 +59,7 @@ namespace XenAdmin.Actions
return;
Description = string.Format(Messages.APPLYING_PATCH, update.Name(), host.Name());
log.Debug(Description);
log.DebugFormat("Applying update '{0}' to server '{1}'...", update.Name(), host.Name());
var poolUpdates = new List<Pool_update>(Connection.Cache.Pool_updates);
var poolUpdate = poolUpdates.FirstOrDefault(u => u != null && string.Equals(u.uuid, update.uuid, StringComparison.OrdinalIgnoreCase));

View File

@ -134,7 +134,7 @@ namespace XenAdmin.Actions
if (template != null)
{
this.Description = string.Format(Messages.ACTION_SR_REPAIR_CREATE_PBD, Helpers.GetName(host));
log.Debug(this.Description);
log.Debug($"Creating PBD for {Helpers.GetName(host)}.");
var newPbd = new PBD
{
@ -174,7 +174,7 @@ namespace XenAdmin.Actions
if (thePBD != null && !thePBD.currently_attached)
{
this.Description = string.Format(Messages.ACTION_SR_REPAIR_PLUGGING_PBD, Helpers.GetName(host));
log.Debug(this.Description);
log.Debug($"Plugging PBD for {Helpers.GetName(host)}.");
try
{

View File

@ -57,7 +57,7 @@ namespace XenAdmin.Actions
if (host == null)
{
log.WarnFormat("Plugin call trim.do_trim({0}) is not possible. Reason: {1}", SR.uuid, Messages.SR_TRIM_NO_STORAGE_HOST_ERROR);
log.WarnFormat("Plugin call trim.do_trim({0}) is not possible. Reason: Cannot reclaim freed space, because the SR is detached.", SR.uuid);
Exception = new Exception(Messages.SR_TRIM_NO_STORAGE_HOST_ERROR);
return;
}

View File

@ -145,7 +145,11 @@ namespace XenAdmin.Actions
log.ErrorFormat(
"Error while downloading from '{0}'. Number of errors so far (including this): {1}. Trying maximum {2} times.",
address, errorCount, MAX_NUMBER_OF_TRIES);
log.Error(patchDownloadError ?? new Exception(Messages.ERROR_UNKNOWN));
if (patchDownloadError == null)
log.Error("An unknown error occurred.");
else
log.Error(patchDownloadError);
}
} while (errorCount < MAX_NUMBER_OF_TRIES && needToRetry);
}

View File

@ -89,7 +89,7 @@ namespace XenAdmin.Actions.Wlb
//Force disabling of WLB
XenAPI.Pool.set_wlb_enabled(this.Session, Pool.opaque_ref, false);
WlbServerState.SetState(this.Session, Pool, WlbServerState.ServerState.ConnectionError, (Failure)ex);
log.Debug(string.Format(Messages.ACTION_WLB_DECONFIGURE_FAILED, Pool.Name(), ex.Message));
log.Debug($"Disconnecting Workload Balancing failed on pool {Pool.Name()}. Workload Balancing has been paused.", ex);
throw new Exception(string.Format(Messages.ACTION_WLB_DECONFIGURE_FAILED, Pool.Name(), ex.Message));
}
finally

View File

@ -3138,7 +3138,6 @@ Would you like to carry out the operation at this time?</value>
</data>
<data name="CONNECTION_RESTRICTED_MESSAGE" xml:space="preserve">
<value>Connection to Server {0} restricted because a connection already exists to another XE Express Server ({1})</value>
<comment>Message shown when user attempts to connect to a second XE Express host from the UI</comment>
</data>
<data name="CONNECTION_RESTRICTED_MESSAGE_LONG" xml:space="preserve">
<value>Connection to server {0} restricted - a connection to a [Citrix XenServer] Express Edition server ({1}) already exists.

View File

@ -948,7 +948,7 @@ namespace XenAdmin.Network
: string.Format("{0} ({1})", FriendlyName, taskHostname);
string title = string.Format(Messages.CONNECTING_NOTICE_TITLE, name);
string msg = string.Format(Messages.CONNECTING_NOTICE_TEXT, name);
log.Info(msg);
log.Info($"Connecting to {name} in progress.");
ConnectAction = new ActionBase(title, msg, false, false);
@ -1122,7 +1122,7 @@ namespace XenAdmin.Network
{
string title = string.Format(Messages.CONNECTION_OK_NOTICE_TITLE, Hostname);
string msg = string.Format(Messages.CONNECTION_OK_NOTICE_TEXT, Hostname);
log.Info(msg);
log.Info($"Connection to {Hostname} successful.");
ConnectAction.Title = title;
ConnectAction.Description = msg;
SetPoolAndHostInAction(ConnectAction);
@ -1415,9 +1415,9 @@ namespace XenAdmin.Network
EndConnect(true, task, false);
ExpressRestriction e = (ExpressRestriction)error;
// This can happen when the user attempts to connect to a second XE Express host from the UI
string msg = string.Format(Messages.CONNECTION_RESTRICTED_MESSAGE, e.HostName, e.ExistingHostName);
// Add an informational log message saying why the connection attempt failed
log.Info(msg);
log.Info($"Connection to Server {e.HostName} restricted because a connection already exists to another XE Express Server ({e.ExistingHostName})");
string title = string.Format(Messages.CONNECTION_RESTRICTED_NOTICE_TITLE, e.HostName);
ActionBase action = new ActionBase(title, msg, false, true, msg);
SetPoolAndHostInAction(action, pool, PoolOpaqueRef);

View File

@ -258,9 +258,9 @@ namespace XenOvf
{
if (ex is OperationCanceledException)
throw;
var message = string.Format(Messages.COMPRESS_FAILED, filename);
log.ErrorFormat("{0} {1}", message, ex.Message);
throw new Exception(message, ex);
log.Error("Compression failure", ex);
throw new Exception(string.Format(Messages.COMPRESS_FAILED, filename), ex);
}
finally
{

View File

@ -80,14 +80,10 @@ namespace XenOvf
internal static ResourceManager _ovfrm = new ResourceManager("XenOvf.Content", Assembly.GetExecutingAssembly());
#region PUBLIC
#region CONSTRUCTOR
public OVF()
{
UnLoad();
log.InfoFormat("XenOvf.Message.resources {0}", Messages.RESOURCES_LOADED);
log.InfoFormat("XenOvf.Content.resources {0}", Messages.RESOURCES_LOADED);
}
#endregion
#region PROPERTIES
@ -4644,7 +4640,7 @@ namespace XenOvf
if (nbr < 0 || nbr > 15)
{
var message = string.Format(Messages.OVF_DEVICE_OUT_OF_RANGE, device);
log.Error(message);
log.ErrorFormat("Device number {0} is less than zero or greater than 15.", device);
throw new ArgumentOutOfRangeException(message);
}

View File

@ -370,7 +370,7 @@ namespace XenOvf
}
}
auditLog.Debug(isValid ? Messages.PASSWORD_SUCCESS : Messages.PASSWORD_FAILED);
log.Debug(isValid ? "Password is valid." : "Password is not valid.");
return isValid;
}
/// <summary>

View File

@ -118,7 +118,7 @@ namespace XenOvfTransport
}
catch
{
log.ErrorFormat(Messages.ERROR_VM_NOT_FOUND, vmUuid);
log.ErrorFormat("Failed to find VM {0}.", vmUuid);
throw;
}
}
@ -130,7 +130,7 @@ namespace XenOvfTransport
{
var message = string.Format(Messages.ERROR_VM_NOT_HALTED, vm.Name());
OnUpdate(new XenOvfTranportEventArgs(XenOvfTranportEventType.ExportProgress, "Export", message));
log.Info(message);
log.Info($"VM {vm.Name()} ({vmRef.opaque_ref}) is neither halted nor suspended.");
throw new Exception(message);
}
@ -393,7 +393,7 @@ namespace XenOvfTransport
{
if (ex is OperationCanceledException)
throw;
log.Error(Messages.ERROR_EXPORT_FAILED);
log.Error("Export failed", ex);
throw new Exception(Messages.ERROR_EXPORT_FAILED, ex);
}
return ovfEnv;
@ -459,7 +459,7 @@ namespace XenOvfTransport
if (ex is OperationCanceledException)
throw;
var msg = string.Format(Messages.ISCSI_COPY_ERROR, destinationFilename);
log.Error(msg);
log.Error($"Failed to transfer virtual disk {destinationFilename}", ex);
OnUpdate(new XenOvfTranportEventArgs(XenOvfTranportEventType.Failure, "Export", msg, ex));
throw new Exception(msg, ex);
}

View File

@ -278,7 +278,7 @@ namespace XenOvfTransport
XenRef<VM> vmRef = DefineSystem(xenSession, vhs, ovfname);
if (vmRef == null)
{
log.Error(Messages.ERROR_CREATE_VM_FAILED);
log.Error("Failed to create a VM");
throw new ImportException(Messages.ERROR_CREATE_VM_FAILED);
}
@ -439,7 +439,7 @@ namespace XenOvfTransport
{
if (ex is OperationCanceledException)
throw;
log.Error(Messages.ERROR_IMPORT_FAILED);
log.Error("Import failed", ex);
throw new Exception(Messages.ERROR_IMPORT_FAILED, ex);
}
}
@ -603,7 +603,7 @@ namespace XenOvfTransport
{
var statusMessage = string.Format(Messages.START_FILE_DECRYPTION, filename);
OnUpdate(new XenOvfTranportEventArgs(XenOvfTranportEventType.MarqueeOn, "Security", statusMessage));
log.Debug(statusMessage);
log.Debug($"Decrypting {filename}");
OVF.DecryptToTempFile(EncryptionClass, filename, version, passcode, encryptfilename);
sourcefile = encryptfilename;
statusMessage += Messages.COMPLETE;
@ -702,7 +702,7 @@ namespace XenOvfTransport
}
catch (Exception ex)
{
log.Error(Messages.ISCSI_ERROR_CANNOT_OPEN_DISK);
log.Error("Failed to open virtual disk", ex);
throw new Exception(Messages.ISCSI_ERROR_CANNOT_OPEN_DISK, ex);
}
}
@ -713,7 +713,7 @@ namespace XenOvfTransport
}
else
{
log.Error(Messages.ERROR_FILE_NAME_NULL);
log.Error("The file to import was not provided");
throw new InvalidDataException(Messages.ERROR_FILE_NAME_NULL);
}
#endregion
@ -740,9 +740,9 @@ namespace XenOvfTransport
}
if (freespace <= dataCapacity)
{
{
log.Error($"SR {sruuid} does not have {vhdDisk.Capacity} bytes of free space to import virtual disk {filename}.");
string message = string.Format(Messages.NOT_ENOUGH_SPACE_IN_SR, sruuid, Convert.ToString(vhdDisk.Capacity), filename);
log.Error(message);
throw new IOException(message);
}
}
@ -781,7 +781,7 @@ namespace XenOvfTransport
}
default:
{
log.Error(Messages.UNSUPPORTED_TRANSPORT);
log.Error($"Unsupported transfer type {useTransport.ToString()}");
throw new InvalidDataException(Messages.UNSUPPORTED_TRANSPORT);
}
}
@ -867,7 +867,7 @@ namespace XenOvfTransport
{
if (ex is OperationCanceledException)
throw;
log.ErrorFormat("{0} {1}", Messages.ERROR_ISCSI_UPLOAD_FAILED, ex.Message);
log.Error("Failed to import a virtual disk over iSCSI. ", ex);
vdiRef = null;
throw new Exception(Messages.ERROR_ISCSI_UPLOAD_FAILED, ex);
}
@ -965,7 +965,7 @@ namespace XenOvfTransport
{
if (ex is OperationCanceledException)
throw;
log.ErrorFormat("{0} {1}", Messages.ERROR_ISCSI_UPLOAD_FAILED, ex.Message);
log.Error("Failed to import a virtual disk over iSCSI.", ex);
vdiRef = null;
throw new Exception(Messages.ERROR_ISCSI_UPLOAD_FAILED, ex);
}
@ -1011,7 +1011,7 @@ namespace XenOvfTransport
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", Messages.ERROR_CANNOT_CREATE_VDI, ex.Message);
log.Error("Failed to create VDI. ", ex);
throw new Exception(Messages.ERROR_CANNOT_CREATE_VDI, ex);
}
log.Debug("Import.CeateVDI::VDI Created");
@ -1131,7 +1131,7 @@ namespace XenOvfTransport
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", Messages.ERROR_CANNOT_CREATE_VDI, ex.Message);
log.Error("Failed to create VDI", ex);
throw new Exception(Messages.ERROR_CANNOT_CREATE_VDI, ex);
}
log.Debug("Import.UploadRawVDI::VDI Created");
@ -1153,9 +1153,19 @@ namespace XenOvfTransport
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", Messages.ERROR_HTTP_UPLOAD_FAILED, ex.Message);
log.Error("Failed to import a virtual disk over HTTP. ", ex);
if (vdiRef != null)
RemoveVDI(xenSession, vdiRef);
{
try
{
VDI.destroy(xenSession, vdi.opaque_ref);
}
catch (Exception e)
{
log.Error("Failed to remove a virtual disk image (VDI). ", e);
throw new Exception(Messages.ERROR_REMOVE_VDI_FAILED, e);
}
}
vdiRef = null;
throw new Exception(Messages.ERROR_HTTP_UPLOAD_FAILED, ex);
}
@ -1334,7 +1344,7 @@ namespace XenOvfTransport
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", Messages.ERROR_CREATE_VM_FAILED, ex.Message);
log.Error("Failed to create a virtual machine (VM).", ex);
throw new Exception(Messages.ERROR_CREATE_VM_FAILED, ex);
}
}
@ -1421,24 +1431,9 @@ namespace XenOvfTransport
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", Messages.ERROR_REMOVE_VM_FAILED, ex.Message);
log.Error("Failed to remove a virtual machine (VM). ", ex);
throw new Exception(Messages.ERROR_REMOVE_VM_FAILED, ex);
}
return;
}
private void RemoveVDI(Session xenSession, XenRef<VDI> vdi)
{
try
{
log.Error("OVF.Import.RemoveVDI: Something went wrong deleting associated VDI");
VDI.destroy(xenSession, vdi.opaque_ref);
}
catch (Exception ex)
{
log.ErrorFormat("{0}, {1}", Messages.ERROR_REMOVE_VDI_FAILED, ex.Message);
throw new Exception(Messages.ERROR_REMOVE_VDI_FAILED, ex);
}
return;
}
private static Dictionary<string, string> SplitStringIntoDictionary(string inputStr)
@ -1597,7 +1592,7 @@ namespace XenOvfTransport
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", Messages.ERROR_CREATE_VIF_FAILED, ex.Message);
log.Error("Failed to create a virtual network interface (VIF). ", ex);
throw new Exception(Messages.ERROR_CREATE_VIF_FAILED, ex);
}
#endregion
@ -1731,14 +1726,14 @@ namespace XenOvfTransport
if (ex is OperationCanceledException)
throw;
var msg = string.Format(Messages.ERROR_ADDRESOURCESETTINGDATA_FAILED, Messages.ISO);
log.ErrorFormat("{0}, {1}", msg, ex.Message);
log.Error("Failed to add resource ISO.", ex);
throw new Exception(msg, ex);
}
finally
{
if (vdiRef == null || vdiRef.Count <= 0)
{
log.Error(string.Format(Messages.ERROR_IMPORT_DISK_FAILED, filename, isoUuid));
log.ErrorFormat("Failed to import virtual disk from file {0} to storage repository {1}.", filename, isoUuid);
RemoveSystem(xenSession, vmRef);
}
}
@ -1960,7 +1955,7 @@ namespace XenOvfTransport
{
if (DefaultSRUUID == null)
{
log.Error(Messages.ERROR_COULD_NOT_FIND_SR);
log.Error("The SR was not found and a default was not assigned.");
throw new InvalidDataException(Messages.ERROR_COULD_NOT_FIND_SR);
}
@ -1971,7 +1966,7 @@ namespace XenOvfTransport
XenRef<VDI> tempVDI = VDI.get_by_uuid(xenSession, vdiuuid);
if (tempVDI == null)
{
log.Error(Messages.ERROR_COULD_NOT_FIND_SR);
log.Error("The SR was not found and a default was not assigned.");
throw new InvalidDataException(Messages.ERROR_COULD_NOT_FIND_SR);
}
@ -2002,15 +1997,14 @@ namespace XenOvfTransport
if (ex is OperationCanceledException)
throw;
var msg = string.Format(Messages.ERROR_ADDRESOURCESETTINGDATA_FAILED, Messages.DISK_DEVICE);
log.ErrorFormat("{0} {1}", msg, ex.Message);
log.Error("Failed to add resource Hard Disk Image.", ex);
throw new InvalidDataException(msg, ex);
}
finally
{
if (vdiRef == null)
{
var msg = string.Format(Messages.ERROR_IMPORT_DISK_FAILED, filename, sruuid);
log.Error(msg);
log.ErrorFormat("Failed to import virtual disk from file {0} to storage repository {1}.", filename, sruuid);
RemoveSystem(xenSession, vmRef);
}
}
@ -2045,7 +2039,7 @@ namespace XenOvfTransport
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", Messages.ERROR_CREATE_VBD_FAILED, ex.Message);
log.Error("Failed to create a virtual block device (VBD).", ex);
throw new Exception(Messages.ERROR_CREATE_VBD_FAILED, ex);
}
}
@ -2393,7 +2387,7 @@ namespace XenOvfTransport
{
if (ex is OperationCanceledException)
throw;
log.Error(Messages.ERROR_IMPORT_FAILED);
log.Error("Failed to import.", ex);
throw new Exception(Messages.ERROR_IMPORT_FAILED, ex);
}
}

View File

@ -367,7 +367,7 @@ namespace XenOvfTransport {
}
/// <summary>
/// Looks up a localized string similar to Connecting virtual disk {0} ... .
/// Looks up a localized string similar to Connecting virtual disk {0}... .
/// </summary>
internal static string FILES_TRANSPORT_SETUP {
get {

View File

@ -214,7 +214,7 @@
<value>Disconnecting virtual disk {0} ... </value>
</data>
<data name="FILES_TRANSPORT_SETUP" xml:space="preserve">
<value>Connecting virtual disk {0} ... </value>
<value>Connecting virtual disk {0}... </value>
</data>
<data name="FILE_MISSING" xml:space="preserve">
<value>Failed to find {0}.</value>

View File

@ -119,7 +119,7 @@ namespace XenOvfTransport
try
{
log.DebugFormat(Messages.FILES_TRANSPORT_SETUP, vdiuuid);
log.DebugFormat("Connecting virtual disk {0}... ", vdiuuid);
TargetAddress ta = new TargetAddress(ipaddress, ipport, targetGroupTag);
TargetInfo[] targets = initiator.GetTargets(ta);
log.InfoFormat("iSCSI.Connect found {0} targets, connecting to: {1}", targets.Length, targets[0].Name);
@ -128,7 +128,7 @@ namespace XenOvfTransport
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", Messages.ISCSI_ERROR, ex.Message);
log.Error($"Failed to connect to VDI {vdiuuid} over iSCSI.", ex);
Thread.Sleep(new TimeSpan(0, 0, 5));
iSCSIConnectRetry--;
}
@ -179,7 +179,7 @@ namespace XenOvfTransport
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", Messages.ISCSI_ERROR_CANNOT_OPEN_DISK, ex.Message);
log.Error("Failed to open virtual disk.", ex);
throw new Exception(Messages.ISCSI_ERROR_CANNOT_OPEN_DISK, ex);
}
}
@ -232,7 +232,7 @@ namespace XenOvfTransport
{
if (Cancel)
{
log.InfoFormat(Messages.ISCSI_COPY_CANCELLED, filename);
log.InfoFormat("Canceled transfer of virtual disk {0}.", filename);
throw new OperationCanceledException(string.Format(Messages.ISCSI_COPY_CANCELLED, filename));
}
@ -268,8 +268,8 @@ namespace XenOvfTransport
}
catch (Exception ex)
{
log.Warn("Failed to transfer virtual disk.", ex);
var message = string.Format(Messages.ISCSI_COPY_ERROR, filename);
log.Warn(message);
throw new Exception(message, ex);
}
}
@ -314,7 +314,7 @@ namespace XenOvfTransport
{
if (Cancel)
{
log.Info(Messages.ISCSI_VERIFY_CANCELLED);
log.Info("Canceled virtual disk verification after export.");
throw new OperationCanceledException(Messages.ISCSI_VERIFY_CANCELLED);
}
@ -341,8 +341,8 @@ namespace XenOvfTransport
}
catch (Exception ex)
{
log.Warn($"Failed to verify virtual disk {filename}.", ex);
var message = string.Format(Messages.ISCSI_VERIFY_ERROR, filename);
log.WarnFormat("{0} {1}", message, ex.Message);
throw new Exception(message, ex);
}
}
@ -359,7 +359,7 @@ namespace XenOvfTransport
// Compare targetHash with copyHash.
if (!System.Linq.Enumerable.SequenceEqual(_copyHash, hashAlgorithm.Hash))
{
log.Error(Messages.ISCSI_VERIFY_INVALID);
log.Error("The exported virtual disk does not match the source.");
throw new Exception(Messages.ISCSI_VERIFY_INVALID);
}
}
@ -398,7 +398,7 @@ namespace XenOvfTransport
}
if (Cancel)
{
log.WarnFormat(Messages.ISCSI_COPY_CANCELLED, filename);
log.WarnFormat("Cancelled transfer of virtual disk {0}.", filename);
throw new OperationCanceledException(string.Format(Messages.ISCSI_COPY_CANCELLED, filename));
}
p += (ulong)n;
@ -411,8 +411,8 @@ namespace XenOvfTransport
{
if (ex is OperationCanceledException)
throw;
log.Warn($"Failed to transfer virtual disk {filename}.", ex);
var message = string.Format(Messages.ISCSI_COPY_ERROR, filename);
log.Warn(message);
throw new Exception(message, ex);
}
}
@ -505,7 +505,7 @@ namespace XenOvfTransport
}
catch (Exception ex)
{
log.ErrorFormat("{0} {1}", Messages.ISCSI_START_ERROR, ex.Message);
log.Error("Failed to start Transfer VM.", ex);
throw new Exception(Messages.ISCSI_START_ERROR, ex);
}
}
@ -531,7 +531,7 @@ namespace XenOvfTransport
}
catch (Exception ex)
{
log.WarnFormat("{0} {1}", Messages.ISCSI_SHUTDOWN_ERROR, ex.Message);
log.Warn("Failed to shutdown Transfer VM.", ex);
throw new Exception(Messages.ISCSI_SHUTDOWN_ERROR, ex);
}
}