diff --git a/ChangeLog b/ChangeLog index 8c6aaaa7..23798373 100644 --- a/ChangeLog +++ b/ChangeLog @@ -49,6 +49,8 @@ Changes in HQApi 3.0 Changes in HQApi 2.4 + *) [HHQ-3603] Add support for location field for Resources. + *) [HHQ-3583] Fix handling of -s and --secure CLI options. *) [HHQ-3565] Fix issue in MetricAPI causing all metrics to be shown as diff --git a/hqu/hqapi1/app/ResourceController.groovy b/hqu/hqapi1/app/ResourceController.groovy index 37d44455..9829d286 100644 --- a/hqu/hqapi1/app/ResourceController.groovy +++ b/hqu/hqapi1/app/ResourceController.groovy @@ -11,11 +11,25 @@ class ResourceController extends ApiController { private static final String PROP_INSTALLPATH = "installPath" private static final String PROP_AIIDENIFIER = "autoIdentifier" + // TODO: move into ResourceCategory + private getLocation(r) { + if (r.isPlatform()) { + return r.toPlatform().location + } else if (r.isServer()) { + return r.toServer().location + } else if (r.isService()) { + return r.toService().location + } + throw new IllegalArgumentException("getLocation() called for invalid resource " + + r.name + " (id=" + r.id + ")") + } + private Closure getResourceXML(user, r, boolean verbose, boolean children) { { doc -> Resource(id : r.id, name : r.name, - description : r.description) { + description : r.description, + location : getLocation(r)) { if (verbose) { def config = r.getConfig() config.each { k, v -> @@ -545,9 +559,12 @@ class ResourceController extends ApiController { def id = xmlResource.'@id'?.toInteger() def name = xmlResource.'@name' def description = xmlResource.'@description' + def location = xmlResource.'@location' def config = [name: name, - description: description] + description: description, + location: location] + xmlResource['ResourceConfig'].each { // Do not set configs for empty keys if (it.'@value' && it.'@value'.length() > 0) { diff --git a/xsd/HQApi1.xsd b/xsd/HQApi1.xsd index 4def6cbd..c734753d 100644 --- a/xsd/HQApi1.xsd +++ b/xsd/HQApi1.xsd @@ -79,6 +79,7 @@ e.g installpath, fqdn, autoinventory identifier --> +