Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
7e3d9ab5
authored
Oct 09, 2016
by
Szabolcs Gelencser
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Azure VM Size model. Implement Azure VM size periodic import.
parent
9f04d2dc
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
121 additions
and
1 deletions
+121
-1
circle/manager/mancelery.py
+6
-0
circle/vm/migrations/0005_azurevirtualmachinesize.py
+29
-0
circle/vm/models/__init__.py
+2
-1
circle/vm/models/azure_virtual_machine_size.py
+49
-0
circle/vm/tasks/local_periodic_tasks.py
+35
-0
No files found.
circle/manager/mancelery.py
View file @
7e3d9ab5
...
...
@@ -61,6 +61,12 @@ celery.conf.update(
'schedule'
:
timedelta
(
hours
=
24
),
'options'
:
{
'queue'
:
'localhost.man'
}
},
'vm.update_azure_vm_sizes'
:
{
'task'
:
'vm.tasks.local_periodic_tasks.'
'update_azure_vm_sizes'
,
'schedule'
:
timedelta
(
hours
=
24
),
'options'
:
{
'queue'
:
'localhost.man'
}
},
}
)
...
...
circle/vm/migrations/0005_azurevirtualmachinesize.py
0 → 100644
View file @
7e3d9ab5
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'vm'
,
'0004_auto_20161006_2201'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'AzureVirtualMachineSize'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
verbose_name
=
'ID'
,
serialize
=
False
,
auto_created
=
True
,
primary_key
=
True
)),
(
'name'
,
models
.
TextField
(
verbose_name
=
'name'
)),
(
'number_of_cores'
,
models
.
IntegerField
(
verbose_name
=
'number of cores'
)),
(
'os_disk_size_in_mb'
,
models
.
IntegerField
(
verbose_name
=
'os disk size in mb'
)),
(
'resource_disk_size_in_mb'
,
models
.
IntegerField
(
verbose_name
=
'resource disk size in mb'
)),
(
'memory_in_mb'
,
models
.
IntegerField
(
verbose_name
=
'memory in mb'
)),
(
'max_data_disk_count'
,
models
.
IntegerField
(
verbose_name
=
'max data disk count'
)),
],
options
=
{
'db_table'
:
'vm_azure_vm_size'
,
},
),
]
circle/vm/models/__init__.py
View file @
7e3d9ab5
...
...
@@ -19,6 +19,7 @@ from .azure_builtin_template import AzureBuiltinPublisher
from
.azure_builtin_template
import
AzureBuiltinOffer
from
.azure_builtin_template
import
AzureBuiltinSKU
from
.azure_builtin_template
import
AzureBuiltinVersion
from
.azure_virtual_machine_size
import
AzureVirtualMachineSize
__all__
=
[
'InstanceActivity'
,
'BaseResourceConfigModel'
,
...
...
@@ -26,5 +27,5 @@ __all__ = [
'Instance'
,
'post_state_changed'
,
'pre_state_changed'
,
'InterfaceTemplate'
,
'Interface'
,
'Trait'
,
'Node'
,
'NodeActivity'
,
'Lease'
,
'node_activity'
,
'pwgen'
,
'AzureBuiltinPublisher'
,
'AzureBuiltinOffer'
,
'AzureBuiltinSKU'
,
'AzureBuiltinVersion'
,
'AzureBuiltinVersion'
,
'AzureVirtualMachineSize'
,
]
circle/vm/models/azure_virtual_machine_size.py
0 → 100644
View file @
7e3d9ab5
# Copyright 2014 Budapest University of Technology and Economics (BME IK)
#
# This file is part of CIRCLE Cloud.
#
# CIRCLE is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# CIRCLE is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
__future__
import
absolute_import
,
unicode_literals
from
django.db
import
models
from
django.utils.translation
import
ugettext_lazy
as
_
from
logging
import
getLogger
logger
=
getLogger
(
__name__
)
class
AzureVirtualMachineSize
(
models
.
Model
):
"""
Azure Virtual Machine size
"""
name
=
models
.
TextField
(
verbose_name
=
_
(
'name'
),
unique
=
True
)
number_of_cores
=
models
.
IntegerField
(
verbose_name
=
_
(
'number of cores'
))
os_disk_size_in_mb
=
models
.
IntegerField
(
verbose_name
=
_
(
'os disk size in mb'
))
resource_disk_size_in_mb
=
models
.
IntegerField
(
verbose_name
=
_
(
'resource disk size in mb'
))
memory_in_mb
=
models
.
IntegerField
(
verbose_name
=
_
(
'memory in mb'
))
max_data_disk_count
=
models
.
IntegerField
(
verbose_name
=
_
(
'max data disk count'
))
class
Meta
:
app_label
=
'vm'
db_table
=
'vm_azure_vm_size'
def
__unicode__
(
self
):
return
'azure_vm_size-'
+
str
(
self
.
name
)
\ No newline at end of file
circle/vm/tasks/local_periodic_tasks.py
View file @
7e3d9ab5
...
...
@@ -20,11 +20,13 @@ from os import getenv
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_noop
from
django.core.exceptions
import
ObjectDoesNotExist
from
manager.mancelery
import
celery
from
vm.models
import
(
Node
,
Instance
,
AzureBuiltinPublisher
,
AzureBuiltinOffer
,
AzureBuiltinSKU
,
AzureBuiltinVersion
,
AzureVirtualMachineSize
,
)
from
azure.common.credentials
import
ServicePrincipalCredentials
from
azure.mgmt.compute
import
ComputeManagementClient
...
...
@@ -102,6 +104,39 @@ def garbage_collector(timeout=15):
logger
.
debug
(
"Instance
%
d didn't expire."
%
i
.
pk
)
@celery.task
(
ignore_result
=
True
)
def
update_azure_vm_sizes
():
logger
.
info
(
"beginning azure vm size imports"
)
vm_sizes
=
compute_client
.
virtual_machine_sizes
.
list
(
REGION
,
)
for
vm_size
in
vm_sizes
:
try
:
old_vm_size
=
AzureVirtualMachineSize
.
objects
.
get
(
name
=
vm_size
.
name
)
old_vm_size
.
name
=
vm_size
.
name
old_vm_size
.
number_of_cores
=
vm_size
.
number_of_cores
old_vm_size
.
os_disk_size_in_mb
=
vm_size
.
os_disk_size_in_mb
old_vm_size
.
resource_disk_size_in_mb
=
\
vm_size
.
resource_disk_size_in_mb
old_vm_size
.
memory_in_mb
=
vm_size
.
memory_in_mb
old_vm_size
.
max_data_disk_count
=
vm_size
.
max_data_disk_count
old_vm_size
.
save
()
except
ObjectDoesNotExist
:
new_vm_size
=
AzureVirtualMachineSize
(
name
=
vm_size
.
name
,
number_of_cores
=
vm_size
.
number_of_cores
,
os_disk_size_in_mb
=
vm_size
.
os_disk_size_in_mb
,
resource_disk_size_in_mb
=
vm_size
.
resource_disk_size_in_mb
,
memory_in_mb
=
vm_size
.
memory_in_mb
,
max_data_disk_count
=
vm_size
.
max_data_disk_count
,
)
new_vm_size
.
save
()
logger
.
info
(
"finished importing azure vm sizes"
)
@celery.task
(
ignore_result
=
True
)
def
update_azure_builtin_templates
():
logger
.
info
(
"beginning azure built-in template imports"
)
...
...
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