Formatting
This commit is contained in:
parent
df4c0c3060
commit
8ae37d3bd4
1 changed files with 42 additions and 34 deletions
|
@ -15,18 +15,20 @@ def vm_price_2020(cpu=1, ram=2, v6only=False):
|
||||||
else:
|
else:
|
||||||
discount = 0
|
discount = 0
|
||||||
|
|
||||||
return cpu*3 + ram*4 - discount
|
return cpu * 3 + ram * 4 - discount
|
||||||
|
|
||||||
|
|
||||||
def disk_price_2020(size_in_gb, disk_type):
|
def disk_price_2020(size_in_gb, disk_type):
|
||||||
if disk_type == VMDiskType.CEPH_SSD:
|
if disk_type == VMDiskType.CEPH_SSD:
|
||||||
price = 3.5/10
|
price = 3.5 / 10
|
||||||
elif disk_type == VMDiskType.CEPH_HDD:
|
elif disk_type == VMDiskType.CEPH_HDD:
|
||||||
price = 1.5/100
|
price = 1.5 / 100
|
||||||
else:
|
else:
|
||||||
raise Exception("not yet defined price")
|
raise Exception("not yet defined price")
|
||||||
|
|
||||||
return size_in_gb * price
|
return size_in_gb * price
|
||||||
|
|
||||||
|
|
||||||
class Command(BaseCommand):
|
class Command(BaseCommand):
|
||||||
help = 'Adding VMs / creating orders for user'
|
help = 'Adding VMs / creating orders for user'
|
||||||
|
|
||||||
|
@ -40,18 +42,20 @@ class Command(BaseCommand):
|
||||||
owner=user,
|
owner=user,
|
||||||
active=True,
|
active=True,
|
||||||
defaults={'organization': 'Undefined organisation',
|
defaults={'organization': 'Undefined organisation',
|
||||||
'name': 'Undefined name',
|
'full_name': 'Undefined name',
|
||||||
'street': 'Undefined Street',
|
'street': 'Undefined Street',
|
||||||
'city': 'Undefined city',
|
'city': 'Undefined city',
|
||||||
'postal_code': '8750',
|
'postal_code': '8750',
|
||||||
'country': 'CH',
|
'country': 'CH',
|
||||||
'active': True
|
'active': True
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
# 25206 + SSD
|
# 25206 + SSD
|
||||||
vm25206 = VMProduct.objects.create(name="one-25206", cores=1, ram_in_gb=4, owner=user)
|
vm25206 = VMProduct.objects.create(name="one-25206", cores=1,
|
||||||
vm25206.create_order_at(timezone.make_aware(datetime.datetime(2020,3,3)))
|
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 = VMDiskProduct.objects.create(vm=vm25206, owner=user, size_in_gb=30)
|
||||||
# vm25206_ssd.create_order_at(timezone.make_aware(datetime.datetime(2020,3,3)))
|
# vm25206_ssd.create_order_at(timezone.make_aware(datetime.datetime(2020,3,3)))
|
||||||
|
@ -60,7 +64,8 @@ class Command(BaseCommand):
|
||||||
vm25206.cores = 2
|
vm25206.cores = 2
|
||||||
vm25206.ram_in_gb = 8
|
vm25206.ram_in_gb = 8
|
||||||
vm25206.save()
|
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)
|
sys.exit(0)
|
||||||
|
|
||||||
|
@ -72,69 +77,72 @@ class Command(BaseCommand):
|
||||||
# 25206 done.
|
# 25206 done.
|
||||||
|
|
||||||
# 25615
|
# 25615
|
||||||
vm25615 = VMProduct.objects.create(name="one-25615", cores=1, ram_in_gb=4, owner=user)
|
vm25615 = VMProduct.objects.create(name="one-25615", cores=1,
|
||||||
vm25615.create_order_at(timezone.make_aware(datetime.datetime(2020,3,3)))
|
ram_in_gb=4, owner=user)
|
||||||
|
vm25615.create_order_at(
|
||||||
|
timezone.make_aware(datetime.datetime(2020, 3, 3)))
|
||||||
|
|
||||||
# Change 2020-04-17
|
# Change 2020-04-17
|
||||||
vm25615.cores = 2
|
vm25615.cores = 2
|
||||||
vm25615.ram_in_gb = 8
|
vm25615.ram_in_gb = 8
|
||||||
vm25615.save()
|
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 = VMDiskProduct(vm=vm25615, owner=user, size_in_gb=30)
|
||||||
# vm25615_ssd.create_order_at(timezone.make_aware(datetime.datetime(2020,3,3)))
|
# vm25615_ssd.create_order_at(timezone.make_aware(datetime.datetime(2020,3,3)))
|
||||||
# vm25615_ssd.save()
|
# vm25615_ssd.save()
|
||||||
|
|
||||||
vm25208 = VMProduct.objects.create(name="one-25208", cores=1, ram_in_gb=4, owner=user)
|
vm25208 = VMProduct.objects.create(name="one-25208", cores=1,
|
||||||
vm25208.create_order_at(timezone.make_aware(datetime.datetime(2020,3,5)))
|
ram_in_gb=4, owner=user)
|
||||||
|
vm25208.create_order_at(
|
||||||
|
timezone.make_aware(datetime.datetime(2020, 3, 5)))
|
||||||
|
|
||||||
vm25208.cores = 2
|
vm25208.cores = 2
|
||||||
vm25208.ram_in_gb = 8
|
vm25208.ram_in_gb = 8
|
||||||
vm25208.save()
|
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)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
vm25615_ssd.size_in_gb = 50
|
vm25615_ssd.size_in_gb = 50
|
||||||
vm25615_ssd.save()
|
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,
|
vm25208_ssd = VMDiskProduct.objects.create(vm=vm25208,
|
||||||
owner=user,
|
owner=user,
|
||||||
size_in_gb=30)
|
size_in_gb=30)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vm25208_ssd.size_in_gb = 50
|
vm25208_ssd.size_in_gb = 50
|
||||||
vm25208_ssd.save()
|
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
|
# 25207
|
||||||
vm25207 = VMProduct.objects.create(name="OpenNebula 25207",
|
vm25207 = VMProduct.objects.create(name="OpenNebula 25207",
|
||||||
cores=1,
|
cores=1,
|
||||||
ram_in_gb=4,
|
ram_in_gb=4,
|
||||||
owner=user)
|
owner=user)
|
||||||
|
|
||||||
vm25207_ssd = VMDiskProduct.objects.create(vm=vm25207,
|
vm25207_ssd = VMDiskProduct.objects.create(vm=vm25207,
|
||||||
owner=user,
|
owner=user,
|
||||||
size_in_gb=30)
|
size_in_gb=30)
|
||||||
|
|
||||||
vm25207_ssd.size_in_gb = 50
|
vm25207_ssd.size_in_gb = 50
|
||||||
vm25207_ssd.save()
|
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.cores = 2
|
||||||
vm25207.ram_in_gb = 8
|
vm25207.ram_in_gb = 8
|
||||||
vm25207.save()
|
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)
|
# FIXES: check starting times (they are slightly different)
|
||||||
# add vm 25236
|
# add vm 25236
|
||||||
|
|
Loading…
Reference in a new issue