use of cz.metacentrum.perun.openapi.AttributesManagerApi in project perun by CESNET.
the class ListOfVoMembersWithCertificate method executeCommand.
@Override
public void executeCommand(PerunCLI.CommandContext ctx) {
Integer voId = this.getVoId(ctx, true);
AttributesManagerApi attributesManager = ctx.getPerunRPC().getAttributesManager();
int prefDNid = attributesManager.getAttributeDefinitionByName("urn:perun:user:attribute-def:def:userPreferredCertDN").getId();
for (Member member : ctx.getPerunRPC().getMembersManager().getMembers(voId, null)) {
String pdn = (String) attributesManager.getUserAttributeById(member.getUserId(), prefDNid).getValue();
if (pdn != null) {
User user = ctx.getPerunRPC().getUsersManager().getUserById(member.getUserId());
System.out.println(user.getFirstName() + " " + user.getLastName() + " (" + member.getStatus() + ") " + pdn);
}
}
}
use of cz.metacentrum.perun.openapi.AttributesManagerApi in project perun by CESNET.
the class SetFacilityHostsAttributeValue method executeCommand.
@Override
public void executeCommand(PerunCLI.CommandContext ctx) {
int facilityId = this.getFacilityId(ctx, true);
int attributeDefinitionId = this.getAttributeDefinitionId(ctx, true);
String value = ctx.getCommandLine().getOptionValue("w");
Object attributeValue;
if (value.matches("\\d+")) {
attributeValue = Integer.valueOf(value);
} else {
attributeValue = value;
}
PerunRPC perunRPC = ctx.getPerunRPC();
AttributesManagerApi attributesManager = perunRPC.getAttributesManager();
List<Host> hosts = perunRPC.getFacilitiesManager().getHosts(facilityId);
for (Host host : hosts) {
Attribute attribute = attributesManager.getHostAttributeById(host.getId(), attributeDefinitionId);
attribute.setValue(attributeValue);
System.out.println("setting attribute on host " + host.getHostname() + " to " + attributeValue + " ...");
attributesManager.setHostAttribute(new InputSetHostAttribute().host(host.getId()).attribute(attribute));
}
System.out.println("OK");
}
Aggregations