Skip to content

Commit

Permalink
CA-40854: The Session's uuid is in reality its opaque_ref. Use the op…
Browse files Browse the repository at this point in the history
…aque_ref so

it's obvious what it is. The Session's uuid will be deprecated from the API bindings.

Signed-off-by: Konstantina Chremmou <[email protected]>
  • Loading branch information
kc284 authored and MihaelaStoica committed Feb 21, 2018
1 parent b091771 commit 63c6b81
Show file tree
Hide file tree
Showing 29 changed files with 592 additions and 587 deletions.
4 changes: 2 additions & 2 deletions XenAdmin/Actions/GUIActions/ExternalPluginAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private List<string> RetrieveParams(IXenObject obj)
WriteTrustedCertificates(master.Connection);
}

string sessionRef = connection.Session != null ? connection.Session.uuid : EmptyParameter;
string sessionRef = connection.Session != null ? connection.Session.opaque_ref : EmptyParameter;
string objCls = obj != null ? obj.GetType().Name : EmptyParameter;
string objUuid = obj != null && connection.Session != null ? Helpers.GetUuid(obj) : EmptyParameter;
return new List<string>(new string[] { masterAddress, sessionRef, objCls, objUuid });
Expand All @@ -278,7 +278,7 @@ private List<string> RetrieveParams(IXenConnection connection)
WriteTrustedCertificates(master.Connection);
}

string sessionRef = connection.Session != null ? connection.Session.uuid : EmptyParameter;
string sessionRef = connection.Session != null ? connection.Session.opaque_ref : EmptyParameter;
string objCls = BlankParamter;
string objUuid = BlankParamter;
return new List<string>(new string[] { masterAddress, sessionRef, objCls, objUuid });
Expand Down
6 changes: 3 additions & 3 deletions XenAdmin/ConsoleView/XSVNCScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,17 +1087,17 @@ private void ConnectHostedConsole(VNCGraphicsClient v, Console console)
}

Uri uri = new Uri(console.location);
String SessionUUID;
string sesssionRef;

lock (activeSessionLock)
{
// use the elevated credentials, if provided, for connecting to the console (CA-91132)
activeSession = (string.IsNullOrEmpty(ElevatedUsername) || string.IsNullOrEmpty(ElevatedPassword)) ?
console.Connection.DuplicateSession() : console.Connection.ElevatedSession(ElevatedUsername, ElevatedPassword);
SessionUUID = activeSession.uuid;
sesssionRef = activeSession.opaque_ref;
}

Stream stream = HTTPHelper.CONNECT(uri, console.Connection, SessionUUID, false, true);
Stream stream = HTTPHelper.CONNECT(uri, console.Connection, sesssionRef, false, true);

InvokeConnection(v, stream, console);
}
Expand Down
8 changes: 4 additions & 4 deletions XenAdmin/Controls/CustomDataGraph/ArchiveMaintainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ private Uri UpdateUri(Session session, Host host, ArchiveInterval interval, IXen
{
string query =
xo is Host ?
string.Format(RrdHostUpdatesQuery, Uri.EscapeDataString(session.uuid), TimeFromInterval(interval), RrdCFAverage, ToSeconds(interval)) :
string.Format(RrdHostUpdatesQuery, Uri.EscapeDataString(session.opaque_ref), TimeFromInterval(interval), RrdCFAverage, ToSeconds(interval)) :
xo is VM ?
string.Format(RrdVmUpdatesQuery, Uri.EscapeDataString(session.uuid), TimeFromInterval(interval), RrdCFAverage, ToSeconds(interval), Helpers.GetUuid(xo)) :
string.Format(RrdVmUpdatesQuery, Uri.EscapeDataString(session.opaque_ref), TimeFromInterval(interval), RrdCFAverage, ToSeconds(interval), Helpers.GetUuid(xo)) :
"";
return BuildUri(host, RrdUpdatesPath, query);
}
Expand All @@ -332,9 +332,9 @@ private static Uri RrdsUri(Session session, Host host, ArchiveInterval interval,
{
string query =
xo is Host ?
string.Format(RrdHostQuery, Uri.EscapeDataString(session.uuid)) :
string.Format(RrdHostQuery, Uri.EscapeDataString(session.opaque_ref)) :
xo is VM ?
string.Format(RrdVmQuery, Uri.EscapeDataString(session.uuid), Helpers.GetUuid(xo)) :
string.Format(RrdVmQuery, Uri.EscapeDataString(session.opaque_ref), Helpers.GetUuid(xo)) :
"";
return BuildUri(host, xo is Host ? RrdHostPath : RrdVmPath, query);
}
Expand Down
4 changes: 2 additions & 2 deletions XenAdmin/Diagnostics/Checks/DR/AssertCanBeRecoveredCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ protected override Problem RunCheck()
try
{
if (xenObject is VM)
VM.assert_can_be_recovered(MetadataSession, xenObject.opaque_ref, Pool.Connection.Session.uuid);
VM.assert_can_be_recovered(MetadataSession, xenObject.opaque_ref, Pool.Connection.Session.opaque_ref);
if (xenObject is VM_appliance)
VM_appliance.assert_can_be_recovered(MetadataSession, xenObject.opaque_ref,
Pool.Connection.Session.uuid);
Pool.Connection.Session.opaque_ref);
}
catch (Failure f)
{
Expand Down
2 changes: 1 addition & 1 deletion XenAdmin/Dialogs/EvacuateHostDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ private void EvacuateHostDialog_FormClosed(object sender, FormClosedEventArgs e)

deregisterVMEvents();

if (elevatedSession != null && elevatedSession.uuid != null)
if (elevatedSession != null && elevatedSession.opaque_ref != null)
{
// NOTE: This doesnt happen currently, as we always scan once. Here as cheap insurance.
// we still have the session from the role elevation dialog
Expand Down
7 changes: 6 additions & 1 deletion XenAdmin/Plugins/Features/TabPageFeature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,9 @@ public class ScriptingObject
private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public const string JAVASCRIPT_CALLBACK_METHOD = "XenCenterXML";

[Obsolete("Use SessionOpaqueRef instead.")]
public string SessionUuid;
public string SessionOpaqueRef;
public string SessionUrl;
private IXenConnection connection;
public WebBrowser2 browser;
Expand Down Expand Up @@ -932,7 +934,10 @@ public void LoginSession()
if (connection != null)
{
SessionUrl = connection.Session.Url;
SessionUuid = connection.DuplicateSession().uuid;
SessionOpaqueRef = connection.DuplicateSession().opaque_ref;
#pragma warning disable 612, 618
SessionUuid = SessionOpaqueRef;
#pragma warning restore 612, 618
}
}

Expand Down
2 changes: 1 addition & 1 deletion XenAdmin/Plugins/Placeholders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private static string GetPlaceholderReplacement(string placeholder, IList<IXenOb
{
return NULL_PLACEHOLDER_KEY;
}
return objs[0].Connection.Session.uuid;
return objs[0].Connection.Session.opaque_ref;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion XenAdmin/WinformsXenAdminConfigProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public IWebProxy GetProxyFromSettings(IXenConnection connection, bool isForXenSe
{
try
{
if (connection != null && connection.Session != null && connection.Session.uuid == "dummy")
if (connection != null && connection.Session != null && connection.Session.opaque_ref == "dummy")
return new XenAdminSimulatorWebProxy(DbProxy.proxys[connection]);

switch ((HTTPHelper.ProxyStyle)XenAdmin.Properties.Settings.Default.ProxySetting)
Expand Down
4 changes: 2 additions & 2 deletions XenModel/Actions/AsyncAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private void RunWorkerThread(object o)
}
catch(Failure ex)
{
log.Debug("Session.logout() failed for Session uuid " + Session.uuid, ex);
log.Debug("Session.logout() failed for Session uuid " + Session.opaque_ref, ex);
}
}

Expand All @@ -262,7 +262,7 @@ public virtual void DestroyTask()
{
//Program.AssertOffEventThread();

if (Session == null || string.IsNullOrEmpty(Session.uuid) || RelatedTask == null)
if (Session == null || string.IsNullOrEmpty(Session.opaque_ref) || RelatedTask == null)
return;

try
Expand Down
2 changes: 1 addition & 1 deletion XenModel/Actions/CancellingAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public virtual void RecomputeCanCancel()
}

Session local_session = GetCancelSession();
if (local_session == null || string.IsNullOrEmpty(local_session.uuid))
if (local_session == null || string.IsNullOrEmpty(local_session.opaque_ref))
{
can_cancel = false;
return;
Expand Down
4 changes: 2 additions & 2 deletions XenModel/Actions/DR/DrRecoverAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ protected override void Run()
if (MetadataSession != null)
{
if (xenObject is VM)
RelatedTask = VM.async_recover(MetadataSession, xenObject.opaque_ref, Session.uuid, true);
RelatedTask = VM.async_recover(MetadataSession, xenObject.opaque_ref, Session.opaque_ref, true);
if (xenObject is VM_appliance)
{
// if appliance already exists in target pool, it will be replaced during recovery and the uuid is preserved
RelatedTask = VM_appliance.async_recover(MetadataSession, xenObject.opaque_ref, Session.uuid, true);
RelatedTask = VM_appliance.async_recover(MetadataSession, xenObject.opaque_ref, Session.opaque_ref, true);
}
PollToCompletion();
}
Expand Down
4 changes: 2 additions & 2 deletions XenModel/Actions/Host/HostBackupRestoreAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected override void Run()
try
{
HTTPHelper.Get(this, true, DataReceived, filename, Host.address,
(HTTP_actions.get_ss)HTTP_actions.get_host_backup, Session.uuid);
(HTTP_actions.get_ss)HTTP_actions.get_host_backup, Session.opaque_ref);
}
finally
{
Expand All @@ -96,7 +96,7 @@ protected override void Run()
this.Description = String.Format(Messages.RESTORING_HOST, Host.Name());

HTTPHelper.Put(this, true, filename, Host.address,
(HTTP_actions.put_ss)HTTP_actions.put_host_restore, Session.uuid);
(HTTP_actions.put_ss)HTTP_actions.put_host_restore, Session.opaque_ref);

this.Description = String.Format(Messages.HOST_RESTORED, Host.Name());
break;
Expand Down
2 changes: 1 addition & 1 deletion XenModel/Actions/Host/SingleHostStatusAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected override void Run()

HTTPHelper.Get(this, false, dataRxDelegate, filename, host.Host.address,
(HTTP_actions.get_ssss)HTTP_actions.get_system_status,
Session.uuid, entries_string, "tar");
Session.opaque_ref, entries_string, "tar");

log.DebugFormat("Getting system status from {0} successful", hostname);

Expand Down
4 changes: 2 additions & 2 deletions XenModel/Actions/Pool_Patch/ApplyPatchAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected XenRef<Pool_patch> BringPatchToPoolForHost(Host host, Pool_patch patch
{
HTTPHelper.Get(this, true, filename, patch.Connection.Hostname,
(HTTP_actions.get_sss)HTTP_actions.get_pool_patch_download,
Session.uuid, patch.uuid);
Session.opaque_ref, patch.uuid);
}
catch (Exception e)
{
Expand All @@ -89,7 +89,7 @@ protected XenRef<Pool_patch> BringPatchToPoolForHost(Host host, Pool_patch patch
try
{
string result = HTTPHelper.Put(this, true, filename, host.Connection.Hostname,
(HTTP_actions.put_ss)HTTP_actions.put_pool_patch_upload, Session.uuid);
(HTTP_actions.put_ss)HTTP_actions.put_pool_patch_upload, Session.opaque_ref);

return new XenRef<Pool_patch>(result);
}
Expand Down
2 changes: 1 addition & 1 deletion XenModel/Actions/Pool_Patch/UploadPatchAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private Pool_patch UploadRetailPatch(Host host)
try
{
result = HTTPHelper.Put(progressDelegate, GetCancelling, true, Connection, RelatedTask, ref session, retailPatchPath,
h.address, (HTTP_actions.put_ss)HTTP_actions.put_pool_patch_upload, session.uuid);
h.address, (HTTP_actions.put_ss)HTTP_actions.put_pool_patch_upload, session.opaque_ref);
}
catch(CancelledException)
{
Expand Down
Loading

0 comments on commit 63c6b81

Please sign in to comment.