Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
cbcf6f97
authored
Jul 15, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented hot-attach functions
parent
e5780f5a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
11 deletions
+30
-11
circle/vm/operations.py
+30
-11
No files found.
circle/vm/operations.py
View file @
cbcf6f97
...
@@ -33,7 +33,7 @@ from .models import (
...
@@ -33,7 +33,7 @@ from .models import (
Instance
,
InstanceActivity
,
InstanceTemplate
,
Interface
,
Node
,
Instance
,
InstanceActivity
,
InstanceTemplate
,
Interface
,
Node
,
NodeActivity
,
NodeActivity
,
)
)
from
string
import
ascii_lowercase
logger
=
getLogger
(
__name__
)
logger
=
getLogger
(
__name__
)
...
@@ -98,6 +98,7 @@ class AddInterfaceOperation(InstanceOperation):
...
@@ -98,6 +98,7 @@ class AddInterfaceOperation(InstanceOperation):
managed
=
managed
,
owner
=
user
,
vlan
=
vlan
)
managed
=
managed
,
owner
=
user
,
vlan
=
vlan
)
if
self
.
instance
.
is_running
:
if
self
.
instance
.
is_running
:
self
.
instance
.
attach_network
(
net
)
net
.
deploy
()
net
.
deploy
()
return
net
return
net
...
@@ -107,6 +108,7 @@ register_operation(AddInterfaceOperation)
...
@@ -107,6 +108,7 @@ register_operation(AddInterfaceOperation)
class
CreateDiskOperation
(
InstanceOperation
):
class
CreateDiskOperation
(
InstanceOperation
):
activity_code_suffix
=
'create_disk'
activity_code_suffix
=
'create_disk'
id
=
'create_disk'
id
=
'create_disk'
name
=
_
(
"create disk"
)
name
=
_
(
"create disk"
)
...
@@ -115,20 +117,28 @@ class CreateDiskOperation(InstanceOperation):
...
@@ -115,20 +117,28 @@ class CreateDiskOperation(InstanceOperation):
def
check_precond
(
self
):
def
check_precond
(
self
):
super
(
CreateDiskOperation
,
self
)
.
check_precond
()
super
(
CreateDiskOperation
,
self
)
.
check_precond
()
# TODO remove check when hot-attach is implemented
if
self
.
instance
.
status
not
in
[
'STOPPED'
,
'PENDING'
,
'RUNNING'
]:
if
self
.
instance
.
status
not
in
[
'STOPPED'
,
'PENDING'
]:
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
def
_operation
(
self
,
user
,
size
,
name
=
None
):
def
_operation
(
self
,
user
,
size
,
activity
,
name
=
None
):
# TODO implement with hot-attach when it'll be available
from
storage.models
import
Disk
from
storage.models
import
Disk
if
not
name
:
if
not
name
:
name
=
"new disk"
name
=
"new disk"
disk
=
Disk
.
create
(
size
=
size
,
name
=
name
,
type
=
"qcow2-norm"
)
disk
=
Disk
.
create
(
size
=
size
,
name
=
name
,
type
=
"qcow2-norm"
)
disk
.
full_clean
()
disk
.
full_clean
()
devnums
=
list
(
ascii_lowercase
)
for
d
in
self
.
instance
.
disks
.
all
():
devnums
.
remove
(
d
.
dev_num
)
disk
.
dev_num
=
devnums
.
pop
(
0
)
self
.
instance
.
disks
.
add
(
disk
)
self
.
instance
.
disks
.
add
(
disk
)
if
self
.
instance
.
is_running
:
with
activity
.
sub_activity
(
'deploying_disk'
):
disk
.
deploy
()
with
activity
.
sub_activity
(
'attach_disk'
):
self
.
instance
.
attach_disk
(
disk
)
register_operation
(
CreateDiskOperation
)
register_operation
(
CreateDiskOperation
)
...
@@ -143,19 +153,26 @@ class DownloadDiskOperation(InstanceOperation):
...
@@ -143,19 +153,26 @@ class DownloadDiskOperation(InstanceOperation):
def
check_precond
(
self
):
def
check_precond
(
self
):
super
(
DownloadDiskOperation
,
self
)
.
check_precond
()
super
(
DownloadDiskOperation
,
self
)
.
check_precond
()
# TODO remove check when hot-attach is implemented
if
self
.
instance
.
status
not
in
[
'STOPPED'
,
'PENDING'
,
'RUNNING'
]:
if
self
.
instance
.
status
not
in
[
'STOPPED'
,
'PENDING'
]:
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
def
_operation
(
self
,
user
,
url
,
task
,
activity
,
name
=
None
):
def
_operation
(
self
,
user
,
url
,
task
,
activity
,
name
=
None
):
activity
.
result
=
url
activity
.
result
=
url
# TODO implement with hot-attach when it'll be available
from
storage.models
import
Disk
from
storage.models
import
Disk
disk
=
Disk
.
download
(
url
=
url
,
name
=
name
,
task
=
task
)
disk
=
Disk
.
download
(
url
=
url
,
name
=
name
,
task
=
task
)
devnums
=
list
(
ascii_lowercase
)
for
d
in
self
.
instance
.
disks
.
all
():
devnums
.
remove
(
d
.
dev_num
)
disk
.
dev_num
=
devnums
.
pop
(
0
)
disk
.
full_clean
()
disk
.
full_clean
()
disk
.
save
()
self
.
instance
.
disks
.
add
(
disk
)
self
.
instance
.
disks
.
add
(
disk
)
if
self
.
instance
.
is_running
and
disk
.
type
not
in
[
"iso"
]:
with
activity
.
sub_activity
(
'attach_disk'
):
self
.
instance
.
attach_disk
(
disk
)
register_operation
(
DownloadDiskOperation
)
register_operation
(
DownloadDiskOperation
)
...
@@ -329,6 +346,7 @@ class RemoveInterfaceOperation(InstanceOperation):
...
@@ -329,6 +346,7 @@ class RemoveInterfaceOperation(InstanceOperation):
def
_operation
(
self
,
activity
,
user
,
system
,
interface
):
def
_operation
(
self
,
activity
,
user
,
system
,
interface
):
if
self
.
instance
.
is_running
:
if
self
.
instance
.
is_running
:
self
.
instance
.
detach_network
(
interface
)
interface
.
shutdown
()
interface
.
shutdown
()
interface
.
destroy
()
interface
.
destroy
()
...
@@ -347,12 +365,13 @@ class RemoveDiskOperation(InstanceOperation):
...
@@ -347,12 +365,13 @@ class RemoveDiskOperation(InstanceOperation):
def
check_precond
(
self
):
def
check_precond
(
self
):
super
(
RemoveDiskOperation
,
self
)
.
check_precond
()
super
(
RemoveDiskOperation
,
self
)
.
check_precond
()
# TODO remove check when hot-detach is implemented
if
self
.
instance
.
status
not
in
[
'STOPPED'
,
'RUNNING'
]:
if
self
.
instance
.
status
not
in
[
'STOPPED'
]:
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
raise
self
.
instance
.
WrongStateError
(
self
.
instance
)
def
_operation
(
self
,
activity
,
user
,
system
,
disk
):
def
_operation
(
self
,
activity
,
user
,
system
,
disk
):
# TODO implement with hot-detach when it'll be available
if
self
.
instance
.
is_running
and
disk
.
type
not
in
[
"iso"
]:
with
activity
.
sub_activity
(
'detach_disk'
):
self
.
instance
.
detach_disk
(
disk
)
return
self
.
instance
.
disks
.
remove
(
disk
)
return
self
.
instance
.
disks
.
remove
(
disk
)
...
...
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