Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
libocci
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
108ab4af
authored
Jul 10, 2017
by
Fukász Rómeó Ervin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add operating system template details
parent
032b996a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
83 additions
and
21 deletions
+83
-21
compute.cpp
+2
-2
compute.h
+1
-1
occilib.i
+3
-2
template.cpp
+53
-11
template.h
+24
-5
No files found.
compute.cpp
View file @
108ab4af
...
@@ -67,9 +67,9 @@ shared_ptr<Compute> Compute::getComputeInstance(OcciSession* session, string id)
...
@@ -67,9 +67,9 @@ shared_ptr<Compute> Compute::getComputeInstance(OcciSession* session, string id)
return
make_shared
<
Compute
>
(
Compute
(
session
,
instance
));
return
make_shared
<
Compute
>
(
Compute
(
session
,
instance
));
}
}
shared_ptr
<
Compute
>
Compute
::
createComputeInstance
(
OcciSession
*
session
,
Template
t
)
{
shared_ptr
<
Compute
>
Compute
::
createComputeInstance
(
OcciSession
*
session
,
Template
*
t
)
{
auto
uri
=
"compute/1/"
;
auto
uri
=
"compute/1/"
;
json
data
=
json
::
parse
(
"{
\"
mixins
\"
: [
\"
"
+
t
+
"
\"
]}"
);
json
data
=
json
::
parse
(
"{
\"
mixins
\"
: [
\"
"
+
t
->
getTemplateIdentifier
()
+
"
\"
]}"
);
auto
instance
=
session
->
put
(
uri
,
data
);
auto
instance
=
session
->
put
(
uri
,
data
);
return
make_shared
<
Compute
>
(
Compute
(
session
,
instance
));
return
make_shared
<
Compute
>
(
Compute
(
session
,
instance
));
}
}
...
...
compute.h
View file @
108ab4af
...
@@ -58,7 +58,7 @@ namespace OcciClient {
...
@@ -58,7 +58,7 @@ namespace OcciClient {
static
std
::
shared_ptr
<
Compute
>
getComputeInstance
(
OcciSession
*
session
,
std
::
string
id
);
static
std
::
shared_ptr
<
Compute
>
getComputeInstance
(
OcciSession
*
session
,
std
::
string
id
);
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
::
shared_ptr
<
Compute
>>
getComputeInstances
(
OcciSession
*
session
);
...
...
occilib.i
View file @
108ab4af
...
@@ -25,16 +25,17 @@
...
@@ -25,16 +25,17 @@
%shared_ptr(OcciClient::Compute)
%shared_ptr(OcciClient::Compute)
%shared_ptr(OcciClient::Storage)
%shared_ptr(OcciClient::Storage)
%shared_ptr(OcciClient::Network)
%shared_ptr(OcciClient::Network)
%shared_ptr(OcciClient::Template)
%include "entity.hpp"
%include "entity.hpp"
%include "resource.h"
%include "resource.h"
%include "link.h"
%include "link.h"
%include "compute.h"
%include "template.h"
%include "template.h"
%include "compute.h"
%include "storage.h"
%include "storage.h"
%include "network.h"
%include "network.h"
namespace std {
namespace std {
%template(TemplateVector) vector<
Template
>;
%template(TemplateVector) vector<
shared_ptr<OcciClient::Template>
>;
%template(ComputeInstanceVector) vector<shared_ptr<OcciClient::Compute>>;
%template(ComputeInstanceVector) vector<shared_ptr<OcciClient::Compute>>;
}
}
template.cpp
View file @
108ab4af
...
@@ -18,24 +18,66 @@
...
@@ -18,24 +18,66 @@
#include <string>
#include <string>
#include <vector>
#include <vector>
#include <memory>
#include "occisession.h"
#include "occisession.h"
#include "json.hpp"
#include "json.hpp"
#include "template.h"
#include "template.h"
//TODO remove this include
#include <iostream>
using
nlohmann
::
json
;
using
nlohmann
::
json
;
using
std
::
string
;
using
std
::
string
;
using
std
::
vector
;
using
std
::
vector
;
using
namespace
OcciClient
;
using
std
::
shared_ptr
;
using
std
::
make_shared
;
vector
<
Template
>
OcciClient
::
getTemplates
(
OcciSession
*
session
){
json
mixins
=
session
->
queryInterface
()[
"mixins"
];
namespace
OcciClient
{
auto
result
=
vector
<
Template
>
();
for
(
auto
&
mixin
:
mixins
)
{
vector
<
shared_ptr
<
Template
>
>
Template
::
getTemplates
(
OcciSession
*
session
){
if
(
mixin
[
"depends"
]
==
"http://schemas.ogf.org/occi/infrastructure#os_tpl"
)
{
json
mixins
=
session
->
queryInterface
()[
"mixins"
];
result
.
push_back
(
mixin
[
"scheme"
].
get
<
string
>
()
+
mixin
[
"term"
].
get
<
string
>
());
auto
result
=
vector
<
shared_ptr
<
Template
>
>
();
for
(
auto
&
mixin
:
mixins
)
{
if
(
mixin
[
"depends"
]
==
"http://schemas.ogf.org/occi/infrastructure#os_tpl"
)
{
auto
tpl
=
make_shared
<
Template
>
(
mixin
);
result
.
push_back
(
tpl
);
}
}
}
return
result
;
}
Template
::
Template
(
json
rendering
)
{
this
->
scheme
=
rendering
[
"scheme"
].
get
<
string
>
();
this
->
term
=
rendering
[
"term"
].
get
<
string
>
();
this
->
title
=
rendering
[
"title"
].
get
<
string
>
();
this
->
defaultCores
=
rendering
[
"attributes"
][
"occi.compute.cores"
][
"default"
].
get
<
int
>
();
this
->
defaultCpuShare
=
rendering
[
"attributes"
][
"occi.compute.share"
][
"default"
].
get
<
int
>
();
this
->
defaultMemory
=
rendering
[
"attributes"
][
"occi.compute.memory"
][
"default"
].
get
<
double
>
();
this
->
defaultArchitecture
=
rendering
[
"attributes"
][
"occi.compute.architecture"
][
"default"
].
get
<
string
>
();
}
string
Template
::
getTemplateIdentifier
()
{
return
this
->
scheme
+
this
->
term
;
}
std
::
string
Template
::
getDefaultArchitecture
()
{
return
this
->
defaultArchitecture
;
}
double
Template
::
getDefaultMemory
()
{
return
this
->
defaultMemory
;
}
int
Template
::
getDefaultCores
()
{
return
this
->
defaultCores
;
}
}
return
result
;
int
Template
::
getDefaultCpuShare
()
{
return
this
->
defaultCpuShare
;
}
string
Template
::
getTitle
(){
return
this
->
title
;
}
}
}
template.h
View file @
108ab4af
...
@@ -21,15 +21,34 @@
...
@@ -21,15 +21,34 @@
#include <string>
#include <string>
#include <vector>
#include <vector>
#include <memory>
#include "json.hpp"
#include "occisession.h"
#include "occisession.h"
typedef
std
::
string
Template
;
namespace
OcciClient
{
namespace
OcciClient
{
std
::
vector
<
Template
>
getTemplates
(
OcciSession
*
session
);
class
Template
{
private
:
std
::
string
defaultArchitecture
;
double
defaultMemory
;
int
defaultCores
;
int
defaultCpuShare
;
std
::
string
title
;
std
::
string
scheme
;
std
::
string
term
;
public
:
Template
(
nlohmann
::
json
);
static
std
::
vector
<
std
::
shared_ptr
<
Template
>
>
getTemplates
(
OcciSession
*
);
std
::
string
getDefaultArchitecture
();
double
getDefaultMemory
();
int
getDefaultCores
();
int
getDefaultCpuShare
();
std
::
string
getTemplateIdentifier
();
std
::
string
getTitle
();
};
}
}
#endif // OCCILIB_TEMPLATE_H
#endif // OCCILIB_TEMPLATE_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment