Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE3
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
5
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
324b4ce8
authored
Sep 13, 2022
by
Karsa Zoltán István
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add interface ipv4, mac, ipv6
parent
8179e8f6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
26 deletions
+60
-26
circle/dashboard/serializers.py
+28
-3
circle/dashboard/urls.py
+2
-1
circle/dashboard/views/storage.py
+0
-9
circle/dashboard/views/vm.py
+16
-8
circle/locale/hu/LC_MESSAGES/django.po
+0
-0
circle/vm/models/network.py
+8
-0
circle/vm/operations.py
+6
-5
No files found.
circle/dashboard/serializers.py
View file @
324b4ce8
...
@@ -7,10 +7,15 @@ from firewall.models import Vlan
...
@@ -7,10 +7,15 @@ from firewall.models import Vlan
from
storage.models
import
Disk
from
storage.models
import
Disk
class
InstanceActivitySerializer
(
serializers
.
ModelSerializer
):
class
InstanceActivitySerializer
(
serializers
.
ModelSerializer
):
get_percentage
=
serializers
.
IntegerField
()
result_data
=
serializers
.
JSONField
()
class
Meta
:
class
Meta
:
model
=
InstanceActivity
model
=
InstanceActivity
fields
=
(
'id'
,
'instance'
,
'resultant_state'
,
'interruptible'
,
'activity_code'
,
'readable_name_data'
,
'parent'
,
fields
=
(
'id'
,
'instance'
,
'resultant_state'
,
'interruptible'
,
'activity_code'
,
'parent'
,
'task_uuid'
,
'user'
,
'started'
,
'finished'
,
'succeeded'
,
'result_data'
,
'created'
,
'modified'
)
'task_uuid'
,
'user'
,
'started'
,
'finished'
,
'succeeded'
,
'result_data'
,
'created'
,
'modified'
,
'get_percentage'
)
class
GroupSerializer
(
serializers
.
ModelSerializer
):
class
GroupSerializer
(
serializers
.
ModelSerializer
):
class
Meta
:
class
Meta
:
...
@@ -73,9 +78,22 @@ class InstanceSerializer(serializers.ModelSerializer):
...
@@ -73,9 +78,22 @@ class InstanceSerializer(serializers.ModelSerializer):
class
InterfaceSerializer
(
serializers
.
ModelSerializer
):
class
InterfaceSerializer
(
serializers
.
ModelSerializer
):
mac
=
serializers
.
SerializerMethodField
(
'get_mac'
)
ipv4
=
serializers
.
SerializerMethodField
(
'get_ipv4'
)
ipv6
=
serializers
.
SerializerMethodField
(
'get_ipv6'
)
def
get_mac
(
self
,
i
):
return
str
(
i
.
mac
)
def
get_ipv4
(
self
,
i
):
return
str
(
i
.
ipv4
)
def
get_ipv6
(
self
,
i
):
return
str
(
i
.
ipv6
)
class
Meta
:
class
Meta
:
model
=
Interface
model
=
Interface
fields
=
[
'id'
,
'vlan'
,
'host'
,
'instance'
,
'model'
]
fields
=
[
'id'
,
'vlan'
,
'host'
,
'instance'
,
'model'
,
'host'
,
'mac'
,
'ipv4'
,
'ipv6'
]
class
VlanSerializer
(
serializers
.
ModelSerializer
):
class
VlanSerializer
(
serializers
.
ModelSerializer
):
...
@@ -97,6 +115,13 @@ class DownloadDiskSerializer(serializers.Serializer):
...
@@ -97,6 +115,13 @@ class DownloadDiskSerializer(serializers.Serializer):
url
=
serializers
.
CharField
(
max_length
=
500
)
url
=
serializers
.
CharField
(
max_length
=
500
)
name
=
serializers
.
CharField
(
max_length
=
100
)
name
=
serializers
.
CharField
(
max_length
=
100
)
class
DestroyDiskSerializer
(
serializers
.
Serializer
):
disk
=
serializers
.
IntegerField
()
instance
=
serializers
.
IntegerField
(
required
=
False
)
class
Meta
:
extra_kwargs
=
{
'instance'
:
{
'required'
:
False
,
'allow_null'
:
True
}}
class
VMDeploySerializer
(
serializers
.
Serializer
):
class
VMDeploySerializer
(
serializers
.
Serializer
):
node
=
serializers
.
IntegerField
(
required
=
False
)
node
=
serializers
.
IntegerField
(
required
=
False
)
...
...
circle/dashboard/urls.py
View file @
324b4ce8
...
@@ -58,7 +58,7 @@ from .views import (
...
@@ -58,7 +58,7 @@ from .views import (
InterfaceREST
,
InstanceFromTemplateREST
,
InstanceFTforUsersREST
,
InterfaceREST
,
InstanceFromTemplateREST
,
InstanceFTforUsersREST
,
DownloadDiskREST
,
GetInstanceREST
,
GetInterfaceREST
,
ShutdownInstanceREST
,
DownloadDiskREST
,
GetInstanceREST
,
GetInterfaceREST
,
ShutdownInstanceREST
,
GetLeaseREST
,
GetDiskRest
,
DeployInstanceREST
,
CreateDiskREST
,
GetLeaseREST
,
GetDiskRest
,
DeployInstanceREST
,
CreateDiskREST
,
VlanREST
,
ResizeDiskREST
,
GetVlanREST
,
VlanREST
,
ResizeDiskREST
,
GetVlanREST
,
DestroyDiskREST
,
StorageDetail
,
DiskDetail
,
UserREST
,
GroupREST
,
StorageDetail
,
DiskDetail
,
UserREST
,
GroupREST
,
InstanceActivityREST
,
GetInstanceActivityREST
,
InstanceActivityREST
,
GetInstanceActivityREST
,
MessageList
,
MessageDetail
,
MessageCreate
,
MessageDelete
,
MessageList
,
MessageDetail
,
MessageCreate
,
MessageDelete
,
...
@@ -94,6 +94,7 @@ urlpatterns = [
...
@@ -94,6 +94,7 @@ urlpatterns = [
path
(
'acpi/vm/<int:pk>/deploy/'
,
DeployInstanceREST
.
as_view
()),
path
(
'acpi/vm/<int:pk>/deploy/'
,
DeployInstanceREST
.
as_view
()),
path
(
'acpi/vm/<int:pk>/shutdown/'
,
ShutdownInstanceREST
.
as_view
()),
path
(
'acpi/vm/<int:pk>/shutdown/'
,
ShutdownInstanceREST
.
as_view
()),
path
(
'acpi/vm/<int:pk>/resizedisk/'
,
ResizeDiskREST
.
as_view
()),
path
(
'acpi/vm/<int:pk>/resizedisk/'
,
ResizeDiskREST
.
as_view
()),
path
(
'acpi/vm/<int:pk>/destroydisk/'
,
DestroyDiskREST
.
as_view
()),
url
(
r'^$'
,
IndexView
.
as_view
(),
name
=
"dashboard.index"
),
url
(
r'^$'
,
IndexView
.
as_view
(),
name
=
"dashboard.index"
),
url
(
r"^profile/list/$"
,
UserList
.
as_view
(),
url
(
r"^profile/list/$"
,
UserList
.
as_view
(),
name
=
"dashboard.views.user-list"
),
name
=
"dashboard.views.user-list"
),
...
...
circle/dashboard/views/storage.py
View file @
324b4ce8
...
@@ -29,7 +29,6 @@ from sizefield.utils import filesizeformat
...
@@ -29,7 +29,6 @@ from sizefield.utils import filesizeformat
from
rest_framework.authentication
import
TokenAuthentication
,
BasicAuthentication
from
rest_framework.authentication
import
TokenAuthentication
,
BasicAuthentication
from
rest_framework.permissions
import
IsAdminUser
from
rest_framework.permissions
import
IsAdminUser
from
rest_framework.views
import
APIView
from
rest_framework.views
import
APIView
from
rest_framework.parsers
import
JSONParser
from
common.models
import
WorkerNotFound
from
common.models
import
WorkerNotFound
from
storage.models
import
DataStore
,
Disk
from
storage.models
import
DataStore
,
Disk
...
@@ -156,14 +155,6 @@ class DiskRest(APIView):
...
@@ -156,14 +155,6 @@ class DiskRest(APIView):
serializer
=
DiskSerializer
(
templates
,
many
=
True
)
serializer
=
DiskSerializer
(
templates
,
many
=
True
)
return
JsonResponse
(
serializer
.
data
,
safe
=
False
)
return
JsonResponse
(
serializer
.
data
,
safe
=
False
)
def
post
(
self
,
request
,
format
=
None
):
data
=
JSONParser
()
.
parse
(
request
)
serializer
=
DiskSerializer
(
data
=
data
)
if
serializer
.
is_valid
():
serializer
.
save
()
return
JsonResponse
(
serializer
.
data
,
status
=
201
)
return
JsonResponse
(
serializer
.
errors
,
status
=
400
)
class
GetDiskRest
(
APIView
):
class
GetDiskRest
(
APIView
):
authentication_classes
=
[
TokenAuthentication
,
BasicAuthentication
]
authentication_classes
=
[
TokenAuthentication
,
BasicAuthentication
]
...
...
circle/dashboard/views/vm.py
View file @
324b4ce8
...
@@ -44,7 +44,9 @@ from django.views.generic import (
...
@@ -44,7 +44,9 @@ from django.views.generic import (
)
)
from
braces.views
import
SuperuserRequiredMixin
,
LoginRequiredMixin
from
braces.views
import
SuperuserRequiredMixin
,
LoginRequiredMixin
from
vm.operations
import
DeployOperation
,
DestroyOperation
,
DownloadDiskOperation
,
ShutdownOperation
,
RenewOperation
,
ResizeDiskOperation
from
vm.operations
import
(
DeployOperation
,
DestroyOperation
,
DownloadDiskOperation
,
ShutdownOperation
,
RenewOperation
,
ResizeDiskOperation
,
RemoveDiskOperation
)
from
common.models
import
(
from
common.models
import
(
create_readable
,
HumanReadableException
,
fetch_human_exception
,
create_readable
,
HumanReadableException
,
fetch_human_exception
,
...
@@ -98,7 +100,7 @@ from rest_framework.permissions import IsAdminUser
...
@@ -98,7 +100,7 @@ from rest_framework.permissions import IsAdminUser
from
dashboard.serializers
import
(
from
dashboard.serializers
import
(
DiskSerializer
,
InstanceSerializer
,
InterfaceSerializer
,
CreateDiskSerializer
,
DownloadDiskSerializer
,
DiskSerializer
,
InstanceSerializer
,
InterfaceSerializer
,
CreateDiskSerializer
,
DownloadDiskSerializer
,
VMDeploySerializer
,
VlanSerializer
,
ResizeDiskSerializer
,
InstanceActivitySerializer
VMDeploySerializer
,
VlanSerializer
,
ResizeDiskSerializer
,
InstanceActivitySerializer
,
DestroyDiskSerializer
,
)
)
class
VlanREST
(
APIView
):
class
VlanREST
(
APIView
):
...
@@ -223,7 +225,7 @@ class GetInstanceREST(APIView):
...
@@ -223,7 +225,7 @@ class GetInstanceREST(APIView):
instance
=
Instance
.
objects
.
get
(
pk
=
pk
)
instance
=
Instance
.
objects
.
get
(
pk
=
pk
)
DestroyOperation
(
instance
)
.
call
(
user
=
instance
.
owner
)
DestroyOperation
(
instance
)
.
call
(
user
=
instance
.
owner
)
serializer
=
InstanceSerializer
(
instance
,
many
=
False
)
serializer
=
InstanceSerializer
(
instance
,
many
=
False
)
return
JsonResponse
(
serializer
.
data
,
status
=
401
)
return
JsonResponse
(
serializer
.
data
,
status
=
204
)
class
DeployInstanceREST
(
APIView
):
class
DeployInstanceREST
(
APIView
):
...
@@ -329,14 +331,20 @@ class ResizeDiskREST(APIView):
...
@@ -329,14 +331,20 @@ class ResizeDiskREST(APIView):
return
JsonResponse
(
ret
.
data
,
status
=
201
)
return
JsonResponse
(
ret
.
data
,
status
=
201
)
return
JsonResponse
(
serializer
.
errors
,
status
=
400
)
return
JsonResponse
(
serializer
.
errors
,
status
=
400
)
class
StateOperation
REST
(
APIView
):
class
DestroyDisk
REST
(
APIView
):
authentication_classes
=
[
TokenAuthentication
,
BasicAuthentication
]
authentication_classes
=
[
TokenAuthentication
,
BasicAuthentication
]
permission_classes
=
[
IsAdminUser
]
permission_classes
=
[
IsAdminUser
]
def
post
(
self
,
request
,
pk
,
format
=
None
):
def
delete
(
self
,
request
,
pk
,
format
=
None
):
pass
data
=
JSONParser
()
.
parse
(
request
)
return
JsonResponse
(
status
=
400
)
serializer
=
DestroyDiskSerializer
(
data
=
data
)
if
serializer
.
is_valid
():
instance
=
Instance
.
objects
.
get
(
pk
=
pk
)
disk
=
Disk
.
objects
.
get
(
pk
=
int
(
data
[
'disk'
]))
RemoveDiskOperation
(
instance
)
.
call
(
disk
=
disk
,
user
=
instance
.
owner
)
return
JsonResponse
({},
status
=
204
)
return
JsonResponse
(
serializer
.
errors
,
status
=
400
)
class
VmDetailVncTokenView
(
CheckedDetailView
):
class
VmDetailVncTokenView
(
CheckedDetailView
):
...
...
circle/locale/hu/LC_MESSAGES/django.po
View file @
324b4ce8
This diff is collapsed.
Click to expand it.
circle/vm/models/network.py
View file @
324b4ce8
...
@@ -86,6 +86,14 @@ class Interface(Model):
...
@@ -86,6 +86,14 @@ class Interface(Model):
return
self
.
host
.
mac
return
self
.
host
.
mac
except
:
except
:
return
Interface
.
generate_mac
(
self
.
instance
,
self
.
vlan
)
return
Interface
.
generate_mac
(
self
.
instance
,
self
.
vlan
)
@property
def
ipv4
(
self
):
return
self
.
host
.
ipv4
@property
def
ipv6
(
self
):
return
self
.
host
.
ipv6
@classmethod
@classmethod
def
generate_mac
(
cls
,
instance
,
vlan
):
def
generate_mac
(
cls
,
instance
,
vlan
):
...
...
circle/vm/operations.py
View file @
324b4ce8
...
@@ -341,16 +341,17 @@ class DownloadDiskOperation(InstanceOperation):
...
@@ -341,16 +341,17 @@ class DownloadDiskOperation(InstanceOperation):
disk
.
save
()
disk
.
save
()
self
.
instance
.
disks
.
add
(
disk
)
self
.
instance
.
disks
.
add
(
disk
)
activity
.
readable_name
=
create_readable
(
activity
.
readable_name
=
create_readable
(
ugettext_noop
(
"download
%(name)
s (id:
%(disk_id)
s)"
),
name
=
disk
.
name
,
disk_id
=
str
(
disk
.
id
))
ugettext_noop
(
"download
%(name)
s (id:
%(disk_id)
d)"
),
name
=
disk
.
name
,
disk_id
=
disk
.
id
)
activity
.
result
=
create_readable
(
ugettext_noop
(
activity
.
result
=
create_readable
(
ugettext_noop
(
"Downloading
%(url)
s is finished. The file md5sum "
"Downloading
%(url)
s is finished. The file md5sum "
"is: '
%(checksum)
s' (id:
%(disk_id)
s)."
),
"is: '
%(checksum)
s' (id:
%(disk_id)
d)."
),
url
=
url
,
checksum
=
disk
.
checksum
,
disk_id
=
str
(
disk
.
id
))
url
=
url
,
checksum
=
disk
.
checksum
,
disk_id
=
disk
.
id
,
disk_size
=
disk
.
size
)
activity
.
result_data
[
'params'
][
'disk_id'
]
=
disk
.
id
# TODO iso (cd) hot-plug is not supported by kvm/guests
# TODO iso (cd) hot-plug is not supported by kvm/guests
if
self
.
instance
.
is_running
and
disk
.
type
not
in
[
"iso"
]:
if
self
.
instance
.
is_running
and
disk
.
type
not
in
[
"iso"
]:
self
.
instance
.
_attach_disk
(
parent_activity
=
activity
,
disk
=
disk
)
self
.
instance
.
_attach_disk
(
parent_activity
=
activity
,
disk
=
disk
)
return
create_readable
(
ugettext_noop
(
"Downloading
%(url)
s is finished. The file md5sum "
"is: '
%(checksum)
s' (id:
%(disk_id)
s)."
),
url
=
url
,
checksum
=
disk
.
checksum
,
disk_id
=
str
(
disk
.
id
))
@register_operation
@register_operation
...
...
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