Hi Guys,
I need some help regarding a workflow I want to build for our VMware administators to ease there management. But I'm stucked and do not know how to proceed. Maybe somebody can help me.
I have the following step inside my workflow:
//Roles of Source vCenter
var SourceRoleList = new Array();
var SourceRoleList = Source_vcenter.authorizationManager.roleList
var InfraSourceRoleList = new Array();
for each (Role in SourceRoleList)
{
if (Role.name.indexOf("Infra") != -1 )
{
InfraSourceRoleList.push(Role);
}
}
//Roles of Target vCenter
var TargetRoleList = new Array();
var TargetRoleList = Target_vcenter.authorizationManager.roleList;
var PreExisting = 0;
for each(Role in InfraSourceRoleList)
{
PreExisting = 0
for each(TargetRole in TargetRoleList)
{
if(TargetRole.name == Role.name)
{
PreExisting = 1
}
}
if(PreExisting == 1)
{
try
{
Target_vcenter.authorizationManager.updateAuthorizationRole(Role.roleId , Role.name , Role.privilege);
System.log("Role: " + Role.name + " --- Privileges updated");
}
catch(ex)
{
//System.log(ex);
System.log("Role: " + Role.name + " --- already exists - No Updates");
ex = null;
}
}
else
{
try
{
Target_vcenter.authorizationManager.addAuthorizationRole(Role.name , Role.privilege);
System.log("Role: " + Role.name + " --- created with privileges");
}
catch(ex)
{
Target_vcenter.authorizationManager.addAuthorizationRole(Role.name);
System.log("Role: " + Role.name + " --- created");
}
}
}
If the role is not existing in target vcenter every pivilege will copied correctly. If I try to update it fails.But when I read the descriptin of authorizationManager.updateAuthorizationRole for e it seems the right function to use.