diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index f2d2136645..a9d9ca37a1 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -1392,17 +1392,12 @@ public: // Public cloud templates related functions // ------------------------------------------------------------------------ - /** - * Checks if the VM can be deployed in a public cloud provider - * @return true if the VM can be deployed in a public cloud provider - */ - bool is_public_cloud() const; - /** * Gets the list of public cloud hypervisors for which this VM has definitions - * @return the list of public cloud hypervisors + * @param list to store the cloud hypervisors in the template + * @return the number of public cloud hypervisors */ - vector get_public_cloud_hypervisors() const; + int get_public_cloud_hypervisors(vector &cloud_hypervisors) const; private: diff --git a/src/scheduler/src/sched/Scheduler.cc b/src/scheduler/src/sched/Scheduler.cc index 6c518abb5f..cd06de4f47 100644 --- a/src/scheduler/src/sched/Scheduler.cc +++ b/src/scheduler/src/sched/Scheduler.cc @@ -765,6 +765,8 @@ void Scheduler::match_schedule() if (vm->is_public_cloud()) { vm->set_only_public_cloud(); + + continue; } else { diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index 53d43d246d..45273f5373 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -1130,7 +1130,9 @@ int VirtualMachine::automatic_requirements(string& error_str) string requirements; string cluster_id = ""; - vector public_cloud_hypervisors = get_public_cloud_hypervisors(); + vector public_cloud_hypervisors; + + int num_public = get_public_cloud_hypervisors(public_cloud_hypervisors); int incomp_id; int rc; @@ -1216,13 +1218,13 @@ int VirtualMachine::automatic_requirements(string& error_str) oss << "!(PUBLIC_CLOUD = YES)"; } - if (!public_cloud_hypervisors.empty()) + if (num_public != 0) { oss << " | (PUBLIC_CLOUD = YES & ("; oss << "HYPERVISOR = " << public_cloud_hypervisors[0]; - for (size_t i = 1; i < public_cloud_hypervisors.size(); i++) + for (int i = 1; i < num_public; i++) { oss << " | HYPERVISOR = " << public_cloud_hypervisors[i]; } @@ -3666,23 +3668,12 @@ void VirtualMachine::clear_template_monitor_error() /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -bool VirtualMachine::is_public_cloud() const -{ - vector v = get_public_cloud_hypervisors(); - - return (v.size() > 0); -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - -vector VirtualMachine::get_public_cloud_hypervisors() const +int VirtualMachine::get_public_cloud_hypervisors(vector &public_cloud_hypervisors) const { vector attrs; vector::const_iterator it; VectorAttribute * vatt; - vector public_cloud_hypervisors; user_obj_template->get("PUBLIC_CLOUD", attrs); @@ -3713,5 +3704,5 @@ vector VirtualMachine::get_public_cloud_hypervisors() const public_cloud_hypervisors.push_back("ec2"); } - return public_cloud_hypervisors; + return public_cloud_hypervisors.size(); }