pax_global_header 0000666 0000000 0000000 00000000064 13130523340 0014504 g ustar 00root root 0000000 0000000 52 comment=08f1396159642e2d17f2ac599effa84e3883a59a
libocci-2-login-should-return-a-proper-response-08f1396159642e2d17f2ac599effa84e3883a59a/ 0000775 0000000 0000000 00000000000 13130523340 0027441 5 ustar 00root root 0000000 0000000 libocci-2-login-should-return-a-proper-response-08f1396159642e2d17f2ac599effa84e3883a59a/.gitignore 0000664 0000000 0000000 00000000151 13130523340 0031426 0 ustar 00root root 0000000 0000000 *.pyc
*.sw[pon]
*.o
*.so
*.a
libocci.egg-info
restclient-cpp
build
dist
occi.py
occilib_wrap.cpp
test.py
libocci-2-login-should-return-a-proper-response-08f1396159642e2d17f2ac599effa84e3883a59a/Makefile 0000664 0000000 0000000 00000003671 13130523340 0031110 0 ustar 00root root 0000000 0000000 # 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 .
CPP=g++
CC=gcc
AR=ar
CFLAGS=-fPIC -Ofast
CPPFLAGS=-fPIC --std=c++11 -Ofast -Irestclient-cpp/include `pkg-config --cflags lasso`
LDFLAGS=--shared
LIBS=-lrestclient-cpp -lcurl `pkg-config --libs lasso` -lgobject-2.0 -lgumbo -lgq
SONAME=_occi.so
SOURCES=compute.cpp entity.cpp network.cpp occisession.cpp resource.cpp storage.cpp template.cpp link.cpp saml2_ecp.cpp
SWIG=swig
SWIG_INTERFACES=occilib.i
WRAPPER_SOURCES=occilib_wrap.cpp
WRAPPER_INCLUDES=`pkg-config python --cflags`
RESTCLIENT_CPP_URL=https://github.com/fuximo/restclient-cpp.git
RESTCLIENT_CPP_TAG=master
default: python
python:
python setup.py build
lib: deps
$(CPP) $(CPPFLAGS) -c $(SOURCES)
$(AR) rcs libocci.a *.o
restclient-cpp:
git clone --depth=1 $(RESTCLIENT_CPP_URL) -b $(RESTCLIENT_CPP_TAG)
bash gen_restclient-cpp_version.sh $(RESTCLIENT_CPP_TAG)
build-restclient-cpp: restclient-cpp
cd restclient-cpp ; \
$(CPP) $(CPPFLAGS) -c source/*.cc -Iinclude
$(AR) rcs librestclient-cpp.a restclient-cpp/*.o
deps: build-restclient-cpp
clean:
rm -f *.o
rm -f $(WRAPPER_SOURCES)
rm -f $(SONAME)
rm -f occi.py
rm -f occi.pyc
rm -Rf build
mrproper: clean clean_deps
rm -Rf dist libocci.egg-info
clean_deps:
rm -Rf restclient-cpp
rm -f librestclient-cpp.a
libocci-2-login-should-return-a-proper-response-08f1396159642e2d17f2ac599effa84e3883a59a/compute.cpp0000664 0000000 0000000 00000015206 13130523340 0031625 0 ustar 00root root 0000000 0000000 // 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 .
#include
#include
#include
#include "json.hpp"
#include "resource.h"
#include "template.h"
#include "compute.h"
using std::string;
using std::vector;
using nlohmann::json;
using std::shared_ptr;
using std::make_shared;
using namespace OcciClient;
void Compute::parseJsonInstance(json instance) {
Resource::parseJsonInstance(instance);
this->state = getAttributeFromRendering(instance, "occi.compute.state");
this->stateMessage = getAttributeFromRendering(instance, "occi.compute.state.message");
this->memory = getAttributeFromRendering(instance, "occi.compute.memory");
this->cpuShare = getAttributeFromRendering(instance, "occi.compute.share");
this->cores = getAttributeFromRendering(instance, "occi.compute.cores");
this->hostname = getAttributeFromRendering(instance, "occi.compute.hostname");
this->architecture = getAttributeFromRendering(instance, "occi.compute.architecture");
this->credentialProtocol = getAttributeFromRendering(instance, "org.circlecloud.occi.credentials.protocol");
this->credentialPort = getAttributeFromRendering(instance, "org.circlecloud.occi.credentials.port");
this->credentialHost = getAttributeFromRendering(instance, "org.circlecloud.occi.credentials.host");
this->credentialUsername = getAttributeFromRendering(instance, "org.circlecloud.occi.credentials.username");
this->credentialPassword = getAttributeFromRendering(instance, "org.circlecloud.occi.credentials.password");
this->credentialCommand = getAttributeFromRendering(instance, "org.circlecloud.occi.credentials.command");
this->leasetimeSuspend = getAttributeFromRendering(instance, "org.circlecloud.occi.leasetime.suspend");
this->leasetimeRemove = getAttributeFromRendering(instance, "org.circlecloud.occi.leasetime.remove");
this->rendering = instance;
}
Compute::Compute(OcciSession* session, json instance) : Resource(session, "compute", instance) {
parseJsonInstance(instance);
}
void Compute::invokeAction(json actionData) {
auto inst = Resource::invokeAction(actionData);
parseJsonInstance(inst);
}
shared_ptr Compute::getComputeInstance(OcciSession* session, string id) {
auto uri = "compute/" + id + "/";
auto instance = session->get(uri);
return make_shared(Compute(session, instance));
}
shared_ptr Compute::createComputeInstance(OcciSession* session, Template t) {
auto uri = "compute/1/";
json data = json::parse("{\"mixins\": [\"" + t + "\"]}");
auto instance = session->put(uri, data);
return make_shared(Compute(session, instance));
}
vector> Compute::getComputeInstances(OcciSession* session){
auto result = vector>();
auto data = session->get("compute/");
for (auto& computeRendering : data["resources"]) {
auto computeInstance = make_shared(Compute(session, computeRendering));
result.push_back(computeInstance);
}
return result;
}
vector Compute::getComputeInstanceIds(OcciSession* session){
auto computes = getComputeInstances(session);
auto ids = vector();
for (auto& compute : computes) {
ids.push_back(compute->getId());
}
return ids;
}
string Compute::getState(){
return this->state;
}
string Compute::getStateMessage(){
return this->stateMessage;
}
double Compute::getMemory(){
return this->memory;
}
int Compute::getCpuShare(){
return this->cpuShare;
}
int Compute::getCores(){
return this->cores;
}
string Compute::getHostname(){
return this->hostname;
}
string Compute::getArchitecture(){
return this->architecture;
}
string Compute::getCredentialProtocol(){
return this->credentialProtocol;
}
int Compute::getCredentialPort(){
return this->credentialPort;
}
string Compute::getCredentialHost(){
return this->credentialHost;
}
string Compute::getCredentialPassword(){
return this->credentialPassword;
}
string Compute::getCredentialUsername(){
return this->credentialUsername;
}
string Compute::getCredentialCommand(){
return this->credentialCommand;
}
string Compute::getLeasetimeSuspend(){
return this->leasetimeSuspend;
}
string Compute::getLeasetimeRemove(){
return this->leasetimeRemove;
}
void Compute::start() {
json actionData = {
{"action", "http://schemas.ogf.org/occi/infrastructure/compute/action#start"}
};
invokeAction(actionData);
}
void Compute::wakeup() {
start();
}
void Compute::sleep() {
json actionData = {
{"action", "http://schemas.ogf.org/occi/infrastructure/compute/action#suspend"},
{"attributes", {
{"method", "suspend"}
}}
};
invokeAction(actionData);
}
void Compute::reboot() {
json actionData = {
{"action", "http://schemas.ogf.org/occi/infrastructure/compute/action#restart"},
{"attributes", {
{"method", "warm"}
}}
};
invokeAction(actionData);
}
void Compute::reset() {
json actionData = {
{"action", "http://schemas.ogf.org/occi/infrastructure/compute/action#restart"},
{"attributes", {
{"method", "cold"}
}}
};
invokeAction(actionData);
}
void Compute::shutdown() {
json actionData = {
{"action", "http://schemas.ogf.org/occi/infrastructure/compute/action#stop"},
{"attributes", {
{"method", "acpioff"}
}}
};
invokeAction(actionData);
}
void Compute::shutoff() {
json actionData = {
{"action", "http://schemas.ogf.org/occi/infrastructure/compute/action#stop"},
{"attributes", {
{"method", "poweroff"}
}}
};
invokeAction(actionData);
}
void Compute::renew() {
json actionData = {
{"action", "http://circlecloud.org/occi/infrastructure/compute/action#renew"},
};
invokeAction(actionData);
}
libocci-2-login-should-return-a-proper-response-08f1396159642e2d17f2ac599effa84e3883a59a/compute.h 0000664 0000000 0000000 00000005755 13130523340 0031302 0 ustar 00root root 0000000 0000000 // 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 .
#ifndef OCCILIB_COMPUTE_H_
#define OCCILIB_COMPUTE_H_
#include
#include
#include
#include "json.hpp"
#include "resource.h"
#include "template.h"
namespace OcciClient {
class Compute : public Resource {
private:
std::string state;
std::string stateMessage;
double memory;
int cpuShare;
int cores;
std::string hostname;
std::string architecture;
std::string credentialProtocol;
int credentialPort;
std::string credentialHost;
std::string credentialPassword;
std::string credentialUsername;
std::string credentialCommand;
std::string leasetimeSuspend;
std::string leasetimeRemove;
void parseJsonInstance(nlohmann::json instance);
Compute(OcciSession* session, nlohmann::json instance);
void invokeAction(nlohmann::json actionData);
public:
static std::shared_ptr getComputeInstance(OcciSession* session, std::string id);
static std::shared_ptr createComputeInstance(OcciSession* session, Template t);
static std::vector> getComputeInstances(OcciSession* session);
static std::vector getComputeInstanceIds(OcciSession* session);
std::string getState();
std::string getStateMessage();
double getMemory();
int getCpuShare();
int getCores();
std::string getHostname();
std::string getArchitecture();
std::string getCredentialProtocol();
int getCredentialPort();
std::string getCredentialHost();
std::string getCredentialPassword();
std::string getCredentialUsername();
std::string getCredentialCommand();
std::string getLeasetimeSuspend();
std::string getLeasetimeRemove();
void start();
void wakeup();
void sleep();
void reboot();
void reset();
void shutdown();
void shutoff();
void renew();
};
}
#endif // OCCILIB_COMPUTE_H
libocci-2-login-should-return-a-proper-response-08f1396159642e2d17f2ac599effa84e3883a59a/entity.cpp 0000664 0000000 0000000 00000003723 13130523340 0031466 0 ustar 00root root 0000000 0000000 // 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 .
#include
#include "json.hpp"
#include "occisession.h"
#include "entity.hpp"
using std::string;
using nlohmann::json;
using namespace OcciClient;
void Entity::parseJsonInstance(json instance) {
this->id = getID(instance);
if (instance.find("title") != instance.end()) {
this->title = instance["title"].get();
}
this->rendering = instance;
}
Entity::Entity(OcciSession* session, string kind, json instance) {
this->session = session;
this->kind = kind;
parseJsonInstance(instance);
}
string Entity::getID(json& rendering) {
try {
return rendering["id"];
}
catch (std::domain_error) {
return "";
}
}
string Entity::getId(){
return this->id;
}
string Entity::getTitle(){
return this->title;
}
json Entity::invokeAction(OcciSession* session, string kind, string id, json actionData) {
auto uri = kind + "/" + id + "/";
return session->post(uri, actionData);
}
json Entity::invokeAction(json actionData){
return invokeAction(this->session, this->kind, this->id, actionData);
}
json Entity::getRendering(){
return this->rendering;
}
void Entity::destroyInstance() {
auto uri = this->kind + "/" + this->id + "/";
session->del(uri);
}
libocci-2-login-should-return-a-proper-response-08f1396159642e2d17f2ac599effa84e3883a59a/entity.hpp 0000664 0000000 0000000 00000004025 13130523340 0031467 0 ustar 00root root 0000000 0000000 // 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 .
#ifndef OCCILIB_ENTITY_H_
#define OCCILIB_ENTITY_H_
#include
#include "json.hpp"
#include "occisession.h"
namespace OcciClient{
class Entity{
protected:
OcciSession* session;
std::string id;
std::string title;
nlohmann::json rendering;
std::string kind;
void parseJsonInstance(nlohmann::json instance);
std::string getID(nlohmann::json& rendering);
template T getAttributeFromRendering(nlohmann::json& rendering, const std::string which, const T defaultValue = T()) {
try {
return rendering["attributes"][which].get();
}
catch (std::exception e){
return defaultValue;
}
}
Entity(OcciSession* session, std::string kind, nlohmann::json instance);
public:
std::string getId();
std::string getTitle();
static nlohmann::json invokeAction(OcciSession* session, std::string kind, std::string id, nlohmann::json actionData);
nlohmann::json invokeAction(nlohmann::json actionData);
nlohmann::json getRendering();
void destroyInstance();
};
}
#endif // OCCILIB_ENTITY_H_
gen_restclient-cpp_version.sh 0000775 0000000 0000000 00000000343 13130523340 0035253 0 ustar 00root root 0000000 0000000 libocci-2-login-should-return-a-proper-response-08f1396159642e2d17f2ac599effa84e3883a59a cat > restclient-cpp/include/restclient-cpp/version.h <