Formatting

This commit is contained in:
PCoder 2021-04-15 16:50:45 +05:30
parent df4c0c3060
commit 8ae37d3bd4

View file

@ -17,6 +17,7 @@ def vm_price_2020(cpu=1, ram=2, v6only=False):
return cpu * 3 + ram * 4 - discount
def disk_price_2020(size_in_gb, disk_type):
if disk_type == VMDiskType.CEPH_SSD:
price = 3.5 / 10
@ -27,6 +28,7 @@ def disk_price_2020(size_in_gb, disk_type):
return size_in_gb * price
class Command(BaseCommand):
help = 'Adding VMs / creating orders for user'
@ -40,7 +42,7 @@ class Command(BaseCommand):
owner=user,
active=True,
defaults={'organization': 'Undefined organisation',
'name': 'Undefined name',
'full_name': 'Undefined name',
'street': 'Undefined Street',
'city': 'Undefined city',
'postal_code': '8750',
@ -50,8 +52,10 @@ class Command(BaseCommand):
)
# 25206 + SSD
vm25206 = VMProduct.objects.create(name="one-25206", cores=1, ram_in_gb=4, owner=user)
vm25206.create_order_at(timezone.make_aware(datetime.datetime(2020,3,3)))
vm25206 = VMProduct.objects.create(name="one-25206", cores=1,
ram_in_gb=4, owner=user)
vm25206.create_order_at(
timezone.make_aware(datetime.datetime(2020, 3, 3)))
# vm25206_ssd = VMDiskProduct.objects.create(vm=vm25206, owner=user, size_in_gb=30)
# vm25206_ssd.create_order_at(timezone.make_aware(datetime.datetime(2020,3,3)))
@ -60,7 +64,8 @@ class Command(BaseCommand):
vm25206.cores = 2
vm25206.ram_in_gb = 8
vm25206.save()
vm25206.create_or_update_order(when_to_start=timezone.make_aware(datetime.datetime(2020,4,17)))
vm25206.create_or_update_order(
when_to_start=timezone.make_aware(datetime.datetime(2020, 4, 17)))
sys.exit(0)
@ -72,48 +77,51 @@ class Command(BaseCommand):
# 25206 done.
# 25615
vm25615 = VMProduct.objects.create(name="one-25615", cores=1, ram_in_gb=4, owner=user)
vm25615.create_order_at(timezone.make_aware(datetime.datetime(2020,3,3)))
vm25615 = VMProduct.objects.create(name="one-25615", cores=1,
ram_in_gb=4, owner=user)
vm25615.create_order_at(
timezone.make_aware(datetime.datetime(2020, 3, 3)))
# Change 2020-04-17
vm25615.cores = 2
vm25615.ram_in_gb = 8
vm25615.save()
vm25615.create_or_update_order(when_to_start=timezone.make_aware(datetime.datetime(2020,4,17)))
vm25615.create_or_update_order(
when_to_start=timezone.make_aware(datetime.datetime(2020, 4, 17)))
# vm25615_ssd = VMDiskProduct(vm=vm25615, owner=user, size_in_gb=30)
# vm25615_ssd.create_order_at(timezone.make_aware(datetime.datetime(2020,3,3)))
# vm25615_ssd.save()
vm25208 = VMProduct.objects.create(name="one-25208", cores=1, ram_in_gb=4, owner=user)
vm25208.create_order_at(timezone.make_aware(datetime.datetime(2020,3,5)))
vm25208 = VMProduct.objects.create(name="one-25208", cores=1,
ram_in_gb=4, owner=user)
vm25208.create_order_at(
timezone.make_aware(datetime.datetime(2020, 3, 5)))
vm25208.cores = 2
vm25208.ram_in_gb = 8
vm25208.save()
vm25208.create_or_update_order(when_to_start=timezone.make_aware(datetime.datetime(2020,4,17)))
vm25208.create_or_update_order(
when_to_start=timezone.make_aware(datetime.datetime(2020, 4, 17)))
Bill.create_next_bills_for_user(user, ending_date=end_of_month(timezone.make_aware(datetime.datetime(2020,7,31))))
Bill.create_next_bills_for_user(user, ending_date=end_of_month(
timezone.make_aware(datetime.datetime(2020, 7, 31))))
sys.exit(0)
vm25615_ssd.size_in_gb = 50
vm25615_ssd.save()
vm25615_ssd.create_or_update_order(when_to_start=timezone.make_aware(datetime.datetime(2020,8,5)))
vm25615_ssd.create_or_update_order(
when_to_start=timezone.make_aware(datetime.datetime(2020, 8, 5)))
vm25208_ssd = VMDiskProduct.objects.create(vm=vm25208,
owner=user,
size_in_gb=30)
vm25208_ssd.size_in_gb = 50
vm25208_ssd.save()
vm25208_ssd.create_or_update_order(when_to_start=timezone.make_aware(datetime.datetime(2020,8,5)))
vm25208_ssd.create_or_update_order(
when_to_start=timezone.make_aware(datetime.datetime(2020, 8, 5)))
# 25207
vm25207 = VMProduct.objects.create(name="OpenNebula 25207",
@ -127,14 +135,14 @@ class Command(BaseCommand):
vm25207_ssd.size_in_gb = 50
vm25207_ssd.save()
vm25207_ssd.create_or_update_order(when_to_start=timezone.make_aware(datetime.datetime(2020,8,5)))
vm25207_ssd.create_or_update_order(
when_to_start=timezone.make_aware(datetime.datetime(2020, 8, 5)))
vm25207.cores = 2
vm25207.ram_in_gb = 8
vm25207.save()
vm25207.create_or_update_order(when_to_start=timezone.make_aware(datetime.datetime(2020,6,19)))
vm25207.create_or_update_order(
when_to_start=timezone.make_aware(datetime.datetime(2020, 6, 19)))
# FIXES: check starting times (they are slightly different)
# add vm 25236