Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
78c30ada
authored
Nov 12, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
occi: attach disks when creating vm
parent
4baa3506
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
circle/occi/occi.py
+36
-0
No files found.
circle/occi/occi.py
View file @
78c30ada
...
@@ -43,6 +43,14 @@ occi_os_tpl_regex = re.compile(
...
@@ -43,6 +43,14 @@ occi_os_tpl_regex = re.compile(
'class="mixin"; ?location=".*"; ?title=".*"$'
'class="mixin"; ?location=".*"; ?title=".*"$'
)
)
occi_link_regex
=
re
.
compile
(
'^Link: <(?P<link>[a-zA-Z0-9/]+)>; ?'
'.*$'
)
occi_inline_attribute_regex
=
'.*
%(attribute)
s="?(?P<value>[
\
w/
\
.:#
\
-]+)"?.*'
occi_attribute_link_regex
=
'^/
%
s/(?P<id>
\
d+)/?'
occi_attribute_link_regex
=
'^/
%
s/(?P<id>
\
d+)/?'
...
@@ -146,6 +154,7 @@ class Compute(Resource):
...
@@ -146,6 +154,7 @@ class Compute(Resource):
user
=
User
.
objects
.
get
(
username
=
"test"
)
user
=
User
.
objects
.
get
(
username
=
"test"
)
template
=
None
template
=
None
attributes
=
{}
attributes
=
{}
links
=
[]
for
d
in
data
:
for
d
in
data
:
tmpl
=
occi_os_tpl_regex
.
match
(
d
)
tmpl
=
occi_os_tpl_regex
.
match
(
d
)
...
@@ -157,6 +166,10 @@ class Compute(Resource):
...
@@ -157,6 +166,10 @@ class Compute(Resource):
if
attr
:
if
attr
:
attributes
[
attr
.
group
(
"attribute"
)]
=
attr
.
group
(
"value"
)
attributes
[
attr
.
group
(
"attribute"
)]
=
attr
.
group
(
"value"
)
link
=
occi_link_regex
.
match
(
d
)
if
link
:
links
.
append
(
d
)
params
=
{}
params
=
{}
params
[
'owner'
]
=
user
params
[
'owner'
]
=
user
title
=
attributes
.
get
(
"occi.core.title"
)
title
=
attributes
.
get
(
"occi.core.title"
)
...
@@ -198,8 +211,31 @@ class Compute(Resource):
...
@@ -198,8 +211,31 @@ class Compute(Resource):
req_traits
=
[],
tags
=
[])
req_traits
=
[],
tags
=
[])
cls
.
location
=
"
%
svm/
%
d"
%
(
OCCI_ADDR
,
inst
.
pk
)
cls
.
location
=
"
%
svm/
%
d"
%
(
OCCI_ADDR
,
inst
.
pk
)
cls
.
instance
=
inst
cls
.
create_links
(
user
,
links
)
return
cls
return
cls
@classmethod
def
create_links
(
cls
,
user
,
links
):
storagelinks
=
[]
for
l
in
links
:
rel
=
re
.
match
(
occi_inline_attribute_regex
%
{
'attribute'
:
"rel"
},
l
)
if
rel
and
rel
.
group
(
"value"
)
.
endswith
(
"#storage"
):
target
=
re
.
match
(
occi_inline_attribute_regex
%
{
'attribute'
:
"occi.core.target"
},
l
)
.
group
(
"value"
)
disk_pk
=
re
.
match
(
occi_attribute_link_regex
%
"storage"
,
target
)
.
group
(
"id"
)
disk
=
Disk
.
objects
.
get
(
pk
=
disk_pk
)
storagelinks
.
append
(
disk
)
for
sl
in
storagelinks
:
cls
.
instance
.
attach_disk
(
user
=
user
,
disk
=
disk
)
def
render_location
(
self
):
def
render_location
(
self
):
return
"
%
s"
%
self
.
location
return
"
%
s"
%
self
.
location
...
...
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