From a155f4c2300acf0d661f9da8471256456d988bf7 Mon Sep 17 00:00:00 2001 From: Rizwan Date: Fri, 7 Apr 2017 15:32:57 +0900 Subject: [PATCH 1/2] Removed extra call for image fetching --- .../openstack4j/OpenStack4JDriver.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/openbaton/drivers/openstack4j/OpenStack4JDriver.java b/src/main/java/org/openbaton/drivers/openstack4j/OpenStack4JDriver.java index 6dd6d6d..a38855e 100644 --- a/src/main/java/org/openbaton/drivers/openstack4j/OpenStack4JDriver.java +++ b/src/main/java/org/openbaton/drivers/openstack4j/OpenStack4JDriver.java @@ -191,16 +191,15 @@ public Server launchInstance( OSClient os = this.authenticate(vimInstance); List networks = getNetworkIdsFromNames(vimInstance, network); - String imageId = getImageIdFromName(vimInstance, image); - log.debug("imageId: " + imageId); - org.openstack4j.model.image.Image imageFromVim = os.images().get(imageId); - log.debug("Image received from VIM: " + imageFromVim); - if (imageFromVim == null) { + Image image4j = getImageFromName(vimInstance, image); + log.debug("Image received from VIM: " + image4j); + if (image4j == null) { throw new VimException("Not found image " + image + " on VIM " + vimInstance.getName()); - } else if (imageFromVim.getStatus() == null - || imageFromVim.getStatus() != (org.openstack4j.model.image.Image.Status.ACTIVE)) { + } else if (image4j.getStatus() == null || image4j.getStatus() != (Image.Status.ACTIVE)) { throw new VimException("Image " + image + " is not yet in active. Try again later..."); } + image = image4j.getId(); + log.debug("imageId: " + image); Flavor flavor4j = getFlavorFromName(vimInstance, flavor); flavor = flavor4j.getId(); // temporary workaround for getting first security group as it seems not supported adding multiple security groups @@ -210,7 +209,7 @@ public Server launchInstance( Builders.server() .name(name) .flavor(flavor) - .image(imageId) + .image(image) .networks(networks) .userData(new String(Base64.encodeBase64(userData.getBytes()))) .build(); @@ -219,7 +218,7 @@ public Server launchInstance( Builders.server() .name(name) .flavor(flavor) - .image(imageId) + .image(image) .keypairName(keypair) .networks(networks) .userData(new String(Base64.encodeBase64(userData.getBytes()))) @@ -236,7 +235,7 @@ public Server launchInstance( + ", SecGroup, " + secGroup + ", imageId: " - + imageId + + image + ", flavorId: " + flavor + ", networks: " @@ -317,6 +316,14 @@ public int compare(VNFDConnectionPoint o1, VNFDConnectionPoint o2) { return res; } + private Image getImageFromName(VimInstance vimInstance, String image) throws VimDriverException { + OSClient os = this.authenticate(vimInstance); + for (Image image4j : os.images().list()) { + if (image4j.getName().equals(image) || image4j.getId().equals(image)) return image4j; + } + throw new VimDriverException("Not found image '" + image + "' on " + vimInstance.getName()); + } + private String getImageIdFromName(VimInstance vimInstance, String imageName) throws VimDriverException { log.info("Getting image id of " + imageName + " on " + vimInstance.getName()); From 3a2244226eaf5375036ef6110dc39ccdeacec8dc Mon Sep 17 00:00:00 2001 From: Rizwan Date: Fri, 7 Apr 2017 15:43:37 +0900 Subject: [PATCH 2/2] Removed unwanted gradle dependency Removed jcloud glance dependency from gradle file. --- build.gradle | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.gradle b/build.gradle index d79ca7c..e2fbc01 100644 --- a/build.gradle +++ b/build.gradle @@ -89,8 +89,6 @@ dependencies { compile 'org.openbaton:exception:' + obVersion compile 'org.openbaton:plugin-sdk:' + obVersion - compile 'org.apache.jclouds.labs:openstack-glance:2.0.0' - compile group: 'org.pacesys', name: 'openstack4j', version: '3.0.3'