Commit 4a284fb8 by Kálmán Viktor

occi: add ipnetwork mixin to our networks

parent fc00f3a5
...@@ -540,7 +540,7 @@ class Network(Resource): ...@@ -540,7 +540,7 @@ class Network(Resource):
def render_body(self): def render_body(self):
kind = NETWORK_KIND kind = NETWORK_KIND
mixins = [] mixins = [IPNetwork()]
return render_to_string("occi/network.html", { return render_to_string("occi/network.html", {
'kind': kind, 'kind': kind,
...@@ -555,18 +555,43 @@ class Network(Resource): ...@@ -555,18 +555,43 @@ class Network(Resource):
'occi.network.vlan': "vid", 'occi.network.vlan': "vid",
'occi.network.label': "name", 'occi.network.label': "name",
} }
alloc = {
True: "dynamic",
False: "static",
}
for k, v in translate.items(): for k, v in translate.items():
self.attrs[k] = getattr(self.vlan, v, None) 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" self.attrs['occi.compute.state'] = "active"
def trigger_action(self, data): def trigger_action(self, data):
pass pass
def delete(self): def delete(self):
# TODO pass
user = User.objects.get(username="test")
self.instance.destroy(user=user)
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 """predefined stuffs
......
{% spaceless %}
Category: {{ term }}; scheme="{{ scheme }}"; class="{{ class }}"; title="{{ title }}"; location="{{ location }}";
{% endspaceless %}
...@@ -275,7 +275,4 @@ class VlanInterface(CSRFExemptMixin, DetailView): ...@@ -275,7 +275,4 @@ class VlanInterface(CSRFExemptMixin, DetailView):
pass # no actions pass # no actions
def delete(self, request, *args, **kwargs): def delete(self, request, *args, **kwargs):
vm = self.get_object() pass
Compute(instance=vm).delete()
return HttpResponse()
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