Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4a284fb8
authored
Nov 19, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
occi: add ipnetwork mixin to our networks
parent
fc00f3a5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
8 deletions
+33
-8
circle/occi/occi.py
+29
-4
circle/occi/templates/occi/ipnetwork.html
+3
-0
circle/occi/views.py
+1
-4
No files found.
circle/occi/occi.py
View file @
4a284fb8
...
...
@@ -540,7 +540,7 @@ class Network(Resource):
def
render_body
(
self
):
kind
=
NETWORK_KIND
mixins
=
[]
mixins
=
[
IPNetwork
()
]
return
render_to_string
(
"occi/network.html"
,
{
'kind'
:
kind
,
...
...
@@ -555,18 +555,43 @@ class Network(Resource):
'occi.network.vlan'
:
"vid"
,
'occi.network.label'
:
"name"
,
}
alloc
=
{
True
:
"dynamic"
,
False
:
"static"
,
}
for
k
,
v
in
translate
.
items
():
self
.
attrs
[
k
]
=
getattr
(
self
.
vlan
,
v
,
None
)
self
.
attrs
[
'occi.network.gateway'
]
=
unicode
(
self
.
vlan
.
network4
.
ip
)
self
.
attrs
[
'occi.network.address'
]
=
unicode
(
self
.
vlan
.
network4
.
cidr
)
self
.
attrs
[
'occi.network.allocation'
]
=
alloc
.
get
(
self
.
vlan
.
managed
)
self
.
attrs
[
'occi.compute.state'
]
=
"active"
def
trigger_action
(
self
,
data
):
pass
def
delete
(
self
):
# TODO
user
=
User
.
objects
.
get
(
username
=
"test"
)
self
.
instance
.
destroy
(
user
=
user
)
pass
class
IPNetwork
(
Mixin
):
def
__init__
(
self
):
self
.
term
=
"ipnetwork"
self
.
title
=
"An IP Network mixin"
self
.
scheme
=
"http://schemas.ogf.org/occi/infrastructure/network#"
self
.
location
=
"/mixin/ipnetwork/"
def
render_location
(
self
):
return
self
.
location
def
render_body
(
self
):
return
render_to_string
(
"occi/ipnetwork.html"
,
{
'term'
:
self
.
term
,
'scheme'
:
self
.
scheme
,
'location'
:
self
.
location
,
'class'
:
"mixin"
,
'title'
:
self
.
title
,
})
"""predefined stuffs
...
...
circle/occi/templates/occi/ipnetwork.html
0 → 100644
View file @
4a284fb8
{% spaceless %}
Category: {{ term }}; scheme="{{ scheme }}"; class="{{ class }}"; title="{{ title }}"; location="{{ location }}";
{% endspaceless %}
circle/occi/views.py
View file @
4a284fb8
...
...
@@ -275,7 +275,4 @@ class VlanInterface(CSRFExemptMixin, DetailView):
pass
# no actions
def
delete
(
self
,
request
,
*
args
,
**
kwargs
):
vm
=
self
.
get_object
()
Compute
(
instance
=
vm
)
.
delete
()
return
HttpResponse
()
pass
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