Commit 330deb56 by Fukász Rómeó Ervin

added functions to get all computes (or their ids) a user has access to

parent b872ee23
# Copyright 2017 Budapest University of Technology and Economics (BME IK)
#
# This file is part of CIRCLE Cloud.
#
# CIRCLE is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# CIRCLE is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
CPP=g++ CPP=g++
CC=gcc CC=gcc
AR=ar AR=ar
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
// with CIRCLE. If not, see <http://www.gnu.org/licenses/>. // with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
#include <string> #include <string>
#include <vector>
#include <memory> #include <memory>
#include "json.hpp" #include "json.hpp"
#include "resource.h" #include "resource.h"
...@@ -24,6 +25,7 @@ ...@@ -24,6 +25,7 @@
#include "compute.h" #include "compute.h"
using std::string; using std::string;
using std::vector;
using nlohmann::json; using nlohmann::json;
using std::shared_ptr; using std::shared_ptr;
using std::make_shared; using std::make_shared;
...@@ -72,6 +74,26 @@ shared_ptr<Compute> Compute::createComputeInstance(OcciSession* session, Templat ...@@ -72,6 +74,26 @@ shared_ptr<Compute> Compute::createComputeInstance(OcciSession* session, Templat
return make_shared<Compute>(Compute(session, instance)); return make_shared<Compute>(Compute(session, instance));
} }
vector<shared_ptr<Compute>> Compute::getComputeInstances(OcciSession* session){
auto result = vector<shared_ptr<Compute>>();
auto data = session->get("compute/");
for (auto& computeRendering : data["resources"]) {
auto computeInstance = make_shared<Compute>(Compute(session, computeRendering));
result.push_back(computeInstance);
}
return result;
}
vector<string> Compute::getComputeInstanceIds(OcciSession* session){
auto computes = getComputeInstances(session);
auto ids = vector<string>();
for (auto& compute : computes) {
ids.push_back(compute->getId());
}
return ids;
}
string Compute::getState(){ string Compute::getState(){
return this->state; return this->state;
} }
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#define OCCILIB_COMPUTE_H_ #define OCCILIB_COMPUTE_H_
#include <string> #include <string>
#include <vector>
#include <memory>
#include "json.hpp" #include "json.hpp"
#include "resource.h" #include "resource.h"
...@@ -58,6 +60,10 @@ namespace OcciClient { ...@@ -58,6 +60,10 @@ namespace OcciClient {
static std::shared_ptr<Compute> createComputeInstance(OcciSession* session, Template t); static std::shared_ptr<Compute> createComputeInstance(OcciSession* session, Template t);
static std::vector<std::shared_ptr<Compute>> getComputeInstances(OcciSession* session);
static std::vector<std::string> getComputeInstanceIds(OcciSession* session);
std::string getState(); std::string getState();
std::string getStateMessage(); std::string getStateMessage();
......
...@@ -36,4 +36,5 @@ ...@@ -36,4 +36,5 @@
namespace std { namespace std {
%template(TemplateVector) vector<Template>; %template(TemplateVector) vector<Template>;
%template(ComputeInstanceVector) vector<shared_ptr<OcciClient::Compute>>;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment