Commit a0fda40b by Fukász Rómeó Ervin

occi: Initial occi commit, added occi-core classes

parent dad93220
...@@ -29,6 +29,7 @@ from dashboard.views import circle_login, HelpView, ResizeHelpView ...@@ -29,6 +29,7 @@ from dashboard.views import circle_login, HelpView, ResizeHelpView
from dashboard.forms import CirclePasswordResetForm, CircleSetPasswordForm from dashboard.forms import CirclePasswordResetForm, CircleSetPasswordForm
from firewall.views import add_blacklist_item from firewall.views import add_blacklist_item
admin.autodiscover() admin.autodiscover()
urlpatterns = patterns( urlpatterns = patterns(
...@@ -38,6 +39,7 @@ urlpatterns = patterns( ...@@ -38,6 +39,7 @@ urlpatterns = patterns(
url(r'^network/', include('network.urls')), url(r'^network/', include('network.urls')),
url(r'^blacklist-add/', add_blacklist_item), url(r'^blacklist-add/', add_blacklist_item),
url(r'^dashboard/', include('dashboard.urls')), url(r'^dashboard/', include('dashboard.urls')),
url(r'^occi/', include('occi.urls')),
url(r'^request/', include('request.urls')), url(r'^request/', include('request.urls')),
# django/contrib/auth/urls.py (care when new version) # django/contrib/auth/urls.py (care when new version)
......
from django.contrib import admin
# Register your models here.
from django.db import models
# Create your models here.
def set_optional_attributes(self, optional_attributes, kwargs):
for k, v in kwargs.iteritems():
if k in optional_attributes:
setattr(self, k, v)
class Attribute:
""" OCCI 1.2 - CORE - Classification - Attribute """
TYPES = ("Object", "List", "Hash")
optional_attributes = ("pattern", "default", "description")
pattern = None
default = None
description = None
def __init__(self, name, type, mutable, required, **kwargs):
self.name = name
self.type = type
self.mutable = mutable
self.required = required
set_optional_attributes(self, self.optional_attributes, kwargs)
class Category:
""" OCCI 1.2 - CORE - Classification - Category """
optional_attributes = ("title", "attributes")
title = None
attributes = ()
def __init__(self, scheme, term, **kwargs):
self.scheme = scheme
self.term = term
set_optional_attributes(self, self.optional_attributes, kwargs)
class Kind(Category):
""" OCCI 1.2 - CORE - Classification - Kind """
optional_attributes = ("parent", "actions", "enitities")
parent = None
actions = ()
entities = ()
def __init__(self, **kwargs):
set_optional_attributes(self, self.optional_attributes, kwargs)
class Action(Category):
""" OCCI 1.2 - CORE - Classification - Kind """
pass
class Mixin(Category):
""" OCCI 1.2 - CORE - Classification - Mixin """
optional_attributes = ("depends", "entities", "applies", "actions")
depends = ()
entities = ()
applies = ()
actions = ()
def __init__(self, **kwargs):
set_optional_attributes(self, self.optional_attributes, kwargs)
class Entity:
""" OCCI 1.2 - CORE - Base Types - Entity """
optional_attributes = ("mixins", "title")
mixins = ()
title = None
def __init__(self, kind, id, **kwargs):
self.kind = kind
self.id = id
set_optional_attributes(self, self.optional_attributes, kwargs)
class Resource(Entity):
""" OCCI 1.2 - CORE - Base Types - Resource """
optional_attributes = ("links", "summary")
links = ()
summary = None
def __init__(self, **kwargs):
set_optional_attributes(self, self.optional_attributes, kwargs)
class Link(Entity):
""" OCCI 1.2 - CORE - Base Types - Link """
optional_attributes = ("target_kind",)
target_kind = None
def __init__(self, source, target, **kwargs):
self.source = source
self.target = target
set_optional_attributes(self, self.optional_attributes, kwargs)
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url
from views import testView
urlpatterns = [
url(r'^test$', testView.as_view()),
]
from django.shortcuts import render
from django.views.generic import View
from django.http import HttpResponse
# Create your views here.
# MY VIEWS ARE SOOOO GOOD
class testView(View):
""" This view is a big test """
def get(self, request, *args, **kwargs):
return HttpResponse('<!DOCTYPE html><html lang="hu"><head>'
'<title>TEST</title></head>'
'<body style="background: black; color: white'
'; text-align: center;"><h1>TEST</h1><p>'
'Csilli-villi service</p></body></html>')
class startVM(View):
""" A test service, which starts a VM """
def get(self, request, *args, **kwargs):
pass
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