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
6c04efc6
authored
Apr 01, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
instance: added clone method to InstanceTemplate
parent
114dba11
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
circle/vm/models/instance.py
+30
-0
No files found.
circle/vm/models/instance.py
View file @
6c04efc6
...
...
@@ -157,6 +157,36 @@ class InstanceTemplate(AclBase, VirtualMachineDescModel, TimeStampedModel):
if
is_new
:
self
.
set_level
(
self
.
owner
,
'owner'
)
def
clone
(
self
,
user
=
None
,
**
kwargs
):
"""Cloning a Template to a new Template.
It returns the new Template object.
Disk cloning handled paralell and asynchronusly.
"""
import
copy
tmpl
=
copy
.
deepcopy
(
self
)
tmpl
.
name
=
"Cloned from "
+
self
.
name
tmpl
.
pk
=
None
tmpl
.
full_clean
()
# Avoiding database errors.
tmpl
.
save
()
def
__clone_disk
(
disk
):
cloned_disk
=
Disk
.
create
(
datastore
=
disk
.
datastore
,
name
=
disk
.
name
,
size
=
disk
.
size
,
type
=
disk
.
type
)
#Paralell cloning disks
disk
.
clone_async
(
cloned_disk
,
user
=
user
)
return
cloned_disk
try
:
tmpl
.
disks
.
add
(
*
[
__clone_disk
(
disk
)
for
disk
in
self
.
disks
.
all
()])
tmpl
.
interface_set
.
add
(
*
self
.
interface_set
.
all
())
except
:
tmpl
.
delete
()
raise
else
:
return
tmpl
@permalink
def
get_absolute_url
(
self
):
return
(
'dashboard.views.template-detail'
,
None
,
{
'pk'
:
self
.
pk
})
...
...
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