mirror of
https://github.com/xcp-ng/xenadmin.git
synced 2025-01-20 07:19:18 +01:00
CP-21904: Update RPU hotfixes in XenCenter
- Added RPU004 for Ely and updated the code to upload and apply the iso format hotfix Signed-off-by: Mihaela Stoica <mihaela.stoica@citrix.com>
This commit is contained in:
parent
633ea16a66
commit
8a4a2ab716
@ -45,6 +45,15 @@ do
|
||||
fi
|
||||
done
|
||||
|
||||
for hfx in RPU004
|
||||
do
|
||||
if [ -d "${hfx}" ]; then
|
||||
latest=$(ls ${hfx} | /usr/bin/sort -n | tail -n 1)
|
||||
echo "INFO: Latest version of ${hfx} hotfix is $latest"
|
||||
cp ${hfx}/$latest/${hfx}.iso ${hfx}.iso
|
||||
fi
|
||||
done
|
||||
|
||||
for hfx in RPU001
|
||||
do
|
||||
if [ -d "${hfx}" ]; then
|
||||
|
@ -160,6 +160,7 @@
|
||||
<?endif?>
|
||||
<File Id="hotfixCreedence" Source="..\Branding\Hotfixes\RPU002.[xsupdate]" />
|
||||
<File Id="hotfixDundee" Source="..\Branding\Hotfixes\RPU003.[xsupdate]" />
|
||||
<File Id="hotfixEly" Source="..\Branding\Hotfixes\RPU004.iso" />
|
||||
</Component>
|
||||
<?if "$(env.Branding)"="XenCenter"?>
|
||||
<!-- TestResources -->
|
||||
|
@ -43,7 +43,8 @@ namespace XenAdmin.Diagnostics.Hotfixing
|
||||
Boston,
|
||||
SanibelToClearwater,
|
||||
Creedence,
|
||||
Dundee
|
||||
Dundee,
|
||||
Ely
|
||||
}
|
||||
|
||||
private readonly Hotfix bostonHotfix = new MultipleHotfix()
|
||||
@ -81,8 +82,16 @@ namespace XenAdmin.Diagnostics.Hotfixing
|
||||
UUID = "474a0f28-0d33-4c9b-9e20-52baaea8ce5e"
|
||||
};
|
||||
|
||||
private readonly Hotfix elyHotfix = new SingleHotfix
|
||||
{
|
||||
Filename = "RPU004",
|
||||
UUID = "1ac61687-8b65-43e6-957f-50602fb79572"
|
||||
};
|
||||
|
||||
public Hotfix Hotfix(Host host)
|
||||
{
|
||||
if (Helpers.ElyOrGreater(host) && !Helpers.FalconOrGreater(host))
|
||||
return Hotfix(HotfixableServerVersion.Ely);
|
||||
if (Helpers.DundeeOrGreater(host) && !Helpers.ElyOrGreater(host))
|
||||
return Hotfix(HotfixableServerVersion.Dundee);
|
||||
if (Helpers.CreedenceOrGreater(host) && !Helpers.DundeeOrGreater(host))
|
||||
@ -97,6 +106,8 @@ namespace XenAdmin.Diagnostics.Hotfixing
|
||||
|
||||
public Hotfix Hotfix(HotfixableServerVersion version)
|
||||
{
|
||||
if (version == HotfixableServerVersion.Ely)
|
||||
return elyHotfix;
|
||||
if (version == HotfixableServerVersion.Dundee)
|
||||
return dundeeHotfix;
|
||||
if (version == HotfixableServerVersion.Creedence)
|
||||
|
@ -30,6 +30,7 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
@ -46,31 +47,63 @@ namespace XenAdmin.Diagnostics.Hotfixing
|
||||
|
||||
public sealed override void Apply(Host host, Session session)
|
||||
{
|
||||
Pool_patch patch = host.Connection.Cache.Find_By_Uuid<Pool_patch>(UUID);
|
||||
if (patch == null)
|
||||
{
|
||||
var master = Helpers.GetMaster(host.Connection);
|
||||
var action = new Actions.UploadPatchAction(master.Connection, Path.Combine(Program.AssemblyDir, String.Format("{0}.{1}", Filename, Branding.Update)));
|
||||
action.RunExternal(session);
|
||||
patch = action.PatchRefs[master];
|
||||
}
|
||||
Pool_patch.apply(session, patch.opaque_ref, host.opaque_ref);
|
||||
bool elyOrGreater = Helpers.ElyOrGreater(host);
|
||||
if (elyOrGreater)
|
||||
UploadAndApplyUpdate(host, session);
|
||||
else
|
||||
UploadAndApplyPatch(host, session);
|
||||
|
||||
IXenObject patch;
|
||||
int numberRetries = 0;
|
||||
do
|
||||
{
|
||||
Thread.Sleep(500);
|
||||
patch = host.Connection.Cache.Find_By_Uuid<Pool_patch>(UUID);
|
||||
patch = elyOrGreater
|
||||
? (IXenObject)host.Connection.Cache.Find_By_Uuid<Pool_update>(UUID)
|
||||
: host.Connection.Cache.Find_By_Uuid<Pool_patch>(UUID);
|
||||
numberRetries++;
|
||||
|
||||
} while (patch == null && numberRetries < 10);
|
||||
}
|
||||
|
||||
private void UploadAndApplyPatch(Host host, Session session)
|
||||
{
|
||||
var patch = host.Connection.Cache.Find_By_Uuid<Pool_patch>(UUID);
|
||||
if (patch == null)
|
||||
{
|
||||
var master = Helpers.GetMaster(host.Connection);
|
||||
var filePath = Path.Combine(Program.AssemblyDir, String.Format("{0}.{1}", Filename, Branding.Update));
|
||||
var action = new Actions.UploadPatchAction(master.Connection, filePath);
|
||||
action.RunExternal(session);
|
||||
patch = action.PatchRefs[master];
|
||||
}
|
||||
Pool_patch.apply(session, patch.opaque_ref, host.opaque_ref);
|
||||
}
|
||||
|
||||
private void UploadAndApplyUpdate(Host host, Session session)
|
||||
{
|
||||
var update = host.Connection.Cache.Find_By_Uuid<Pool_update>(UUID);
|
||||
if (update == null)
|
||||
{
|
||||
var master = Helpers.GetMaster(host.Connection);
|
||||
var filePath = Path.Combine(Program.AssemblyDir, String.Format("{0}.{1}", Filename, Branding.UpdateIso));
|
||||
var action = new Actions.UploadSupplementalPackAction(master.Connection, new List<Host>() { master }, filePath, true);
|
||||
action.RunExternal(session);
|
||||
update = action.PoolUpdate;
|
||||
}
|
||||
Pool_update.apply(session, update.opaque_ref, host.opaque_ref);
|
||||
}
|
||||
|
||||
public override bool ShouldBeAppliedTo(Host host)
|
||||
{
|
||||
if (Helpers.ElyOrGreater(host))
|
||||
{
|
||||
var updates = host.Connection.ResolveAll(host.updates);
|
||||
return !updates.Any(update => UUID.ToLowerInvariant().Contains(update.uuid.ToLowerInvariant()));
|
||||
}
|
||||
var patches = host.Connection.ResolveAll(host.patches);
|
||||
var poolPatches = patches.Select(hostPatch => hostPatch.Connection.Resolve(hostPatch.pool_patch));
|
||||
return !poolPatches.Any( patch => UUID.ToLowerInvariant().Contains(patch.uuid.ToLowerInvariant()));
|
||||
return !poolPatches.Any(patch => UUID.ToLowerInvariant().Contains(patch.uuid.ToLowerInvariant()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ namespace XenAdminTests.UnitTests.Diagnostics
|
||||
string[] enumNames = Enum.GetNames(typeof (HotfixFactory.HotfixableServerVersion));
|
||||
Array.Sort(enumNames);
|
||||
|
||||
string[] expectedNames = new []{"Boston", "SanibelToClearwater", "Creedence", "Dundee"};
|
||||
string[] expectedNames = new []{"Boston", "SanibelToClearwater", "Creedence", "Dundee", "Ely"};
|
||||
Array.Sort(expectedNames);
|
||||
|
||||
CollectionAssert.AreEqual(expectedNames, enumNames, "Expected contents of HotfixableServerVersion enum");
|
||||
@ -83,6 +83,10 @@ namespace XenAdminTests.UnitTests.Diagnostics
|
||||
Assert.AreEqual("474a0f28-0d33-4c9b-9e20-52baaea8ce5e",
|
||||
factory.Hotfix(HotfixFactory.HotfixableServerVersion.Dundee).UUID,
|
||||
"Dundee UUID lookup from enum");
|
||||
|
||||
Assert.AreEqual("1ac61687-8b65-43e6-957f-50602fb79572",
|
||||
factory.Hotfix(HotfixFactory.HotfixableServerVersion.Ely).UUID,
|
||||
"Ely UUID lookup from enum");
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -103,12 +107,16 @@ namespace XenAdminTests.UnitTests.Diagnostics
|
||||
Assert.AreEqual("RPU003",
|
||||
factory.Hotfix(HotfixFactory.HotfixableServerVersion.Dundee).Filename,
|
||||
"Dundee Filename lookup from enum");
|
||||
|
||||
Assert.AreEqual("RPU004",
|
||||
factory.Hotfix(HotfixFactory.HotfixableServerVersion.Ely).Filename,
|
||||
"Ely Filename lookup from enum");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase("2.1.1", Description = "Ely")]
|
||||
[TestCase("2.2.50", Description = "Falcon")]
|
||||
[TestCase("9999.9999.9999", Description = "Future")]
|
||||
public void TestPlatformVersionNumbersElyOrGreaterGiveNulls(string platformVersion)
|
||||
public void TestPlatformVersionNumbersFalconOrGreaterGiveNulls(string platformVersion)
|
||||
{
|
||||
Mock<Host> host = ObjectManager.NewXenObject<Host>(id);
|
||||
host.Setup(h => h.PlatformVersion).Returns(platformVersion);
|
||||
@ -126,7 +134,8 @@ namespace XenAdminTests.UnitTests.Diagnostics
|
||||
}
|
||||
|
||||
[Test]
|
||||
[TestCase("2.1.1", Description = "Ely", Result = false)]
|
||||
[TestCase("2.2.50", Description = "Falcon", Result = false)]
|
||||
[TestCase("2.1.1", Description = "Ely", Result = true)]
|
||||
[TestCase("2.0.0", Description = "Dundee", Result = true)]
|
||||
[TestCase("1.9.0", Description = "Creedence", Result = true)]
|
||||
[TestCase("1.8.0", Description = "Clearwater", Result = true)]
|
||||
|
Loading…
Reference in New Issue
Block a user