Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
RECIRCLE
/
portal
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
11
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
a35f2402
authored
5 years ago
by
Bodor Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reformat code and fix flake8 errors
parent
16394b7c
Hide whitespace changes
Inline
Side-by-side
Showing
30 changed files
with
166 additions
and
202 deletions
+166
-202
recircle/image/admin.py
+1
-1
recircle/image/apps.py
+1
-1
recircle/image/models.py
+10
-4
recircle/image/serializers.py
+2
-1
recircle/image/tests.py
+1
-1
recircle/image/urls.py
+3
-6
recircle/image/views.py
+8
-6
recircle/instance/apps.py
+1
-1
recircle/instance/models.py
+29
-21
recircle/instance/serializers.py
+0
-1
recircle/instance/tests.py
+1
-1
recircle/instance/urls.py
+2
-2
recircle/instance/views.py
+6
-4
recircle/manage.py
+2
-2
recircle/recircle/settings.py
+47
-58
recircle/recircle/urls.py
+7
-7
recircle/recircle/wsgi.py
+1
-1
recircle/storage/admin.py
+1
-1
recircle/storage/apps.py
+1
-1
recircle/storage/models.py
+15
-5
recircle/storage/serializers.py
+2
-1
recircle/storage/tests.py
+1
-1
recircle/storage/views.py
+1
-1
recircle/template/admin.py
+1
-1
recircle/template/apps.py
+1
-1
recircle/template/models.py
+17
-7
recircle/template/serializers.py
+2
-1
recircle/template/tests.py
+1
-1
recircle/template/views.py
+1
-1
recircle/views.py
+0
-62
No files found.
recircle/image/admin.py
View file @
a35f2402
from
django.contrib
import
admin
#
from django.contrib import admin
# Register your models here.
# Register your models here.
This diff is collapsed.
Click to expand it.
recircle/image/apps.py
View file @
a35f2402
...
@@ -2,4 +2,4 @@ from django.apps import AppConfig
...
@@ -2,4 +2,4 @@ from django.apps import AppConfig
class
ImageConfig
(
AppConfig
):
class
ImageConfig
(
AppConfig
):
name
=
'image'
name
=
"image"
This diff is collapsed.
Click to expand it.
recircle/image/models.py
View file @
a35f2402
from
django.db
import
models
from
django.db
import
models
class
Disk
(
models
.
Model
):
class
Disk
(
models
.
Model
):
"""A virtual disk.
"""A virtual disk.
"""
"""
name
=
models
.
CharField
(
blank
=
True
,
max_length
=
100
,
verbose_name
=
"name"
,
help_text
=
"Name of the disk"
)
name
=
models
.
CharField
(
remote_ID
=
models
.
CharField
(
max_length
=
40
,
unique
=
True
,
verbose_name
=
"remote_ID"
,
help_text
=
"ID, which helps access the disk"
)
blank
=
True
,
max_length
=
100
,
verbose_name
=
"name"
,
help_text
=
"Name of the disk"
)
\ No newline at end of file
remote_ID
=
models
.
CharField
(
max_length
=
40
,
unique
=
True
,
verbose_name
=
"remote_ID"
,
help_text
=
"ID, which helps access the disk"
,
)
This diff is collapsed.
Click to expand it.
recircle/image/serializers.py
View file @
a35f2402
...
@@ -2,7 +2,8 @@ from rest_framework import serializers
...
@@ -2,7 +2,8 @@ from rest_framework import serializers
from
.models
import
Disk
from
.models
import
Disk
class
DiskSerializer
(
serializers
.
ModelSerializer
):
class
DiskSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
class
Meta
:
model
=
Disk
model
=
Disk
fields
=
(
'name'
,
'remote_ID'
,
)
fields
=
(
"name"
,
"remote_ID"
)
This diff is collapsed.
Click to expand it.
recircle/image/tests.py
View file @
a35f2402
from
django.test
import
TestCase
#
from django.test import TestCase
# Create your tests here.
# Create your tests here.
This diff is collapsed.
Click to expand it.
recircle/image/urls.py
View file @
a35f2402
from
django.urls
import
include
,
path
from
django.urls
import
path
from
rest_framework.urlpatterns
import
format_suffix_patterns
from
rest_framework.urlpatterns
import
format_suffix_patterns
from
image
import
views
from
image
import
views
urlpatterns
=
[
urlpatterns
=
[
path
(
""
,
views
.
DiskList
.
as_view
())]
path
(
''
,
views
.
DiskList
.
as_view
()),
]
urlpatterns
=
format_suffix_patterns
(
urlpatterns
)
urlpatterns
=
format_suffix_patterns
(
urlpatterns
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
recircle/image/views.py
View file @
a35f2402
from
image.models
import
Disk
from
image.models
import
Disk
from
image.serializers
import
DiskSerializer
from
image.serializers
import
DiskSerializer
from
django.shortcuts
import
render
#
from django.shortcuts import render
from
rest_framework.views
import
APIView
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
rest_framework.response
import
Response
from
interface_openstack.implementation.image.OpenstackImageManager
import
OpenstackImageManager
from
interface_openstack.implementation.image.OpenstackImageManager
import
(
OpenstackImageManager
,
)
import
openstack
import
openstack
conn
=
openstack
.
connect
(
cloud
=
'openstack'
)
conn
=
openstack
.
connect
(
cloud
=
"openstack"
)
class
DiskList
(
APIView
):
class
DiskList
(
APIView
):
def
get
(
self
,
request
,
format
=
None
):
def
get
(
self
,
request
,
format
=
None
):
#OpenStack
#
OpenStack
interface
=
OpenstackImageManager
(
conn
)
interface
=
OpenstackImageManager
(
conn
)
return
Response
([
disk
.
__dict__
for
disk
in
interface
.
list
()])
return
Response
([
disk
.
__dict__
for
disk
in
interface
.
list
()])
#Create response
#
Create response
disks
=
Disk
.
object
.
all
()
disks
=
Disk
.
object
.
all
()
serializer
=
DiskSerializer
(
disks
,
many
=
True
)
serializer
=
DiskSerializer
(
disks
,
many
=
True
)
return
Response
(
serializer
.
data
)
return
Response
(
serializer
.
data
)
This diff is collapsed.
Click to expand it.
recircle/instance/apps.py
View file @
a35f2402
...
@@ -2,4 +2,4 @@ from django.apps import AppConfig
...
@@ -2,4 +2,4 @@ from django.apps import AppConfig
class
InstanceConfig
(
AppConfig
):
class
InstanceConfig
(
AppConfig
):
name
=
'instance'
name
=
"instance"
This diff is collapsed.
Click to expand it.
recircle/instance/models.py
View file @
a35f2402
...
@@ -2,36 +2,44 @@ from django.db import models
...
@@ -2,36 +2,44 @@ from django.db import models
from
django.conf
import
settings
from
django.conf
import
settings
ACCESS_METHODS
=
tuple
([(
key
,
val
[
0
])
ACCESS_METHODS
=
tuple
(
for
key
,
val
in
settings
.
VM_ACCESS_PROTOCOLS
.
items
()])
[(
key
,
val
[
0
])
for
key
,
val
in
settings
.
VM_ACCESS_PROTOCOLS
.
items
()]
)
# Later stored in database
# Later stored in database
LEASE_TYPES
=
tuple
([(
val
[
"name"
],
val
[
"verbose_name"
])
LEASE_TYPES
=
tuple
(
for
val
in
settings
.
LEASE_TYPES
])
[(
val
[
"name"
],
val
[
"verbose_name"
])
for
val
in
settings
.
LEASE_TYPES
]
)
class
Instance
(
models
.
Model
):
class
Instance
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
100
,
name
=
models
.
CharField
(
max_length
=
100
,
help_text
=
"Human readable name of instance"
)
help_text
=
"Human readable name of instance"
)
remote_id
=
models
.
CharField
(
remote_id
=
models
.
CharField
(
max_length
=
100
,
max_length
=
100
,
help_text
=
"ID of the instance on the backend"
help_text
=
"ID of the instance on the backend"
)
)
description
=
models
.
TextField
(
blank
=
True
,
description
=
models
.
TextField
(
help_text
=
"The description of the instance"
)
blank
=
True
,
help_text
=
"The description of the instance"
access_method
=
models
.
CharField
(
max_length
=
10
,
choices
=
ACCESS_METHODS
,
)
help_text
=
"Primary remote access method"
)
access_method
=
models
.
CharField
(
system
=
models
.
CharField
(
max_length
=
50
,
max_length
=
10
,
choices
=
ACCESS_METHODS
,
help_text
=
"Primary remote access method"
help_text
=
"Operating system type"
)
)
password
=
models
.
CharField
(
max_length
=
50
,
system
=
models
.
CharField
(
max_length
=
50
,
help_text
=
"Operating system type"
)
help_text
=
"Original password of the instance"
)
password
=
models
.
CharField
(
lease
=
models
.
CharField
(
max_length
=
50
,
choices
=
LEASE_TYPES
,
max_length
=
50
,
help_text
=
"Original password of the instance"
help_text
=
"Expiration method"
)
)
lease
=
models
.
CharField
(
max_length
=
50
,
choices
=
LEASE_TYPES
,
help_text
=
"Expiration method"
)
time_of_suspend
=
models
.
DateTimeField
(
time_of_suspend
=
models
.
DateTimeField
(
help_text
=
"After this point in time, the instance will be suspended"
)
help_text
=
"After this point in time, the instance will be suspended"
)
time_of_delete
=
models
.
DateTimeField
(
time_of_delete
=
models
.
DateTimeField
(
help_text
=
"After this point in time, the instance will be deleted!"
)
help_text
=
"After this point in time, the instance will be deleted!"
)
deleted
=
models
.
BooleanField
(
deleted
=
models
.
BooleanField
(
help_text
=
"Indicates if the instance is ready for garbage collection"
,
help_text
=
"Indicates if the instance is ready for garbage collection"
,
default
=
False
)
default
=
False
,
)
# template
# template
# disks
# disks
# owner
# owner
This diff is collapsed.
Click to expand it.
recircle/instance/serializers.py
View file @
a35f2402
...
@@ -4,7 +4,6 @@ from .models import Instance
...
@@ -4,7 +4,6 @@ from .models import Instance
class
InstanceSerializer
(
serializers
.
ModelSerializer
):
class
InstanceSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
class
Meta
:
model
=
Instance
model
=
Instance
fields
=
"__all__"
fields
=
"__all__"
This diff is collapsed.
Click to expand it.
recircle/instance/tests.py
View file @
a35f2402
from
django.test
import
TestCase
#
from django.test import TestCase
# Create your tests here.
# Create your tests here.
This diff is collapsed.
Click to expand it.
recircle/instance/urls.py
View file @
a35f2402
...
@@ -3,8 +3,8 @@ from rest_framework.urlpatterns import format_suffix_patterns
...
@@ -3,8 +3,8 @@ from rest_framework.urlpatterns import format_suffix_patterns
from
instance
import
views
from
instance
import
views
urlpatterns
=
[
urlpatterns
=
[
path
(
'instances/'
,
views
.
InstanceList
.
as_view
()),
path
(
"instances/"
,
views
.
InstanceList
.
as_view
()),
path
(
'instances/<int:pk>/'
,
views
.
InstanceDetail
.
as_view
()),
path
(
"instances/<int:pk>/"
,
views
.
InstanceDetail
.
as_view
()),
# path('instances/<int:pk>/action/', views.InstanceAction.as_view())
# path('instances/<int:pk>/action/', views.InstanceAction.as_view())
]
]
...
...
This diff is collapsed.
Click to expand it.
recircle/instance/views.py
View file @
a35f2402
...
@@ -10,7 +10,7 @@ import openstack
...
@@ -10,7 +10,7 @@ import openstack
import
datetime
import
datetime
conn
=
openstack
.
connect
(
cloud
=
'openstack'
)
conn
=
openstack
.
connect
(
cloud
=
"openstack"
)
class
InstanceList
(
APIView
):
class
InstanceList
(
APIView
):
...
@@ -22,9 +22,11 @@ class InstanceList(APIView):
...
@@ -22,9 +22,11 @@ class InstanceList(APIView):
data
=
request
.
data
data
=
request
.
data
interface
=
OSVirtualMachineManager
(
conn
)
interface
=
OSVirtualMachineManager
(
conn
)
imageId
=
"da51253f-867c-472d-8ce0-81e7b7126d60"
imageId
=
"da51253f-867c-472d-8ce0-81e7b7126d60"
flavorId
=
'1'
flavorId
=
"1"
networks
=
[{
"uuid"
:
"c03d0d4b-413e-4cc6-9ebe-c0b5ca0dac3a"
}]
networks
=
[{
"uuid"
:
"c03d0d4b-413e-4cc6-9ebe-c0b5ca0dac3a"
}]
newBackendInstance
=
interface
.
create_vm_from_template
(
"Integration test vm 2"
,
imageId
,
flavorId
,
networks
)
newBackendInstance
=
interface
.
create_vm_from_template
(
"Integration test vm 2"
,
imageId
,
flavorId
,
networks
)
newInstance
=
Instance
(
newInstance
=
Instance
(
name
=
data
[
"name"
],
name
=
data
[
"name"
],
remote_id
=
newBackendInstance
.
id
,
remote_id
=
newBackendInstance
.
id
,
...
@@ -35,7 +37,7 @@ class InstanceList(APIView):
...
@@ -35,7 +37,7 @@ class InstanceList(APIView):
lease
=
data
[
"lease"
],
lease
=
data
[
"lease"
],
time_of_suspend
=
datetime
.
datetime
.
now
(),
time_of_suspend
=
datetime
.
datetime
.
now
(),
time_of_delete
=
datetime
.
datetime
.
now
(),
time_of_delete
=
datetime
.
datetime
.
now
(),
deleted
=
False
deleted
=
False
,
)
)
newInstance
.
save
()
newInstance
.
save
()
return
Response
(
newInstance
.
pk
)
return
Response
(
newInstance
.
pk
)
...
...
This diff is collapsed.
Click to expand it.
recircle/manage.py
View file @
a35f2402
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
import
os
import
os
import
sys
import
sys
if
__name__
==
'__main__'
:
if
__name__
==
"__main__"
:
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'recircle.settings'
)
os
.
environ
.
setdefault
(
"DJANGO_SETTINGS_MODULE"
,
"recircle.settings"
)
try
:
try
:
from
django.core.management
import
execute_from_command_line
from
django.core.management
import
execute_from_command_line
except
ImportError
as
exc
:
except
ImportError
as
exc
:
...
...
This diff is collapsed.
Click to expand it.
recircle/recircle/settings.py
View file @
a35f2402
...
@@ -20,72 +20,69 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
...
@@ -20,72 +20,69 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY
=
'xhe8=w50lz82gjb6+z
%
(rwk2c+1kd!
%
(iv_s^!tp)*5cnb=-^t'
SECRET_KEY
=
"xhe8=w50lz82gjb6+z
%
(rwk2c+1kd!
%
(iv_s^!tp)*5cnb=-^t"
# SECURITY WARNING: don't run with debug turned on in production!
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
True
DEBUG
=
True
ALLOWED_HOSTS
=
[
ALLOWED_HOSTS
=
[
"vm.niif.cloud.bme.hu"
,
"localhost"
]
'vm.niif.cloud.bme.hu'
,
'localhost'
,
]
# Application definition
# Application definition
INSTALLED_APPS
=
[
INSTALLED_APPS
=
[
'instance.apps.InstanceConfig'
,
"instance.apps.InstanceConfig"
,
'image.apps.ImageConfig'
,
"image.apps.ImageConfig"
,
'django.contrib.admin'
,
"django.contrib.admin"
,
'django.contrib.auth'
,
"django.contrib.auth"
,
'django.contrib.contenttypes'
,
"django.contrib.contenttypes"
,
'django.contrib.sessions'
,
"django.contrib.sessions"
,
'django.contrib.messages'
,
"django.contrib.messages"
,
'django.contrib.staticfiles'
,
"django.contrib.staticfiles"
,
'rest_framework'
,
"rest_framework"
,
'djoser'
,
"djoser"
,
'rest_framework_swagger'
,
"rest_framework_swagger"
,
'corsheaders'
,
"corsheaders"
,
]
]
MIDDLEWARE
=
[
MIDDLEWARE
=
[
'django.middleware.security.SecurityMiddleware'
,
"django.middleware.security.SecurityMiddleware"
,
'django.contrib.sessions.middleware.SessionMiddleware'
,
"django.contrib.sessions.middleware.SessionMiddleware"
,
'corsheaders.middleware.CorsMiddleware'
,
"corsheaders.middleware.CorsMiddleware"
,
'django.middleware.common.CommonMiddleware'
,
"django.middleware.common.CommonMiddleware"
,
'django.middleware.csrf.CsrfViewMiddleware'
,
"django.middleware.csrf.CsrfViewMiddleware"
,
'django.contrib.auth.middleware.AuthenticationMiddleware'
,
"django.contrib.auth.middleware.AuthenticationMiddleware"
,
'django.contrib.messages.middleware.MessageMiddleware'
,
"django.contrib.messages.middleware.MessageMiddleware"
,
'django.middleware.clickjacking.XFrameOptionsMiddleware'
,
"django.middleware.clickjacking.XFrameOptionsMiddleware"
,
]
]
ROOT_URLCONF
=
'recircle.urls'
ROOT_URLCONF
=
"recircle.urls"
TEMPLATES
=
[
TEMPLATES
=
[
{
{
'BACKEND'
:
'django.template.backends.django.DjangoTemplates'
,
"BACKEND"
:
"django.template.backends.django.DjangoTemplates"
,
'DIRS'
:
[],
"DIRS"
:
[],
'APP_DIRS'
:
True
,
"APP_DIRS"
:
True
,
'OPTIONS'
:
{
"OPTIONS"
:
{
'context_processors'
:
[
"context_processors"
:
[
'django.template.context_processors.debug'
,
"django.template.context_processors.debug"
,
'django.template.context_processors.request'
,
"django.template.context_processors.request"
,
'django.contrib.auth.context_processors.auth'
,
"django.contrib.auth.context_processors.auth"
,
'django.contrib.messages.context_processors.messages'
,
"django.contrib.messages.context_processors.messages"
,
]
,
]
},
},
}
,
}
]
]
WSGI_APPLICATION
=
'recircle.wsgi.application'
WSGI_APPLICATION
=
"recircle.wsgi.application"
# Database
# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases
DATABASES
=
{
DATABASES
=
{
'default'
:
{
"default"
:
{
'ENGINE'
:
'django.db.backends.sqlite3'
,
"ENGINE"
:
"django.db.backends.sqlite3"
,
'NAME'
:
os
.
path
.
join
(
BASE_DIR
,
'db.sqlite3'
),
"NAME"
:
os
.
path
.
join
(
BASE_DIR
,
"db.sqlite3"
),
}
}
}
}
...
@@ -95,26 +92,20 @@ DATABASES = {
...
@@ -95,26 +92,20 @@ DATABASES = {
AUTH_PASSWORD_VALIDATORS
=
[
AUTH_PASSWORD_VALIDATORS
=
[
{
{
'NAME'
:
'django.contrib.auth.password_validation.UserAttributeSimilarityValidator'
,
"NAME"
:
"django.contrib.auth.password_validation.UserAttributeSimilarityValidator"
},
{
'NAME'
:
'django.contrib.auth.password_validation.MinimumLengthValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.CommonPasswordValidator'
,
},
{
'NAME'
:
'django.contrib.auth.password_validation.NumericPasswordValidator'
,
},
},
{
"NAME"
:
"django.contrib.auth.password_validation.MinimumLengthValidator"
},
{
"NAME"
:
"django.contrib.auth.password_validation.CommonPasswordValidator"
},
{
"NAME"
:
"django.contrib.auth.password_validation.NumericPasswordValidator"
},
]
]
# Internationalization
# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/
# https://docs.djangoproject.com/en/2.1/topics/i18n/
LANGUAGE_CODE
=
'en-us'
LANGUAGE_CODE
=
"en-us"
TIME_ZONE
=
'UTC'
TIME_ZONE
=
"UTC"
USE_I18N
=
True
USE_I18N
=
True
...
@@ -126,7 +117,7 @@ USE_TZ = True
...
@@ -126,7 +117,7 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL
=
'/static/'
STATIC_URL
=
"/static/"
###############################################################################
###############################################################################
# RECIRCLE CONFIG
# RECIRCLE CONFIG
...
@@ -135,7 +126,7 @@ STATIC_URL = '/static/'
...
@@ -135,7 +126,7 @@ STATIC_URL = '/static/'
# VM ACCESS PROTOCOLS
# VM ACCESS PROTOCOLS
VM_ACCESS_PROTOCOLS
=
{
VM_ACCESS_PROTOCOLS
=
{
"rdp"
:
[
"Remote Desktop Protocol"
,
3389
,
"tcp"
],
"rdp"
:
[
"Remote Desktop Protocol"
,
3389
,
"tcp"
],
"ssh"
:
[
"Secure Shell"
,
22
,
"tcp"
]
"ssh"
:
[
"Secure Shell"
,
22
,
"tcp"
]
,
}
}
# LEASE TYPES
# LEASE TYPES
...
@@ -164,6 +155,4 @@ LEASE_TYPES = [
...
@@ -164,6 +155,4 @@ LEASE_TYPES = [
]
]
# CORS config for development version only
# CORS config for development version only
CORS_ORIGIN_WHITELIST
=
(
CORS_ORIGIN_WHITELIST
=
(
"http://localhost:3000"
,)
'http://localhost:3000'
,
)
This diff is collapsed.
Click to expand it.
recircle/recircle/urls.py
View file @
a35f2402
...
@@ -18,13 +18,13 @@ from django.urls import path, re_path, include
...
@@ -18,13 +18,13 @@ from django.urls import path, re_path, include
from
rest_framework_swagger.views
import
get_swagger_view
from
rest_framework_swagger.views
import
get_swagger_view
schema_view
=
get_swagger_view
(
title
=
'RECIRCLE API'
)
schema_view
=
get_swagger_view
(
title
=
"RECIRCLE API"
)
urlpatterns
=
[
urlpatterns
=
[
path
(
'images/'
,
include
(
'image.urls'
)),
path
(
"images/"
,
include
(
"image.urls"
)),
path
(
'api/v1/'
,
include
(
'instance.urls'
)),
path
(
"api/v1/"
,
include
(
"instance.urls"
)),
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
"admin/"
,
admin
.
site
.
urls
),
re_path
(
r
'^auth/'
,
include
(
'djoser.urls'
)),
re_path
(
r
"^auth/"
,
include
(
"djoser.urls"
)),
re_path
(
r
'^auth/'
,
include
(
'djoser.urls.authtoken'
)),
re_path
(
r
"^auth/"
,
include
(
"djoser.urls.authtoken"
)),
path
(
r
'swagger'
,
schema_view
)
path
(
r
"swagger"
,
schema_view
),
]
]
This diff is collapsed.
Click to expand it.
recircle/recircle/wsgi.py
View file @
a35f2402
...
@@ -11,6 +11,6 @@ import os
...
@@ -11,6 +11,6 @@ import os
from
django.core.wsgi
import
get_wsgi_application
from
django.core.wsgi
import
get_wsgi_application
os
.
environ
.
setdefault
(
'DJANGO_SETTINGS_MODULE'
,
'recircle.settings'
)
os
.
environ
.
setdefault
(
"DJANGO_SETTINGS_MODULE"
,
"recircle.settings"
)
application
=
get_wsgi_application
()
application
=
get_wsgi_application
()
This diff is collapsed.
Click to expand it.
recircle/storage/admin.py
View file @
a35f2402
from
django.contrib
import
admin
#
from django.contrib import admin
# Register your models here.
# Register your models here.
This diff is collapsed.
Click to expand it.
recircle/storage/apps.py
View file @
a35f2402
...
@@ -2,4 +2,4 @@ from django.apps import AppConfig
...
@@ -2,4 +2,4 @@ from django.apps import AppConfig
class
StorageConfig
(
AppConfig
):
class
StorageConfig
(
AppConfig
):
name
=
'storage'
name
=
"storage"
This diff is collapsed.
Click to expand it.
recircle/storage/models.py
View file @
a35f2402
from
django.db
import
models
from
django.db
import
models
# Create your models here.
# Create your models here.
class
DataStore
()
:
class
DataStore
:
"""Collection of virtual disks.
"""Collection of virtual disks.
"""
"""
name
=
models
.
CharField
(
max_length
=
100
,
unique
=
True
,
verbose_name
=
"name"
,
help_text
=
"Name of the data store."
)
name
=
models
.
CharField
(
remote_ID
=
models
.
CharField
(
max_length
=
40
,
unique
=
True
,
verbose_name
=
"remote_ID"
,
help_text
=
"ID, which helps access the data store."
)
max_length
=
100
,
#vm
unique
=
True
,
\ No newline at end of file
verbose_name
=
"name"
,
help_text
=
"Name of the data store."
,
)
remote_ID
=
models
.
CharField
(
max_length
=
40
,
unique
=
True
,
verbose_name
=
"remote_ID"
,
help_text
=
"ID, which helps access the data store."
,
)
# vm
This diff is collapsed.
Click to expand it.
recircle/storage/serializers.py
View file @
a35f2402
...
@@ -2,7 +2,8 @@ from rest_framework import serializers
...
@@ -2,7 +2,8 @@ from rest_framework import serializers
from
.models
import
DataStore
from
.models
import
DataStore
class
DataStoreSerializer
(
serializers
.
ModelSerializer
):
class
DataStoreSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
class
Meta
:
model
=
DataStore
model
=
DataStore
fields
=
(
'name'
,
'remote_ID'
,
)
fields
=
(
"name"
,
"remote_ID"
)
This diff is collapsed.
Click to expand it.
recircle/storage/tests.py
View file @
a35f2402
from
django.test
import
TestCase
#
from django.test import TestCase
# Create your tests here.
# Create your tests here.
This diff is collapsed.
Click to expand it.
recircle/storage/views.py
View file @
a35f2402
from
django.shortcuts
import
render
#
from django.shortcuts import render
# Create your views here.
# Create your views here.
This diff is collapsed.
Click to expand it.
recircle/template/admin.py
View file @
a35f2402
from
django.contrib
import
admin
#
from django.contrib import admin
# Register your models here.
# Register your models here.
This diff is collapsed.
Click to expand it.
recircle/template/apps.py
View file @
a35f2402
...
@@ -2,4 +2,4 @@ from django.apps import AppConfig
...
@@ -2,4 +2,4 @@ from django.apps import AppConfig
class
TemplateConfig
(
AppConfig
):
class
TemplateConfig
(
AppConfig
):
name
=
'template'
name
=
"template"
This diff is collapsed.
Click to expand it.
recircle/template/models.py
View file @
a35f2402
from
django.db
import
models
from
django.db
import
models
class
InstanceTemplate
():
class
InstanceTemplate
:
"""Virtual machine template.
"""Virtual machine template.
"""
"""
name
=
models
.
CharField
(
max_length
=
100
,
verbose_name
=
"name"
,
name
=
models
.
CharField
(
help_text
=
"Human readable name of template."
)
max_length
=
100
,
description
=
models
.
TextField
(
verbose_name
=
"description"
,
blank
=
True
,
help_text
=
"Description of the template."
)
verbose_name
=
"name"
,
#owner = models.ForeignKey(User)
help_text
=
"Human readable name of template."
,
remote_ID
=
models
.
CharField
(
max_length
=
40
,
unique
=
True
,
verbose_name
=
"remote_ID"
,
help_text
=
"ID, which helps access the template."
)
)
\ No newline at end of file
description
=
models
.
TextField
(
verbose_name
=
"description"
,
blank
=
True
,
help_text
=
"Description of the template."
)
# owner = models.ForeignKey(User)
remote_ID
=
models
.
CharField
(
max_length
=
40
,
unique
=
True
,
verbose_name
=
"remote_ID"
,
help_text
=
"ID, which helps access the template."
,
)
This diff is collapsed.
Click to expand it.
recircle/template/serializers.py
View file @
a35f2402
...
@@ -2,7 +2,8 @@ from rest_framework import serializers
...
@@ -2,7 +2,8 @@ from rest_framework import serializers
from
.models
import
InstanceTemplate
from
.models
import
InstanceTemplate
class
InstanceTemplateSerializer
(
serializers
.
ModelSerializer
):
class
InstanceTemplateSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
class
Meta
:
model
=
InstanceTemplate
model
=
InstanceTemplate
fields
=
(
'name'
,
'description'
,
'owner'
,
'remote_ID'
,
)
fields
=
(
"name"
,
"description"
,
"owner"
,
"remote_ID"
)
This diff is collapsed.
Click to expand it.
recircle/template/tests.py
View file @
a35f2402
from
django.test
import
TestCase
#
from django.test import TestCase
# Create your tests here.
# Create your tests here.
This diff is collapsed.
Click to expand it.
recircle/template/views.py
View file @
a35f2402
from
django.shortcuts
import
render
#
from django.shortcuts import render
# Create your views here.
# Create your views here.
This diff is collapsed.
Click to expand it.
recircle/views.py
deleted
100644 → 0
View file @
16394b7c
from
instance.models
import
Instance
from
instance.serializers
import
InstanceSerializer
from
django.http
import
Http404
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
rest_framework
import
status
from
implementation.vm.instance
import
OSVirtualMachineManager
import
openstack
conn
=
openstack
.
connect
(
cloud
=
'openstack'
)
class
InstanceList
(
APIView
):
def
get
(
self
,
request
,
format
=
None
):
instances
=
Instance
.
objects
.
all
()
# refresh OpenStack Attribs
interface
=
OSVirtualMachineManager
(
conn
)
return
Response
([
vm
for
vm
in
interface
.
list_all_vm
()])
# create response
serializer
=
InstanceSerializer
(
instances
,
many
=
True
)
return
Response
(
serializer
.
data
)
def
post
(
self
,
request
,
format
=
None
):
data
=
request
.
data
newId
=
0
interface
=
OSVirtualMachineManager
(
conn
)
imageId
=
"da51253f-867c-472d-8ce0-81e7b7126d60"
flavorId
=
{
"name"
:
1
}
networks
=
[{
"uuid"
:
"c03d0d4b-413e-4cc6-9ebe-c0b5ca0dac3a"
}]
interface
.
create_vm_from_template
(
"Integration test vm 1"
,
imageId
,
flavorId
,
networks
)
return
Response
(
newId
)
class
InstanceDetail
(
APIView
):
"""
Retrieve, update or delete a snippet instance.
"""
def
get_object
(
self
,
pk
):
try
:
return
Instance
.
objects
.
get
(
pk
=
pk
)
except
Instance
.
DoesNotExist
:
raise
Http404
def
get
(
self
,
request
,
pk
,
format
=
None
):
instance
=
self
.
get_object
(
pk
)
serializer
=
InstanceSerializer
(
instance
)
return
Response
(
serializer
.
data
)
def
put
(
self
,
request
,
pk
,
format
=
None
):
instance
=
self
.
get_object
(
pk
)
serializer
=
InstanceSerializer
(
instance
,
data
=
request
.
data
)
if
serializer
.
is_valid
():
serializer
.
save
()
return
Response
(
serializer
.
data
)
return
Response
(
serializer
.
errors
,
status
=
status
.
HTTP_400_BAD_REQUEST
)
def
delete
(
self
,
request
,
pk
,
format
=
None
):
instance
=
self
.
get_object
(
pk
)
instance
.
delete
()
return
Response
(
status
=
status
.
HTTP_204_NO_CONTENT
)
This diff is collapsed.
Click to expand it.
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