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
cf51acfe
authored
Jul 03, 2019
by
Chif Gergő
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
instance: Create Flavor and Lease model. Add fields to instance
parent
415ba749
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
14 deletions
+49
-14
recircle/image/views.py
+1
-1
recircle/instance/models.py
+47
-12
recircle/instance/views.py
+1
-1
No files found.
recircle/image/views.py
View file @
cf51acfe
...
...
@@ -3,7 +3,7 @@ from image.serializers import DiskSerializer
# from django.shortcuts import render
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
i
nterface_openstack.i
mplementation.image.OpenstackImageManager
import
(
from
implementation.image.OpenstackImageManager
import
(
OpenstackImageManager
,
)
import
openstack
...
...
recircle/instance/models.py
View file @
cf51acfe
from
django.db
import
models
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
storage
import
Disk
ACCESS_METHODS
=
tuple
(
[(
key
,
val
[
0
])
for
key
,
val
in
settings
.
VM_ACCESS_PROTOCOLS
.
items
()]
)
# Later stored in database
LEASE_TYPES
=
tuple
(
[(
val
[
"name"
],
val
[
"verbose_name"
])
for
val
in
settings
.
LEASE_TYPES
]
)
class
Lease
(
models
.
Model
):
""" Users can use the virtual machine until the lease dates.
After suspend interval the vm suspends and after delete it will be
destroyed
"""
name
=
models
.
CharField
(
blank
=
True
,
max_length
=
100
)
description
=
models
.
CharField
(
blank
=
True
,
max_length
=
100
)
suspend_interval_in_sec
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
delete_interval_in_sec
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
class
Flavor
(
models
.
Model
):
""" Flavors are reasource packages, contains all information about
resources accociated with the virtual machine
"""
name
=
models
.
CharField
(
blank
=
True
,
max_length
=
100
)
description
=
models
.
CharField
(
blank
=
True
,
max_length
=
200
)
ram
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
vcpu
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
initial_disk
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
priority
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
class
Instance
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
100
,
help_text
=
"Human readable name of instance"
)
"""Virtual machine instance.
"""
name
=
models
.
CharField
(
max_length
=
100
,
help_text
=
"Human readable name of instance"
)
remote_id
=
models
.
CharField
(
max_length
=
100
,
help_text
=
"ID of the instance on the backend"
)
...
...
@@ -21,15 +46,13 @@ class Instance(models.Model):
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"
max_length
=
10
,
choices
=
ACCESS_METHODS
,
help_text
=
"Primary remote access method"
)
system
=
models
.
CharField
(
max_length
=
50
,
help_text
=
"Operating system type"
)
password
=
models
.
CharField
(
max_length
=
50
,
help_text
=
"Original password of the instance"
)
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"
)
...
...
@@ -40,6 +63,18 @@ class Instance(models.Model):
help_text
=
"Indicates if the instance is ready for garbage collection"
,
default
=
False
,
)
# template
# disks
# owner
# image = models.ForeignKey(TemplateImage, related_name="vm", null=True,
# help_text="The base image of the vm")
#
# snapshot = models.ForeignKey(Snapshot, related_name="vm", null=True,
# help_text="The base snapshot of the vm")
disks
=
models
.
ManyToManyField
(
Disk
,
related_name
=
"instance"
,
help_text
=
"Disks attached to instance"
,
verbose_name
=
"disks"
)
owner
=
models
.
ForeignKey
(
User
)
flavor
=
models
.
ForeignKey
(
Flavor
,
help_text
=
"Reasources given to the vm"
,
verbose_name
=
"flavor"
)
lease
=
models
.
ForeignKey
(
Lease
)
recircle/instance/views.py
View file @
cf51acfe
...
...
@@ -4,7 +4,7 @@ from django.http import Http404
from
rest_framework.views
import
APIView
from
rest_framework.response
import
Response
from
rest_framework
import
status
from
i
nterface_openstack.i
mplementation.vm.instance
import
OSVirtualMachineManager
from
implementation.vm.instance
import
OSVirtualMachineManager
import
openstack
import
datetime
...
...
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