Ok this is my scenario. I started out with 1 fabric group and circled back to create multiple fabric groups for the different datacenters that I have. So one I created the fabric groups and added the compute resources, I then removed the compute from the original fabric group, which left the resource only in the new fabric group. I have a script that I use as an action to get the reservation polcies in the blueprint form. See below for script. Long story, short the script stopped working when I removed the resources from the original fabric group. If I understand things correctly, I do not see why this action would stop working when switching to a different fabric group that I have full permissions to. If anyone can explain any flaws in my logic, I am all ears. If not, and you have some time to place. Would you please take the script and create an action and present that action as a property definition, add to a blueprint and see if the action continues to work when you switch to a different fabric group.
Thanks
::::::SCRIPT::::::::
var blueprint = System.getContext().getParameter("__asd_composition_blueprintId");
var component = System.getContext().getParameter("__asd_composition_componentId");
var user = System.getContext().getParameter("__asd_requestedFor");
var tenant = System.getContext().getParameter("__asd_tenantRef");
var host = vCACCAFEHostManager.getDefaultHostForTenant(tenant , true);
var reservationPolicyService = host.createReservationClient().getReservationReservationPolicyService();
var reservations = System.getModule("com.vmware.vra.reservations").getReservationsForUserAndComponent(user,tenant,host, blueprint, component);
// get reservation filtered by reservations
var reservationPolicyFilter = getReservationPolicyFilterForReservations(reservations);
var reservationPolicies = [];
if (reservationPolicyFilter) {
reservationPolicies = reservationPolicyService.getAllReservationPolicies(reservationPolicyFilter).getContent();
}
var reservationPolicyProperties = new Properties();
for each(var reservationPolicy in reservationPolicies) {
reservationPolicyProperties.put(reservationPolicy.getId(),reservationPolicy.getName());
}
return reservationPolicyProperties;
//////////////////////////////////////////////////////////////////////////////////////////////////////////
function getReservationPolicyFilterForReservations(reservations) {
var query = new vCACCAFEOdataQuery();
var queryParams = [];
for each (var reservation in reservations) {
queryParams.push(vCACCAFEFilterParam.equal("id" , vCACCAFEFilterParam.string(reservation.getReservationPolicyId())));
}
if(queryParams.length > 1) {
query.addFilter([vCACCAFEFilterParam.or(queryParams)]);
} else if(queryParams.length == 1){
query.addFilter(queryParams);
} else {
return null;
}
return new vCACCAFEPageOdataRequest(1 , 2147483647, query);
}
Just out of curiosity, but did you realize in vRA 7.3 the café plug-in has a new action called getApplicableReservationPolicies in the com.vmware.vra.reservations module that will essentially do this for you based on the current user? If not, you may want to check this out as it could save some hassle.
That is where this came from and I have a different variation of that, that will assemble the policy name and get the policy info. What I am really looking for is a better understanding of fabric groups. When I started building things I started with 1 fabric group. Everything was working great in that setup. Since then, I was creating different fabric groups for different datacenters. I created additional fabric groups and added the compute resources to the new group and then let it bake for a day or two. After that time I removed the compute resources from the original fabric group, leaving the resources only in the new fabric group and that is when I noticed the action stopped working and displaying any information.
A little bit of digging and I discovered that once the resource was moved out of the original fabric group the resource would not show up in the vRO vRA plugin for the cafe appliance Administration -> Reservations. Unless I am missing something or not understanding things correct, I would not think it would matter which fabric group it was in as long as it was configured.
Am I missing something?
That I don't know about. I rarely ever see more than one fabric group, even with resources at multiple sites. Reason being that there isn't a separate level of responsibility for carving up those resources just because the site is different. Your case might be different. I'm wondering if the café plug-in is somehow caching that in vRO when the host is added. Might want to run that by Ilian.
Will do thanks!!
I am not seeing Ilian listed. What is his searchable username to send a message?
iiliev
Thanks
I ran through the setup you described here on 7.3 and could not reproduce the issue. I would suggest adding some debug logging to see if an error is getting kicked or what is happening. You should be able to see this anyway in the /var/log/vmware/vco/app-server/server.log
Just for good measure I updated your script with some debug logging, you could take a few steps further and output some of the objects you'd like to inspect along the way.
Updated Script:
System.debug("1. Getting __asd_composition_blueprintId");
var blueprint = System.getContext().getParameter("__asd_composition_blueprintId");
System.debug("2. Getting __asd_composition_componentId");
var component = System.getContext().getParameter("__asd_composition_componentId");
System.debug("3. Getting __asd_requestedFor");
var user = System.getContext().getParameter("__asd_requestedFor");
System.debug("4. Getting __asd_tenantRef");
var tenant = System.getContext().getParameter("__asd_tenantRef");
System.debug("5. Getting Default Host For Tenant");
var host = vCACCAFEHostManager.getDefaultHostForTenant(tenant , true);
System.debug("6. Getting reservaion policy service");
var reservationPolicyService = host.createReservationClient().getReservationReservationPolicyService();
System.debug("7. Getting reservations for user and component");
var reservations = System.getModule("com.vmware.vra.reservations").getReservationsForUserAndComponent(user,tenant,host, blueprint, component);
// get reservation filtered by reservations
System.debug("8. Getting reservation policy filter for reservations (function call)");
var reservationPolicyFilter = getReservationPolicyFilterForReservations(reservations);
var reservationPolicies = [];
if (reservationPolicyFilter) {
System.debug("9. Getting all reservation policies");
reservationPolicies = reservationPolicyService.getAllReservationPolicies(reservationPolicyFilter).getContent();
}
var reservationPolicyProperties = new Properties();
for each(var reservationPolicy in reservationPolicies) {
reservationPolicyProperties.put(reservationPolicy.getId(),reservationPolicy.getName());
}
return reservationPolicyProperties;
//////////////////////////////////////////////////////////////////////////////////////////////////////////
function getReservationPolicyFilterForReservations(reservations) {
System.debug(" getReservationPolicyFilterForReservations entered");
var query = new vCACCAFEOdataQuery();
var queryParams = [];
for each (var reservation in reservations) {
queryParams.push(vCACCAFEFilterParam.equal("id" , vCACCAFEFilterParam.string(reservation.getReservationPolicyId())));
}
if(queryParams.length > 1) {
query.addFilter([vCACCAFEFilterParam.or(queryParams)]);
} else if(queryParams.length == 1){
query.addFilter(queryParams);
} else {
return null;
}
System.debug(" getReservationPolicyFilterForReservations done. returning");
return new vCACCAFEPageOdataRequest(1 , 2147483647, query);
}
If you tail -f /var/log/vmware/vco/app-server/server.log while you load the blueprint and wait for the action to run then you'll see output like this:
Sample output
2017-11-16 02:15:25.477+0000 [http-nio-127.0.0.1-8280-exec-41] INFO {} [ManagedTokenRegistryImpl] Updating SecureToken with id: ff8080815eb95183015fc28be3a700a9
2017-11-16 02:15:25.478+0000 [http-nio-127.0.0.1-8280-exec-41] INFO {} [ManagedTokenRegistryImpl] SecureToken updated successfully for id: ff8080815eb95183015fc28be3a700a9
2017-11-16 02:15:25.651+0000 [http-nio-127.0.0.1-8280-exec-39] INFO {} [ManagedTokenRegistryImpl] Updating SecureToken with id: ff8080815eb95183015fc28be3a700a9
2017-11-16 02:15:25.652+0000 [http-nio-127.0.0.1-8280-exec-39] INFO {} [ManagedTokenRegistryImpl] SecureToken updated successfully for id: ff8080815eb95183015fc28be3a700a9
2017-11-16 02:15:25.818+0000 [http-nio-127.0.0.1-8280-exec-39] DEBUG {} [SCRIPTING_LOG] [script: systems.ltx/reservationPolicies] (systems.ltx/reservationPolicies) 1. Getting __asd_composition_blueprintId
2017-11-16 02:15:25.821+0000 [http-nio-127.0.0.1-8280-exec-39] DEBUG {} [SCRIPTING_LOG] [script: systems.ltx/reservationPolicies] (systems.ltx/reservationPolicies) 2. Getting __asd_composition_componentId
2017-11-16 02:15:25.821+0000 [http-nio-127.0.0.1-8280-exec-39] DEBUG {} [SCRIPTING_LOG] [script: systems.ltx/reservationPolicies] (systems.ltx/reservationPolicies) 3. Getting __asd_requestedFor
2017-11-16 02:15:25.823+0000 [http-nio-127.0.0.1-8280-exec-39] DEBUG {} [SCRIPTING_LOG] [script: systems.ltx/reservationPolicies] (systems.ltx/reservationPolicies) 4. Getting __asd_tenantRef
2017-11-16 02:15:25.824+0000 [http-nio-127.0.0.1-8280-exec-39] DEBUG {} [SCRIPTING_LOG] [script: systems.ltx/reservationPolicies] (systems.ltx/reservationPolicies) 5. Getting Default Host For Tenant
2017-11-16 02:15:25.864+0000 [http-nio-127.0.0.1-8280-exec-39] INFO {} [VCACHostManager] Returning default host for tenant 'mtd' with user 'cafe-yIxN0VYzHw@vsphere.local'
2017-11-16 02:15:25.864+0000 [http-nio-127.0.0.1-8280-exec-39] DEBUG {} [SCRIPTING_LOG] [script: systems.ltx/reservationPolicies] (systems.ltx/reservationPolicies) 6. Getting reservaion policy service
2017-11-16 02:15:25.896+0000 [http-nio-127.0.0.1-8280-exec-39] DEBUG {} [SCRIPTING_LOG] [script: systems.ltx/reservationPolicies] (systems.ltx/reservationPolicies) 7. Getting reservations for user and component
2017-11-16 02:15:26.100+0000 [http-nio-127.0.0.1-8280-exec-39] WARN {} [SCRIPTING_LOG] [script: systems.ltx/reservationPolicies] (systems.ltx/reservationPolicies) The selected component 'null' of blueprint 'RedHat7' is null
2017-11-16 02:15:26.103+0000 [http-nio-127.0.0.1-8280-exec-39] INFO {} [DynamicFunction] End of action 'com.vmware.vra.reservations/getReservationTypeIdForComponent', completed for: 57ms
2017-11-16 02:15:26.149+0000 [http-nio-127.0.0.1-8280-exec-39] WARN {} [SCRIPTING_LOG] [script: systems.ltx/reservationPolicies] (systems.ltx/reservationPolicies) The selected component 'null' of blueprint 'RedHat7' is null
2017-11-16 02:15:26.150+0000 [http-nio-127.0.0.1-8280-exec-39] INFO {} [DynamicFunction] End of action 'com.vmware.vra.reservations/getReservationTypeIdForComponent', completed for: 44ms
2017-11-16 02:15:26.276+0000 [http-nio-127.0.0.1-8280-exec-39] INFO {} [DynamicFunction] End of action 'com.vmware.vra.reservations/getReservationsForUserAndComponent', completed for: 378ms
2017-11-16 02:15:26.276+0000 [http-nio-127.0.0.1-8280-exec-39] DEBUG {} [SCRIPTING_LOG] [script: systems.ltx/reservationPolicies] (systems.ltx/reservationPolicies) 8. Getting reservation policy filter for reservations (function call)
2017-11-16 02:15:26.277+0000 [http-nio-127.0.0.1-8280-exec-39] DEBUG {} [SCRIPTING_LOG] [script: systems.ltx/reservationPolicies] (systems.ltx/reservationPolicies) getReservationPolicyFilterForReservations entered
2017-11-16 02:15:26.278+0000 [http-nio-127.0.0.1-8280-exec-39] DEBUG {} [SCRIPTING_LOG] [script: systems.ltx/reservationPolicies] (systems.ltx/reservationPolicies) getReservationPolicyFilterForReservations done. returning
2017-11-16 02:15:26.278+0000 [http-nio-127.0.0.1-8280-exec-39] DEBUG {} [SCRIPTING_LOG] [script: systems.ltx/reservationPolicies] (systems.ltx/reservationPolicies) 9. Getting all reservation policies
I'm sure this is not new to you, but I figured I would share what my approach would be if I needed to figure this out. If it indicates the whole thing runs through and the list is just empty, then I would start to play with outputting some of the objects retrieved and see what's up - are they null, array empty, etc?
FWIW your problem doesn't make sense and shouldn't relate to the Fabric group at all. Is it possible a different change occurred at the same time?