Permalink
Browse files

If vSphere platforms are renamed, check to ensure name is unique.

  • Loading branch information...
1 parent 296d38c commit b7f4a28c1b23619253f60b916eb2362216042b3f pnguyen committed Jun 28, 2010
Showing with 9 additions and 1 deletion.
  1. +9 −1 hqu/hqapi1/app/ResourceController.groovy
@@ -651,7 +651,6 @@ class ResourceController extends ApiController {
def anotherPlatformWithSameName = resourceHelper.find('platform':name)
if (anotherPlatformWithSameName) {
- // rename platform using this convention: name (fqdn)
def uniqueName = generateVSpherePlatformName(name, fqdn.'@value')
name = uniqueName
config.name = uniqueName
@@ -682,6 +681,15 @@ class ResourceController extends ApiController {
// so keep using that name
name = uniqueName
config.name = uniqueName
+ } else {
+ // check to see if the new platform name is already used
+ def platformWithSameName = resourceHelper.find('platform':name)
+
+ if (platformWithSameName != null
+ && platformWithSameName.id != resource.id) {
+ name = uniqueName
+ config.name = uniqueName
+ }
}
}

0 comments on commit b7f4a28

Please sign in to comment.