Skip to content

Commit

Permalink
Corrected Rbac dependencies for the export appliance operation.
Browse files Browse the repository at this point in the history
Signed-off-by: Konstantina Chremmou <[email protected]>
  • Loading branch information
kc284 committed Nov 30, 2023
1 parent 1f666fc commit 35e4c81
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion XenAdmin/Wizards/ExportWizard/ExportApplianceWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ private void AddRbacPage()
{
var exportAsXva = m_exportAsXva.HasValue && m_exportAsXva.Value;

var rbacDependencies = exportAsXva ? ExportVmAction.StaticRBACDependencies : ApplianceAction.StaticRBACDependencies;
var rbacDependencies = exportAsXva ? ExportVmAction.StaticRBACDependencies : ExportApplianceAction.StaticRBACDependencies;
var message = exportAsXva ? Messages.RBAC_WARNING_EXPORT_WIZARD_XVA : Messages.RBAC_WARNING_EXPORT_WIZARD_APPLIANCE;

m_pageRbac.SetPermissionChecks(xenConnection,
Expand Down
2 changes: 1 addition & 1 deletion XenAdmin/Wizards/ImportWizard/ImportWizard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ private void ConfigureRbacPage(IXenConnection selectedConnection)
var check = m_typeOfImport == ImportType.Ovf
? new WizardRbacCheck(Messages.RBAC_WARNING_IMPORT_WIZARD_APPLIANCE) {Blocking = true}
: new WizardRbacCheck(Messages.RBAC_WARNING_IMPORT_WIZARD_IMAGE) {Blocking = true};
check.AddApiMethods(ApplianceAction.StaticRBACDependencies);
check.AddApiMethods(ImportApplianceAction.StaticRBACDependencies);
m_pageRbac.SetPermissionChecks(selectedConnection, check);

AddAfterPage(m_pageHost, m_pageRbac);
Expand Down
17 changes: 0 additions & 17 deletions XenModel/Actions/OvfActions/ApplianceAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,6 @@ public abstract class ApplianceAction : AsyncAction
private const int SLEEP_TIME = 900;
private const int MAX_ITERATIONS = 60 * 60 * 24 / SLEEP_TIME * 1000; //iterations in 24h

/// <summary>
/// RBAC dependencies needed to import appliance/export an appliance/import disk image.
/// </summary>
public static RbacMethodList StaticRBACDependencies = new RbacMethodList("VM.add_to_other_config",
"VM.create",
"VM.destroy",
"VM.hard_shutdown",
"VM.remove_from_other_config",
"VM.set_HVM_boot_params",
"VM.start",
"VDI.create",
"VDI.destroy",
"VBD.create",
"VBD.eject",
"VIF.create",
"Host.call_plugin");

protected ApplianceAction(IXenConnection connection, string title)
: base(connection, title)
{
Expand Down
11 changes: 11 additions & 0 deletions XenModel/Actions/OvfActions/ExportApplianceAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ public ExportApplianceAction(IXenConnection connection, string applianceDirector
VM = m_vmsToExport[0];
}

public static RbacMethodList StaticRBACDependencies
{
get
{
var list = new RbacMethodList("task.create", "http/get_export_raw_vdi");
list.AddRange(Role.CommonTaskApiList);
list.AddRange(Role.CommonSessionApiList);
return list;
}
}

protected override void RunCore()
{
log.Info($"Exporting VMs to package {m_applianceFileName}");
Expand Down
15 changes: 15 additions & 0 deletions XenModel/Actions/OvfActions/ImportApplianceAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ public partial class ImportApplianceAction : ApplianceAction

#endregion

public static RbacMethodList StaticRBACDependencies = new RbacMethodList(
"VM.add_to_other_config",
"VM.create",
"VM.destroy",
"VM.hard_shutdown",
"VM.remove_from_other_config",
"VM.set_HVM_boot_params",
"VM.start",
"VDI.create",
"VDI.destroy",
"VBD.create",
"VBD.eject",
"VIF.create",
"Host.call_plugin");

public ImportApplianceAction(IXenConnection connection, Package package, Dictionary<string, VmMapping> vmMappings,
bool verifyManifest, bool verifySignature, string password, bool runfixups, SR selectedIsoSr, bool startAutomatically)
: base(connection, string.Empty)
Expand Down

0 comments on commit 35e4c81

Please sign in to comment.