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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
4358b986
authored
May 08, 2019
by
Belákovics Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extended instance model
parent
90e62baa
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
86 additions
and
36 deletions
+86
-36
.gitignore
+4
-1
Pipfile
+3
-0
Pipfile.lock
+21
-13
recircle/instance/models.py
+15
-13
recircle/instance/views.py
+10
-1
recircle/recircle/settings.py
+33
-8
No files found.
.gitignore
View file @
4358b986
.vscode/
.vscode/
recircle/db.sqlite3
recircle/db.sqlite3
interface-openstack/
interface-openstack/
recircle/clouds.yaml
recircle/implementation/
recircle/interface/
recircle/interface_openstack/
Pipfile
View file @
4358b986
...
@@ -13,6 +13,9 @@ django = "*"
...
@@ -13,6 +13,9 @@ django = "*"
django-rest-framework = "*"
django-rest-framework = "*"
djangorestframework = "*"
djangorestframework = "*"
djoser = "*"
djoser = "*"
django-cors-headers = "*"
openstack = "*"
openstacksdk = "*"
[requires]
[requires]
python_version = "3.6"
python_version = "3.6"
Pipfile.lock
View file @
4358b986
{
{
"_meta": {
"_meta": {
"hash": {
"hash": {
"sha256": "
3f7933a8e9bf77c56bc9c9664b247c3c7d9aa7541c81c20422854dee46b3fb0a
"
"sha256": "
efd17ef994a943079b5eee780633552565e788c237f155c5a02085c4ea40be66
"
},
},
"pipfile-spec": 6,
"pipfile-spec": 6,
"requires": {
"requires": {
...
@@ -18,11 +18,19 @@
...
@@ -18,11 +18,19 @@
"default": {
"default": {
"django": {
"django": {
"hashes": [
"hashes": [
"sha256:
7c3543e4fb070d14e10926189a7fcf42ba919263b7473dceaefce34d54e8a119
",
"sha256:
6fcc3cbd55b16f9a01f37de8bcbe286e0ea22e87096557f1511051780338eaea
",
"sha256:
a2814bffd1f007805b19194eb0b9a331933b82bd5da1c3ba3d7b7ba16e06dc4b
"
"sha256:
bb407d0bb46395ca1241f829f5bd03f7e482f97f7d1936e26e98dacb201ed4ec
"
],
],
"index": "pypi",
"index": "pypi",
"version": "==2.2"
"version": "==2.2.1"
},
"django-cors-headers": {
"hashes": [
"sha256:c7987faa9aaef7f6a802b0f354a719e80a9158c284f530265ac792f1ee725e52",
"sha256:ceacbd60dd5a65c95e65e74b5559bd4161aa3fe5713c44e1f3417a12bd41e7ba"
],
"index": "pypi",
"version": "==2.5.3"
},
},
"django-rest-framework": {
"django-rest-framework": {
"hashes": [
"hashes": [
...
@@ -40,11 +48,11 @@
...
@@ -40,11 +48,11 @@
},
},
"djangorestframework": {
"djangorestframework": {
"hashes": [
"hashes": [
"sha256:
8a435df9007c8b7d8e69a21ef06650e3c0cbe0d4b09e55dd1bd74c89a75a9fcd
",
"sha256:
1d22971a5fc98becdbbad9710ca2a9148dd339f6cbea4c3ddbed2cb84bab94e1
",
"sha256:
f7a266260d656e1cf4ca54d7a7349609dc8af4fe2590edd0ecd7d7643ea94a17
"
"sha256:
2884763160b997073ff1e937bd820a69d23978902a3ccd0ba53a217e196239f0
"
],
],
"index": "pypi",
"index": "pypi",
"version": "==3.9.
2
"
"version": "==3.9.
3
"
},
},
"djoser": {
"djoser": {
"hashes": [
"hashes": [
...
@@ -115,11 +123,11 @@
...
@@ -115,11 +123,11 @@
},
},
"djangorestframework": {
"djangorestframework": {
"hashes": [
"hashes": [
"sha256:
8a435df9007c8b7d8e69a21ef06650e3c0cbe0d4b09e55dd1bd74c89a75a9fcd
",
"sha256:
1d22971a5fc98becdbbad9710ca2a9148dd339f6cbea4c3ddbed2cb84bab94e1
",
"sha256:
f7a266260d656e1cf4ca54d7a7349609dc8af4fe2590edd0ecd7d7643ea94a17
"
"sha256:
2884763160b997073ff1e937bd820a69d23978902a3ccd0ba53a217e196239f0
"
],
],
"index": "pypi",
"index": "pypi",
"version": "==3.9.
2
"
"version": "==3.9.
3
"
},
},
"httpie": {
"httpie": {
"hashes": [
"hashes": [
...
@@ -236,10 +244,10 @@
...
@@ -236,10 +244,10 @@
},
},
"urllib3": {
"urllib3": {
"hashes": [
"hashes": [
"sha256:
4c291ca23bbb55c76518905869ef34bdd5f0e46af7afe6861e8375643ffee1a0
",
"sha256:
2393a695cd12afedd0dcb26fe5d50d0cf248e5a66f75dbd89a3d4eb333a61af4
",
"sha256:
9a247273df709c4fedb38c711e44292304f73f39ab01beda9f6b9fc375669ac3
"
"sha256:
a637e5fae88995b256e3409dc4d52c2e2e0ba32c42a6365fee8bbd2238de3cfb
"
],
],
"version": "==1.24.
2
"
"version": "==1.24.
3
"
}
}
}
}
}
}
recircle/instance/models.py
View file @
4358b986
...
@@ -4,12 +4,10 @@ from django.conf import settings
...
@@ -4,12 +4,10 @@ from django.conf import settings
ACCESS_METHODS
=
tuple
([(
key
,
val
[
0
])
ACCESS_METHODS
=
tuple
([(
key
,
val
[
0
])
for
key
,
val
in
settings
.
VM_ACCESS_PROTOCOLS
.
items
()])
for
key
,
val
in
settings
.
VM_ACCESS_PROTOCOLS
.
items
()])
# Temporary solution
LEASE_TYPES
=
(
# Later stored in database
(
"project"
,
"Project"
),
LEASE_TYPES
=
tuple
([(
val
[
"name"
],
val
[
"verbose_name"
])
(
"server"
,
"Server"
),
for
val
in
settings
.
LEASE_TYPES
])
(
"infinite"
,
"Infinite lease"
)
)
class
Instance
(
models
.
Model
):
class
Instance
(
models
.
Model
):
...
@@ -18,16 +16,20 @@ class Instance(models.Model):
...
@@ -18,16 +16,20 @@ class Instance(models.Model):
description
=
models
.
TextField
(
blank
=
True
,
description
=
models
.
TextField
(
blank
=
True
,
help_text
=
"The description of the instance"
)
help_text
=
"The description of the instance"
)
access_method
=
models
.
CharField
(
max_length
=
10
,
choices
=
ACCESS_METHODS
,
access_method
=
models
.
CharField
(
max_length
=
10
,
choices
=
ACCESS_METHODS
,
help_text
=
"Primary remote access method."
)
help_text
=
"Primary remote access method"
)
lease
=
models
.
CharField
(
max_length
=
50
,
choices
=
LEASE_TYPES
,
help_text
=
"Expiration method"
)
system
=
models
.
CharField
(
max_length
=
50
,
system
=
models
.
CharField
(
max_length
=
50
,
help_text
=
"Operating system type"
)
help_text
=
"Operating system type"
)
password
=
models
.
CharField
(
max_length
=
50
,
password
=
models
.
CharField
(
max_length
=
50
,
help_text
=
"Original password of the instance."
)
help_text
=
"Original password of the instance"
)
# time_of_suspend = models.DateTimeField()
lease
=
models
.
CharField
(
max_length
=
50
,
choices
=
LEASE_TYPES
,
help_text
=
"Expiration method"
)
time_of_suspend
=
models
.
DateTimeField
(
help_text
=
"After this point in time, the instance will be suspended"
)
time_of_delete
=
models
.
DateTimeField
(
help_text
=
"After this point in time, the instance will be deleted!"
)
deleted
=
models
.
BooleanField
(
help_text
=
"Indicates if the instance is ready for garbage collection"
,
default
=
False
)
# template
# template
# time_of_suspend
# time_of_delete
# disks
# disks
# owner
# owner
recircle/instance/views.py
View file @
4358b986
...
@@ -4,19 +4,28 @@ from django.http import Http404
...
@@ -4,19 +4,28 @@ from django.http import Http404
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
rest_framework
import
status
from
rest_framework
import
status
from
implementation.vm.instance
import
OSVirtualMachineManager
import
openstack
conn
=
openstack
.
connect
(
cloud
=
'openstack'
)
class
InstanceList
(
APIView
):
class
InstanceList
(
APIView
):
def
get
(
self
,
request
,
format
=
None
):
def
get
(
self
,
request
,
format
=
None
):
instances
=
Instance
.
objects
.
all
()
instances
=
Instance
.
objects
.
all
()
# refresh OpenStack Attribs
# refresh OpenStack Attribs
interface
=
OSVirtualMachineManager
(
conn
)
return
Response
([
vm
for
vm
in
interface
.
list_all_vm
()])
# create response
# create response
serializer
=
InstanceSerializer
(
instances
,
many
=
True
)
serializer
=
InstanceSerializer
(
instances
,
many
=
True
)
return
Response
(
serializer
.
data
)
return
Response
(
serializer
.
data
)
def
post
(
self
,
request
,
format
=
None
):
def
post
(
self
,
request
,
format
=
None
):
serializer
=
InstanceSerializer
(
data
=
request
.
data
)
serializer
=
InstanceSerializer
(
data
=
request
.
data
)
# OpenStack
if
serializer
.
is_valid
():
if
serializer
.
is_valid
():
serializer
.
save
()
serializer
.
save
()
return
Response
(
serializer
.
data
,
status
=
status
.
HTTP_201_CREATED
)
return
Response
(
serializer
.
data
,
status
=
status
.
HTTP_201_CREATED
)
...
...
recircle/recircle/settings.py
View file @
4358b986
...
@@ -30,7 +30,6 @@ ALLOWED_HOSTS = [
...
@@ -30,7 +30,6 @@ ALLOWED_HOSTS = [
'localhost'
,
'localhost'
,
]
]
# Application definition
# Application definition
INSTALLED_APPS
=
[
INSTALLED_APPS
=
[
...
@@ -128,16 +127,42 @@ USE_TZ = True
...
@@ -128,16 +127,42 @@ USE_TZ = True
STATIC_URL
=
'/static/'
STATIC_URL
=
'/static/'
###############################################################################
#################
###############################################################################
# RECIRCLE CONFIG
# RECIRCLE CONFIG
###############################################################################
#################
###############################################################################
# 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
=
[
{
"name"
:
"shortlab"
,
"verbose_name"
:
"Short laboratory"
,
"description"
:
"The student only needs the VM during the lecture."
,
"suspend_interval_seconds"
:
10800
,
# 3 hours
"delete_interval_seconds"
:
14400
,
# 4 hours
},
{
"name"
:
"lab"
,
"verbose_name"
:
"Laboratory"
,
"description"
:
"The student may need the VM after the lecture."
,
"suspend_interval_seconds"
:
18000
,
# 5 hours
"delete_interval_seconds"
:
604800
,
# 1 week
},
{
"name"
:
"project"
,
"verbose_name"
:
"Project"
,
"description"
:
"A VM is used for a project for a semester."
,
"suspend_interval_seconds"
:
2629743
,
# 1 month
"delete_interval_seconds"
:
15778463
,
# 6 months
},
]
# CORS config for development version only
CORS_ORIGIN_WHITELIST
=
(
CORS_ORIGIN_WHITELIST
=
(
'localhost:3000'
,
'localhost:3000'
,
)
)
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