Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
617234f7
authored
May 28, 2020
by
Máhonfai Bálint
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add function to mass create VMs for a list of users
parent
6085e2eb
Pipeline
#1144
passed with stage
in 0 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
circle/vm/models/instance.py
+22
-0
No files found.
circle/vm/models/instance.py
View file @
617234f7
...
@@ -439,6 +439,28 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
...
@@ -439,6 +439,28 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
return
[
cls
.
create
(
cps
,
disks
,
networks
,
req_traits
,
tags
)
return
[
cls
.
create
(
cps
,
disks
,
networks
,
req_traits
,
tags
)
for
cps
in
customized_params
]
for
cps
in
customized_params
]
@classmethod
def
mass_create_for_users
(
cls
,
template
,
users
,
**
kwargs
):
"""
Create and deploy an instance of a template
for each user in a list of users.
"""
user_instances
=
[]
user_id
=
None
try
:
for
user_id
in
users
:
user_instances
.
append
(
User
.
objects
.
get
(
profile__org_id
=
user_id
))
except
User
.
DoesNotExist
:
raise
Exception
(
"User with id
%
s doesn't exist"
%
user_id
)
instances
=
[]
for
user
in
user_instances
:
instance
=
cls
.
create_from_template
(
template
,
user
,
**
kwargs
)
instance
.
deploy
(
user
=
user
)
instances
.
append
(
instance
)
return
instances
def
clean
(
self
,
*
args
,
**
kwargs
):
def
clean
(
self
,
*
args
,
**
kwargs
):
self
.
time_of_suspend
,
self
.
time_of_delete
=
self
.
get_renew_times
()
self
.
time_of_suspend
,
self
.
time_of_delete
=
self
.
get_renew_times
()
super
(
Instance
,
self
)
.
clean
(
*
args
,
**
kwargs
)
super
(
Instance
,
self
)
.
clean
(
*
args
,
**
kwargs
)
...
...
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