fix check if flavor is null
package org.openbaton.vim_impl.vim.broker;
-import java.util.HashMap;
-import java.util.List;
-import javax.annotation.PostConstruct;
import org.openbaton.catalogue.mano.common.DeploymentFlavour;
import org.openbaton.catalogue.nfvo.Quota;
import org.openbaton.catalogue.nfvo.Server;
@@ -38,6 +35,11 @@ import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
+import java.util.HashMap;
+import java.util.List;
+
+import javax.annotation.PostConstruct;
+
/** Created by lto on 20/05/15. */
@Service
@Scope
@@ -282,15 +284,12 @@ public class VimBroker implements org.openbaton.nfvo.vim_interfaces.vim.VimBroke
List<Server> servers = vim.queryResources(vimInstance);
//Calculate used resource by servers (cpus, ram)
for (Server server : servers) {
- //Subtract floatingIps
-
//Subtract instances
maximalQuota.setInstances(maximalQuota.getInstances() - 1);
//Subtract used ram and cpus
- // TODO check whenever the library/rest command work.
DeploymentFlavour flavor = server.getFlavor();
- maximalQuota.setRam(maximalQuota.getRam() - flavor.getRam());
- maximalQuota.setCores(maximalQuota.getCores() - flavor.getVcpus());
+ maximalQuota.setRam(maximalQuota.getRam() - (flavor != null ? flavor.getRam() : 0));
+ maximalQuota.setCores(maximalQuota.getCores() - (flavor != null ? flavor.getVcpus() : 0));
// TODO add floating ips when quota command will work...
}
return maximalQuota;
