Add create_vm_pricing management command
This commit is contained in:
parent
588f513f2a
commit
d50f282057
1 changed files with 36 additions and 0 deletions
|
@ -0,0 +1,36 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
|
||||
from datacenterlight.models import VMPricing
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = '''Creates default VMPricing object'''
|
||||
DEFAULT_VMPRICING_NAME = 'default'
|
||||
|
||||
def handle(self, *args, **options):
|
||||
self.create_default_vm_pricing()
|
||||
|
||||
def create_default_vm_pricing(self):
|
||||
obj, created = VMPricing.objects.get_or_create(
|
||||
name=self.DEFAULT_VMPRICING_NAME,
|
||||
defaults={
|
||||
"vat_inclusive": True,
|
||||
"cores_unit_price": 5,
|
||||
"ram_unit_price": 2,
|
||||
"ssd_unit_price": 0.6,
|
||||
"hdd_unit_price": 0.01
|
||||
}
|
||||
)
|
||||
|
||||
if created:
|
||||
print(
|
||||
'Successfully created {} VMPricing object'.format(
|
||||
self.DEFAULT_VMPRICING_NAME
|
||||
)
|
||||
)
|
||||
else:
|
||||
print(
|
||||
'{} VMPricing exists already.'.format(
|
||||
self.DEFAULT_VMPRICING_NAME
|
||||
)
|
||||
)
|
Loading…
Reference in a new issue