Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed extra call for image fetching #23

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,15 @@ public Server launchInstance(
OSClient os = this.authenticate(vimInstance);
List<String> 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
Expand All @@ -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();
Expand All @@ -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())))
Expand All @@ -236,7 +235,7 @@ public Server launchInstance(
+ ", SecGroup, "
+ secGroup
+ ", imageId: "
+ imageId
+ image
+ ", flavorId: "
+ flavor
+ ", networks: "
Expand Down Expand Up @@ -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());
Expand Down