+
+ {% for message in messages %}
+ {% if 'vat_error' in message.tags %}
+
+ {{ message|safe }}
+
+ {% endif %}
+ {% endfor %}
+
+
+
+
+
+
+
+ {% with cards_len=cards|length %}
+
{%trans "Credit Card"%}
+
+
+ {% if cards_len > 0 %}
+ {% blocktrans %}Please select one of the cards that you used before or fill in your credit card information below. We are using Stripe for payment and do not store your information in our database.{% endblocktrans %}
+ {% else %}
+ {% blocktrans %}Please fill in your credit card information below. We are using Stripe for payment and do not store your information in our database.{% endblocktrans %}
+ {% endif %}
+
+
+ {% for card in cards %}
+
+
+
{% trans "Credit Card" %}
+
{% trans "Last" %} 4: ***** {{card.last4}}
+
{% trans "Type" %}: {{card.brand}}
+
{% trans "Expiry" %}: {{card.month}}/{{card.year}}
+ >]
+ django_contrib_auth_models_AbstractUser -> django_contrib_auth_models_PermissionsMixin
+ [label=" abstract\ninheritance"] [arrowhead=empty, arrowtail=none, dir=both];
+
+ uncloud_auth_models_User -> django_contrib_auth_models_Group
+ [label=" groups (user)"] [arrowhead=dot arrowtail=dot, dir=both];
+
+ uncloud_auth_models_User -> django_contrib_auth_models_Permission
+ [label=" user_permissions (user)"] [arrowhead=dot arrowtail=dot, dir=both];
+
+ uncloud_auth_models_User -> django_contrib_auth_models_AbstractUser
+ [label=" abstract\ninheritance"] [arrowhead=empty, arrowtail=none, dir=both];
+
+
+ uncloud_pay_models_Product -> uncloud_auth_models_User
+ [label=" owner (product)"] [arrowhead=none, arrowtail=dot, dir=both];
+
+ uncloud_pay_models_Product -> uncloud_pay_models_Order
+ [label=" order (product)"] [arrowhead=none, arrowtail=dot, dir=both];
+
+ uncloud_vm_models_VMProduct -> uncloud_vm_models_VMHost
+ [label=" vmhost (vmproduct)"] [arrowhead=none, arrowtail=dot, dir=both];
+
+ uncloud_vm_models_VMProduct -> uncloud_pay_models_Product
+ [label=" abstract\ninheritance"] [arrowhead=empty, arrowtail=none, dir=both];
+
+ uncloud_vm_models_VMWithOSProduct -> uncloud_vm_models_VMProduct
+ [label=" multi-table\ninheritance"] [arrowhead=empty, arrowtail=none, dir=both];
+
+ uncloud_vm_models_VMDiskImageProduct -> uncloud_auth_models_User
+ [label=" owner (vmdiskimageproduct)"] [arrowhead=none, arrowtail=dot, dir=both];
+
+ uncloud_vm_models_VMDiskProduct -> uncloud_auth_models_User
+ [label=" owner (vmdiskproduct)"] [arrowhead=none, arrowtail=dot, dir=both];
+
+ uncloud_vm_models_VMDiskProduct -> uncloud_vm_models_VMProduct
+ [label=" vm (vmdiskproduct)"] [arrowhead=none, arrowtail=dot, dir=both];
+
+ uncloud_vm_models_VMDiskProduct -> uncloud_vm_models_VMDiskImageProduct
+ [label=" image (vmdiskproduct)"] [arrowhead=none, arrowtail=dot, dir=both];
+
+ uncloud_vm_models_VMNetworkCard -> uncloud_vm_models_VMProduct
+ [label=" vm (vmnetworkcard)"] [arrowhead=none, arrowtail=dot, dir=both];
+
+ uncloud_vm_models_VMSnapshotProduct -> uncloud_vm_models_VMProduct
+ [label=" vm (vmsnapshotproduct)"] [arrowhead=none, arrowtail=dot, dir=both];
+
+ uncloud_vm_models_VMSnapshotProduct -> uncloud_pay_models_Product
+ [label=" abstract\ninheritance"] [arrowhead=empty, arrowtail=none, dir=both];
+
+
+ uncloud_pay_models_Product -> uncloud_auth_models_User
+ [label=" owner (product)"] [arrowhead=none, arrowtail=dot, dir=both];
+
+ uncloud_pay_models_Product -> uncloud_pay_models_Order
+ [label=" order (product)"] [arrowhead=none, arrowtail=dot, dir=both];
+
+ ungleich_service_models_MatrixServiceProduct -> uncloud_vm_models_VMProduct
+ [label=" vm (matrixserviceproduct)"] [arrowhead=none, arrowtail=dot, dir=both];
+
+ ungleich_service_models_MatrixServiceProduct -> uncloud_pay_models_Product
+ [label=" abstract\ninheritance"] [arrowhead=empty, arrowtail=none, dir=both];
+
+
+ opennebula_models_VM -> uncloud_auth_models_User
+ [label=" owner (vm)"] [arrowhead=none, arrowtail=dot, dir=both];
+
+
+}
diff --git a/models.png b/models.png
new file mode 100644
index 0000000..f9d0c2e
Binary files /dev/null and b/models.png differ
diff --git a/opennebula/__init__.py b/opennebula/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/opennebula/admin.py b/opennebula/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/opennebula/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/opennebula/apps.py b/opennebula/apps.py
new file mode 100644
index 0000000..0750576
--- /dev/null
+++ b/opennebula/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class OpennebulaConfig(AppConfig):
+ name = 'opennebula'
diff --git a/opennebula/management/commands/opennebula-synchosts.py b/opennebula/management/commands/opennebula-synchosts.py
new file mode 100644
index 0000000..29f9ac1
--- /dev/null
+++ b/opennebula/management/commands/opennebula-synchosts.py
@@ -0,0 +1,74 @@
+import json
+
+import uncloud.secrets as secrets
+
+from xmlrpc.client import ServerProxy as RPCClient
+
+from django.core.management.base import BaseCommand
+from xmltodict import parse
+from enum import IntEnum
+from opennebula.models import VM as VMModel
+from uncloud_vm.models import VMHost
+from django_auth_ldap.backend import LDAPBackend
+
+
+class HostStates(IntEnum):
+ """
+ The following flags are copied from
+ https://docs.opennebula.org/5.8/integration/system_interfaces/api.html#schemas-for-host
+ """
+ INIT = 0 # Initial state for enabled hosts
+ MONITORING_MONITORED = 1 # Monitoring the host (from monitored)
+ MONITORED = 2 # The host has been successfully monitored
+ ERROR = 3 # An error ocurrer while monitoring the host
+ DISABLED = 4 # The host is disabled
+ MONITORING_ERROR = 5 # Monitoring the host (from error)
+ MONITORING_INIT = 6 # Monitoring the host (from init)
+ MONITORING_DISABLED = 7 # Monitoring the host (from disabled)
+ OFFLINE = 8 # The host is totally offline
+
+
+class Command(BaseCommand):
+ help = 'Syncronize Host information from OpenNebula'
+
+ def add_arguments(self, parser):
+ pass
+
+ def handle(self, *args, **options):
+ with RPCClient(secrets.OPENNEBULA_URL) as rpc_client:
+ success, response, *_ = rpc_client.one.hostpool.info(secrets.OPENNEBULA_USER_PASS)
+ if success:
+ response = json.loads(json.dumps(parse(response)))
+ host_pool = response.get('HOST_POOL', {}).get('HOST', {})
+ for host in host_pool:
+ host_share = host.get('HOST_SHARE', {})
+
+ host_name = host.get('NAME')
+ state = int(host.get('STATE', HostStates.OFFLINE.value))
+
+ if state == HostStates.MONITORED:
+ status = 'active'
+ elif state == HostStates.DISABLED:
+ status = 'disabled'
+ else:
+ status = 'unusable'
+
+ usable_cores = host_share.get('TOTAL_CPU')
+ usable_ram_in_kb = int(host_share.get('TOTAL_MEM', 0))
+ usable_ram_in_gb = int(usable_ram_in_kb / 2 ** 20)
+
+ # vms cannot be created like this -- Nico, 2020-03-17
+ # vms = host.get('VMS', {}) or {}
+ # vms = vms.get('ID', []) or []
+ # vms = ','.join(vms)
+
+ VMHost.objects.update_or_create(
+ hostname=host_name,
+ defaults={
+ 'usable_cores': usable_cores,
+ 'usable_ram_in_gb': usable_ram_in_gb,
+ 'status': status
+ }
+ )
+ else:
+ print(response)
diff --git a/opennebula/management/commands/opennebula-syncvms.py b/opennebula/management/commands/opennebula-syncvms.py
new file mode 100644
index 0000000..3c12fa9
--- /dev/null
+++ b/opennebula/management/commands/opennebula-syncvms.py
@@ -0,0 +1,44 @@
+import json
+
+from xmlrpc.client import ServerProxy as RPCClient
+from django_auth_ldap.backend import LDAPBackend
+from django.core.management.base import BaseCommand
+from django.conf import settings
+from xmltodict import parse
+
+from opennebula.models import VM as VMModel
+
+
+class Command(BaseCommand):
+ help = 'Syncronize VM information from OpenNebula'
+
+ def add_arguments(self, parser):
+ pass
+
+ def handle(self, *args, **options):
+ with RPCClient(settings.OPENNEBULA_URL) as rpc_client:
+ success, response, *_ = rpc_client.one.vmpool.infoextended(
+ settings.OPENNEBULA_USER_PASS, -2, -1, -1, -1
+ )
+ if success:
+ vms = json.loads(json.dumps(parse(response)))['VM_POOL']['VM']
+ unknown_user = set()
+
+ backend = LDAPBackend()
+
+ for vm in vms:
+ vm_id = vm['ID']
+ vm_owner = vm['UNAME']
+
+ user = backend.populate_user(username=vm_owner)
+
+ if not user:
+ unknown_user.add(vm_owner)
+ else:
+ VMModel.objects.update_or_create(
+ vmid=vm_id,
+ defaults={'data': vm, 'owner': user}
+ )
+ print('User not found in ldap:', unknown_user)
+ else:
+ print(response)
diff --git a/opennebula/management/commands/opennebula-to-uncloud.py b/opennebula/management/commands/opennebula-to-uncloud.py
new file mode 100644
index 0000000..230159a
--- /dev/null
+++ b/opennebula/management/commands/opennebula-to-uncloud.py
@@ -0,0 +1,193 @@
+import sys
+from datetime import datetime
+
+from django.core.management.base import BaseCommand
+from django.utils import timezone
+from django.contrib.auth import get_user_model
+
+from opennebula.models import VM as VMModel
+from uncloud_vm.models import VMHost, VMProduct, VMNetworkCard, VMDiskImageProduct, VMDiskProduct
+
+from uncloud_pay.models import Order
+
+import logging
+
+log = logging.getLogger(__name__)
+
+def convert_mac_to_int(mac_address: str):
+ # Remove octet connecting characters
+ mac_address = mac_address.replace(':', '')
+ mac_address = mac_address.replace('.', '')
+ mac_address = mac_address.replace('-', '')
+ mac_address = mac_address.replace(' ', '')
+
+ # Parse the resulting number as hexadecimal
+ mac_address = int(mac_address, base=16)
+
+ return mac_address
+
+
+def get_vm_price(core, ram, ssd_size, hdd_size, n_of_ipv4, n_of_ipv6):
+ total = 3 * core + 4 * ram + (3.5 * ssd_size/10.) + (1.5 * hdd_size/100.) + 8 * n_of_ipv4 + 0 * n_of_ipv6
+
+ # TODO: Find some reason about the following magical subtraction.
+ total -= 8
+
+ return total
+
+
+def create_nics(one_vm, vm_product):
+ for nic in one_vm.nics:
+ mac_address = convert_mac_to_int(nic.get('MAC'))
+ ip_address = nic.get('IP', None) or nic.get('IP6_GLOBAL', None)
+
+ VMNetworkCard.objects.update_or_create(
+ mac_address=mac_address, vm=vm_product, defaults={'ip_address': ip_address}
+ )
+
+
+def sync_disk_and_image(one_vm, vm_product, disk_owner):
+ """
+ a) Check all opennebula disk if they are in the uncloud VM, if not add
+ b) Check all uncloud disks and remove them if they are not in the opennebula VM
+ """
+
+ vmdisknum = 0
+
+ one_disks_extra_data = []
+
+ for disk in one_vm.disks:
+ vmowner = one_vm.owner
+ name = disk.get('image')
+ vmdisknum += 1
+
+ log.info("Checking disk {} for VM {}".format(name, one_vm))
+
+ is_os_image, is_public, status = True, False, 'active'
+
+ image_size_in_gb = disk.get('image_size_in_gb')
+ disk_size_in_gb = disk.get('size_in_gb')
+ storage_class = disk.get('storage_class')
+ image_source = disk.get('source')
+ image_source_type = disk.get('source_type')
+
+ image, _ = VMDiskImageProduct.objects.update_or_create(
+ name=name,
+ defaults={
+ 'owner': disk_owner,
+ 'is_os_image': is_os_image,
+ 'is_public': is_public,
+ 'size_in_gb': image_size_in_gb,
+ 'storage_class': storage_class,
+ 'image_source': image_source,
+ 'image_source_type': image_source_type,
+ 'status': status
+ }
+ )
+
+ # identify vmdisk from opennebula - primary mapping key
+ extra_data = {
+ 'opennebula_vm': one_vm.vmid,
+ 'opennebula_size_in_gb': disk_size_in_gb,
+ 'opennebula_source': disk.get('opennebula_source'),
+ 'opennebula_disk_num': vmdisknum
+ }
+ # Save for comparing later
+ one_disks_extra_data.append(extra_data)
+
+ try:
+ vm_disk = VMDiskProduct.objects.get(extra_data=extra_data)
+ except VMDiskProduct.DoesNotExist:
+ vm_disk = VMDiskProduct.objects.create(
+ owner=vmowner,
+ vm=vm_product,
+ image=image,
+ size_in_gb=disk_size_in_gb,
+ extra_data=extra_data
+ )
+
+ # Now remove all disks that are not in above extra_data list
+ for disk in VMDiskProduct.objects.filter(vm=vm_product):
+ extra_data = disk.extra_data
+ if not extra_data in one_disks_extra_data:
+ log.info("Removing disk {} from VM {}".format(disk, vm_product))
+ disk.delete()
+
+ disks = [ disk.extra_data for disk in VMDiskProduct.objects.filter(vm=vm_product) ]
+ log.info("VM {} has disks: {}".format(vm_product, disks))
+
+class Command(BaseCommand):
+ help = 'Migrate Opennebula VM to regular (uncloud) vm'
+
+ def add_arguments(self, parser):
+ parser.add_argument('--disk-owner', required=True, help="The user who owns the the opennebula disks")
+
+ def handle(self, *args, **options):
+ log.debug("{} {}".format(args, options))
+
+ disk_owner = get_user_model().objects.get(username=options['disk_owner'])
+
+ for one_vm in VMModel.objects.all():
+
+ if not one_vm.last_host:
+ log.warning("No VMHost for VM {} - VM might be on hold - skipping".format(one_vm.vmid))
+ continue
+
+ try:
+ vmhost = VMHost.objects.get(hostname=one_vm.last_host)
+ except VMHost.DoesNotExist:
+ log.error("VMHost {} does not exist, aborting".format(one_vm.last_host))
+ raise
+
+ cores = one_vm.cores
+ ram_in_gb = one_vm.ram_in_gb
+ owner = one_vm.owner
+ status = 'active'
+
+ ssd_size = sum([ disk['size_in_gb'] for disk in one_vm.disks if disk['pool_name'] in ['ssd', 'one'] ])
+ hdd_size = sum([ disk['size_in_gb'] for disk in one_vm.disks if disk['pool_name'] in ['hdd'] ])
+
+ # List of IPv4 addresses and Global IPv6 addresses
+ ipv4, ipv6 = one_vm.ips
+
+ # TODO: Insert actual/real creation_date, starting_date, ending_date
+ # instead of pseudo one we are putting currently
+ creation_date = starting_date = datetime.now(tz=timezone.utc)
+
+ # Price calculation based on datacenterlight.ch
+ one_time_price = 0
+ recurring_period = 'per_month'
+ recurring_price = get_vm_price(cores, ram_in_gb,
+ ssd_size, hdd_size,
+ len(ipv4), len(ipv6))
+
+ try:
+ vm_product = VMProduct.objects.get(extra_data__opennebula_id=one_vm.vmid)
+ except VMProduct.DoesNotExist:
+ order = Order.objects.create(
+ owner=owner,
+ creation_date=creation_date,
+ starting_date=starting_date
+ )
+ vm_product = VMProduct(
+ extra_data={ 'opennebula_id': one_vm.vmid },
+ name=one_vm.uncloud_name,
+ order=order
+ )
+
+ # we don't use update_or_create, as filtering by json AND setting json
+ # at the same time does not work
+
+ vm_product.vmhost = vmhost
+ vm_product.owner = owner
+ vm_product.cores = cores
+ vm_product.ram_in_gb = ram_in_gb
+ vm_product.status = status
+
+ vm_product.save()
+
+ # Create VMNetworkCards
+ create_nics(one_vm, vm_product)
+
+ # Create VMDiskImageProduct and VMDiskProduct
+ sync_disk_and_image(one_vm, vm_product, disk_owner=disk_owner)
diff --git a/opennebula/migrations/0001_initial.py b/opennebula/migrations/0001_initial.py
new file mode 100644
index 0000000..9a135c6
--- /dev/null
+++ b/opennebula/migrations/0001_initial.py
@@ -0,0 +1,21 @@
+# Generated by Django 3.1 on 2020-12-13 10:38
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='VM',
+ fields=[
+ ('vmid', models.IntegerField(primary_key=True, serialize=False)),
+ ('data', models.JSONField()),
+ ],
+ ),
+ ]
diff --git a/opennebula/migrations/__init__.py b/opennebula/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/opennebula/models.py b/opennebula/models.py
new file mode 100644
index 0000000..f15b845
--- /dev/null
+++ b/opennebula/models.py
@@ -0,0 +1,90 @@
+import uuid
+from django.db import models
+from django.contrib.auth import get_user_model
+from uncloud_pay.models import Product
+
+# ungleich specific
+storage_class_mapping = {
+ 'one': 'ssd',
+ 'ssd': 'ssd',
+ 'hdd': 'hdd'
+}
+
+class VM(models.Model):
+ vmid = models.IntegerField(primary_key=True)
+ data = models.JSONField()
+
+ @property
+ def uncloud_name(self):
+ return "opennebula-{}".format(self.vmid)
+
+ @property
+ def cores(self):
+ return int(self.data['TEMPLATE']['VCPU'])
+
+ @property
+ def ram_in_gb(self):
+ return int(self.data['TEMPLATE']['MEMORY'])/1024
+
+ @property
+ def disks(self):
+ """
+ If there is no disk then the key DISK does not exist.
+
+ If there is only one disk, we have a dictionary in the database.
+
+ If there are multiple disks, we have a list of dictionaries in the database.
+ """
+
+ disks = []
+
+ if 'DISK' in self.data['TEMPLATE']:
+ if type(self.data['TEMPLATE']['DISK']) is dict:
+ disks = [self.data['TEMPLATE']['DISK']]
+ else:
+ disks = self.data['TEMPLATE']['DISK']
+
+ disks = [
+ {
+ 'size_in_gb': int(d['SIZE'])/1024,
+ 'opennebula_source': d['SOURCE'],
+ 'opennebula_name': d['IMAGE'],
+ 'image_size_in_gb': int(d['ORIGINAL_SIZE'])/1024,
+ 'pool_name': d['POOL_NAME'],
+ 'image': d['IMAGE'],
+ 'source': d['SOURCE'],
+ 'source_type': d['TM_MAD'],
+ 'storage_class': storage_class_mapping[d['POOL_NAME']]
+
+ }
+ for d in disks
+ ]
+
+ return disks
+
+ @property
+ def last_host(self):
+ return ((self.data.get('HISTORY_RECORDS', {}) or {}).get('HISTORY', {}) or {}).get('HOSTNAME', None)
+
+ @property
+ def graphics(self):
+ return self.data.get('TEMPLATE', {}).get('GRAPHICS', {})
+
+ @property
+ def nics(self):
+ _nics = self.data.get('TEMPLATE', {}).get('NIC', {})
+ if isinstance(_nics, dict):
+ _nics = [_nics]
+ return _nics
+
+ @property
+ def ips(self):
+ ipv4, ipv6 = [], []
+ for nic in self.nics:
+ ip = nic.get('IP')
+ ip6 = nic.get('IP6_GLOBAL')
+ if ip:
+ ipv4.append(ip)
+ if ip6:
+ ipv6.append(ip6)
+ return ipv4, ipv6
diff --git a/opennebula/serializers.py b/opennebula/serializers.py
new file mode 100644
index 0000000..cd00622
--- /dev/null
+++ b/opennebula/serializers.py
@@ -0,0 +1,10 @@
+from rest_framework import serializers
+from opennebula.models import VM
+
+
+class OpenNebulaVMSerializer(serializers.HyperlinkedModelSerializer):
+ class Meta:
+ model = VM
+ fields = [ 'vmid', 'owner', 'data',
+ 'uncloud_name', 'cores', 'ram_in_gb',
+ 'disks', 'nics', 'ips' ]
diff --git a/opennebula/tests.py b/opennebula/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/opennebula/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/opennebula/views.py b/opennebula/views.py
new file mode 100644
index 0000000..688f0b4
--- /dev/null
+++ b/opennebula/views.py
@@ -0,0 +1,16 @@
+from rest_framework import viewsets, permissions
+
+#from .models import VM
+# from .serializers import OpenNebulaVMSerializer
+
+# class VMViewSet(viewsets.ModelViewSet):
+# permission_classes = [permissions.IsAuthenticated]
+# serializer_class = OpenNebulaVMSerializer
+
+# def get_queryset(self):
+# if self.request.user.is_superuser:
+# obj = VM.objects.all()
+# else:
+# obj = VM.objects.filter(owner=self.request.user)
+
+# return obj
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..8231fd0
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,34 @@
+# Django basics
+Django==3.2.4
+djangorestframework
+django-auth-ldap
+django-bootstrap-v5
+fontawesome-free
+
+psycopg2
+ldap3
+django-allauth
+xmltodict
+parsedatetime
+# Follow are for creating graph models
+pyparsing
+pydot
+django-extensions
+
+# PDF creating
+django-hardcopy
+
+# schema support
+pyyaml
+uritemplate
+tldextract
+# Payment & VAT
+vat-validator
+stripe
+
+#Jobs
+django-q
+redis
+
+jinja2
+python-gitlab
diff --git a/resources/ci/.lock b/resources/ci/.lock
new file mode 100644
index 0000000..e69de29
diff --git a/resources/ci/Dockerfile b/resources/ci/Dockerfile
new file mode 100644
index 0000000..020b66e
--- /dev/null
+++ b/resources/ci/Dockerfile
@@ -0,0 +1,3 @@
+FROM fedora:latest
+
+RUN dnf install -y python3-devel python3-pip python3-coverage libpq-devel openldap-devel gcc chromium
diff --git a/resources/vat-rates.csv b/resources/vat-rates.csv
new file mode 100644
index 0000000..17bdb99
--- /dev/null
+++ b/resources/vat-rates.csv
@@ -0,0 +1,325 @@
+start_date,stop_date,territory_codes,currency_code,rate,rate_type,description
+2011-01-04,,AI,XCD,0,standard,Anguilla (British overseas territory) is exempted of VAT.
+1984-01-01,,AT,EUR,0.2,standard,Austria (member state) standard VAT rate.
+1976-01-01,1984-01-01,AT,EUR,0.18,standard,
+1973-01-01,1976-01-01,AT,EUR,0.16,standard,
+1984-01-01,,"AT-6691
+DE-87491",EUR,0.19,standard,Jungholz (Austrian town) special VAT rate.
+1984-01-01,,"AT-6991
+AT-6992
+AT-6993
+DE-87567
+DE-87568
+DE-87569",EUR,0.19,standard,Mittelberg (Austrian town) special VAT rate.
+1996-01-01,,BE,EUR,0.21,standard,Belgium (member state) standard VAT rate.
+1994-01-01,1996-01-01,BE,EUR,0.205,standard,
+1992-04-01,1994-01-01,BE,EUR,0.195,standard,
+1983-01-01,1992-04-01,BE,EUR,0.19,standard,
+1981-07-01,1983-01-01,BE,EUR,0.17,standard,
+1978-07-01,1981-07-01,BE,EUR,0.16,standard,
+1971-07-01,1978-07-01,BE,EUR,0.18,standard,
+1999-01-01,,BG,BGN,0.2,standard,Bulgaria (member state) standard VAT rate.
+1996-07-01,1999-01-01,BG,BGN,0.22,standard,
+1994-04-01,1996-07-01,BG,BGN,0.18,standard,
+2011-01-04,,BM,BMD,0,standard,Bermuda (British overseas territory) is exempted of VAT.
+2014-01-13,,"CY
+GB-BFPO 57
+GB-BFPO 58
+GB-BFPO 59
+UK-BFPO 57
+UK-BFPO 58
+UK-BFPO 59",EUR,0.19,standard,"Cyprus (member state) standard VAT rate.
+Akrotiri and Dhekelia (British overseas territory) is subjected to Cyprus' standard VAT rate."
+2013-01-14,2014-01-13,CY,EUR,0.18,standard,
+2012-03-01,2013-01-14,CY,EUR,0.17,standard,
+2003-01-01,2012-03-01,CY,EUR,0.15,standard,
+2002-07-01,2003-01-01,CY,EUR,0.13,standard,
+2000-07-01,2002-07-01,CY,EUR,0.1,standard,
+1993-10-01,2000-07-01,CY,EUR,0.08,standard,
+1992-07-01,1993-10-01,CY,EUR,0.05,standard,
+2013-01-01,,CZ,CZK,0.21,standard,Czech Republic (member state) standard VAT rate.
+2010-01-01,2013-01-01,CZ,CZK,0.2,standard,
+2004-05-01,2010-01-01,CZ,CZK,0.19,standard,
+1995-01-01,2004-05-01,CZ,CZK,0.22,standard,
+1993-01-01,1995-01-01,CZ,CZK,0.23,standard,
+2007-01-01,,DE,EUR,0.19,standard,Germany (member state) standard VAT rate.
+1998-04-01,2007-01-01,DE,EUR,0.16,standard,
+1993-01-01,1998-04-01,DE,EUR,0.15,standard,
+1983-07-01,1993-01-01,DE,EUR,0.14,standard,
+1979-07-01,1983-07-01,DE,EUR,0.13,standard,
+1978-01-01,1979-07-01,DE,EUR,0.12,standard,
+1968-07-01,1978-01-01,DE,EUR,0.11,standard,
+1968-01-01,1968-07-01,DE,EUR,0.1,standard,
+2007-01-01,,DE-27498,EUR,0,standard,Heligoland (German island) is exempted of VAT.
+2007-01-01,,"DE-78266
+CH-8238",EUR,0,standard,Busingen am Hochrhein (German territory) is exempted of VAT.
+1992-01-01,,DK,DKK,0.25,standard,Denmark (member state) standard VAT rate.
+1980-06-30,1992-01-01,DK,DKK,0.22,standard,
+1978-10-30,1980-06-30,DK,DKK,0.2025,standard,
+1977-10-03,1978-10-30,DK,DKK,0.18,standard,
+1970-06-29,1977-10-03,DK,DKK,0.15,standard,
+1968-04-01,1970-06-29,DK,DKK,0.125,standard,
+1967-07-03,1968-04-01,DK,DKK,0.1,standard,
+2009-07-01,,EE,EUR,0.2,standard,Estonia (member state) standard VAT rate.
+1993-01-01,2009-07-01,EE,EUR,0.18,standard,
+1991-01-01,1993-01-01,EE,EUR,0.1,standard,
+2016-06-01,,"GR
+EL",EUR,0.24,standard,Greece (member state) standard VAT rate.
+2010-07-01,2016-06-01,"GR
+EL",EUR,0.23,standard,
+2010-03-15,2010-07-01,"GR
+EL",EUR,0.21,standard,
+2005-04-01,2010-03-15,"GR
+EL",EUR,0.19,standard,
+1990-04-28,2005-04-01,"GR
+EL",EUR,0.18,standard,
+1988-01-01,1990-04-28,"GR
+EL",EUR,0.16,standard,
+1987-01-01,1988-01-01,"GR
+EL",EUR,0.18,standard,
+2012-09-01,,ES,EUR,0.21,standard,Spain (member state) standard VAT rate.
+2010-07-01,2012-09-01,ES,EUR,0.18,standard,
+1995-01-01,2010-07-01,ES,EUR,0.16,standard,
+1992-08-01,1995-01-01,ES,EUR,0.15,standard,
+1992-01-01,1992-08-01,ES,EUR,0.13,standard,
+1986-01-01,1992-01-01,ES,EUR,0.12,standard,
+2012-09-01,,"ES-CN
+ES-GC
+ES-TF
+IC",EUR,0,standard,Canary Islands (Spanish autonomous community) is exempted of VAT.
+2012-09-01,,"ES-ML
+ES-CE
+EA",EUR,0,standard,Ceuta and Melilla (Spanish autonomous cities) is exempted of VAT.
+2013-01-01,,FI,EUR,0.24,standard,Finland (member state) standard VAT rate.
+2010-07-01,2013-01-01,FI,EUR,0.23,standard,
+1994-06-01,2010-07-01,FI,EUR,0.22,standard,
+2013-01-01,,"FI-01
+AX",EUR,0,standard,Aland Islands (Finish autonomous region) is exempted of VAT.
+2011-01-04,,FK,FKP,0,standard,Falkland Islands (British overseas territory) is exempted of VAT.
+1992-01-01,,FO,DKK,0,standard,Faroe Islands (Danish autonomous country) is exempted of VAT.
+2014-01-01,,"FR
+MC",EUR,0.2,standard,"France (member state) standard VAT rate.
+Monaco (sovereign city-state) is member of the EU VAT area and subjected to France's standard VAT rate."
+2000-04-01,2014-01-01,"FR
+MC",EUR,0.196,standard,
+1995-08-01,2000-04-01,"FR
+MC",EUR,0.206,standard,
+1982-07-01,1995-08-01,"FR
+MC",EUR,0.186,standard,
+1977-01-01,1982-07-01,"FR
+MC",EUR,0.176,standard,
+1973-01-01,1977-01-01,"FR
+MC",EUR,0.2,standard,
+1970-01-01,1973-01-01,"FR
+MC",EUR,0.23,standard,
+1968-12-01,1970-01-01,"FR
+MC",EUR,0.19,standard,
+1968-01-01,1968-12-01,"FR
+MC",EUR,0.1666,standard,
+2014-01-01,,"FR-BL
+BL",EUR,0,standard,Saint Barthelemy (French overseas collectivity) is exempted of VAT.
+2014-01-01,,"FR-GF
+GF",EUR,0,standard,Guiana (French overseas department) is exempted of VAT.
+2014-01-01,,"FR-GP
+GP",EUR,0.085,standard,Guadeloupe (French overseas department) special VAT rate.
+2014-01-01,,"FR-MF
+MF",EUR,0,standard,Saint Martin (French overseas collectivity) is subjected to France's standard VAT rate.
+2014-01-01,,"FR-MQ
+MQ",EUR,0.085,standard,Martinique (French overseas department) special VAT rate.
+2014-01-01,,"FR-NC
+NC",XPF,0,standard,New Caledonia (French special collectivity) is exempted of VAT.
+2014-01-01,,"FR-PF
+PF",XPF,0,standard,French Polynesia (French overseas collectivity) is exempted of VAT.
+2014-01-01,,"FR-PM
+PM",EUR,0,standard,Saint Pierre and Miquelon (French overseas collectivity) is exempted of VAT.
+2014-01-01,,"FR-RE
+RE",EUR,0.085,standard,Reunion (French overseas department) special VAT rate.
+2014-01-01,,"FR-TF
+TF",EUR,0,standard,French Southern and Antarctic Lands (French overseas territory) is exempted of VAT.
+2014-01-01,,"FR-WF
+WF",XPF,0,standard,Wallis and Futuna (French overseas collectivity) is exempted of VAT.
+2014-01-01,,"FR-YT
+YT",EUR,0,standard,Mayotte (French overseas department) is exempted of VAT.
+2011-01-04,,GG,GBP,0,standard,Guernsey (British Crown dependency) is exempted of VAT.
+2011-01-04,,GI,GIP,0,standard,Gibraltar (British overseas territory) is exempted of VAT.
+1992-01-01,,GL,DKK,0,standard,Greenland (Danish autonomous country) is exempted of VAT.
+2010-07-01,2016-06-01,"GR-34007
+EL-34007",EUR,0.16,standard,Skyros (Greek island) special VAT rate.
+2010-07-01,2016-06-01,"GR-37002
+GR-37003
+GR-37005
+EL-37002
+EL-37003
+EL-37005",EUR,0.16,standard,Northern Sporades (Greek islands) special VAT rate.
+2010-07-01,2016-06-01,"GR-64004
+EL-64004",EUR,0.16,standard,Thasos (Greek island) special VAT rate.
+2010-07-01,2016-06-01,"GR-68002
+EL-68002",EUR,0.16,standard,Samothrace (Greek island) special VAT rate.
+2010-07-01,,"GR-69
+EL-69",EUR,0,standard,Mount Athos (Greek self-governed part) is exempted of VAT.
+2010-07-01,2016-06-01,"GR-81
+EL-81",EUR,0.16,standard,Dodecanese (Greek department) special VAT rate.
+2010-07-01,2016-06-01,"GR-82
+EL-82",EUR,0.16,standard,Cyclades (Greek department) special VAT rate.
+2010-07-01,2016-06-01,"GR-83
+EL-83",EUR,0.16,standard,Lesbos (Greek department) special VAT rate.
+2010-07-01,2016-06-01,"GR-84
+EL-84",EUR,0.16,standard,Samos (Greek department) special VAT rate.
+2010-07-01,2016-06-01,"GR-85
+EL-85",EUR,0.16,standard,Chios (Greek department) special VAT rate.
+2011-01-04,,GS,GBP,0,standard,South Georgia and the South Sandwich Islands (British overseas territory) is exempted of VAT.
+2012-03-01,,HR,HRK,0.25,standard,Croatia (member state) standard VAT rate.
+2009-08-01,2012-03-01,HR,HRK,0.23,standard,
+1998-08-01,2009-08-01,HR,HRK,0.22,standard,
+2012-01-01,,HU,HUF,0.27,standard,Hungary (member state) standard VAT rate.
+2009-07-01,2012-01-01,HU,HUF,0.25,standard,
+2006-01-01,2009-07-01,HU,HUF,0.2,standard,
+1988-01-01,2006-01-01,HU,HUF,0.25,standard,
+2012-01-01,,IE,EUR,0.23,standard,Republic of Ireland (member state) standard VAT rate.
+2010-01-01,2012-01-01,IE,EUR,0.21,standard,
+2008-12-01,2010-01-01,IE,EUR,0.215,standard,
+2002-03-01,2008-12-01,IE,EUR,0.21,standard,
+2001-01-01,2002-03-01,IE,EUR,0.2,standard,
+1991-03-01,2001-01-01,IE,EUR,0.21,standard,
+1990-03-01,1991-03-01,IE,EUR,0.23,standard,
+1986-03-01,1990-03-01,IE,EUR,0.25,standard,
+1983-05-01,1986-03-01,IE,EUR,0.23,standard,
+1983-03-01,1983-05-01,IE,EUR,0.35,standard,
+1982-05-01,1983-03-01,IE,EUR,0.3,standard,
+1980-05-01,1982-05-01,IE,EUR,0.25,standard,
+1976-03-01,1980-05-01,IE,EUR,0.2,standard,
+1973-09-03,1976-03-01,IE,EUR,0.195,standard,
+1972-11-01,1973-09-03,IE,EUR,0.1637,standard,
+2011-01-04,,IO,GBP,0,standard,British Indian Ocean Territory (British overseas territory) is exempted of VAT.
+2013-10-01,,IT,EUR,0.22,standard,Italy (member state) standard VAT rate.
+2011-09-17,2013-10-01,IT,EUR,0.21,standard,
+1997-10-01,2011-09-17,IT,EUR,0.2,standard,
+1988-08-01,1997-10-01,IT,EUR,0.19,standard,
+1982-08-05,1988-08-01,IT,EUR,0.18,standard,
+1981-01-01,1982-08-05,IT,EUR,0.15,standard,
+1980-11-01,1981-01-01,IT,EUR,0.14,standard,
+1980-07-03,1980-11-01,IT,EUR,0.15,standard,
+1977-02-08,1980-07-03,IT,EUR,0.14,standard,
+1973-01-01,1977-02-08,IT,EUR,0.12,standard,
+2013-10-01,,"IT-22060
+CH-6911",CHF,0,standard,Campione (Italian town) is exempted of VAT.
+2013-10-01,,IT-23030,EUR,0,standard,Livigno (Italian town) is exempted of VAT.
+2011-01-04,,JE,GBP,0,standard,Jersey (British Crown dependency) is exempted of VAT.
+2011-01-04,,KY,KYD,0,standard,Cayman Islands (British overseas territory) is exempted of VAT.
+2009-09-01,,LT,EUR,0.21,standard,Lithuania (member state) standard VAT rate.
+2009-01-01,2009-09-01,LT,EUR,0.19,standard,
+1994-05-01,2009-01-01,LT,EUR,0.18,standard,
+2015-01-01,,LU,EUR,0.17,standard,Luxembourg (member state) standard VAT rate.
+1992-01-01,2015-01-01,LU,EUR,0.15,standard,
+1983-07-01,1992-01-01,LU,EUR,0.12,standard,
+1971-01-01,1983-07-01,LU,EUR,0.1,standard,
+1970-01-01,1971-01-01,LU,EUR,0.8,standard,
+2012-07-01,,LV,EUR,0.21,standard,Latvia (member state) standard VAT rate.
+2011-01-01,2012-07-01,LV,EUR,0.22,standard,
+2009-01-01,2011-01-01,LV,EUR,0.21,standard,
+1995-05-01,2009-01-01,LV,EUR,0.18,standard,
+2011-01-04,,MS,XCD,0,standard,Montserrat (British overseas territory) is exempted of VAT.
+2004-01-01,,MT,EUR,0.18,standard,Malta (member state) standard VAT rate.
+1995-01-01,2004-01-01,MT,EUR,0.15,standard,
+2012-10-01,,NL,EUR,0.21,standard,Netherlands (member state) standard VAT rate.
+2001-01-01,2012-10-01,NL,EUR,0.19,standard,
+1992-10-01,2001-01-01,NL,EUR,0.175,standard,
+1989-01-01,1992-10-01,NL,EUR,0.185,standard,
+1986-10-01,1989-01-01,NL,EUR,0.2,standard,
+1984-01-01,1986-10-01,NL,EUR,0.19,standard,
+1976-01-01,1984-01-01,NL,EUR,0.18,standard,
+1973-01-01,1976-01-01,NL,EUR,0.16,standard,
+1971-01-01,1973-01-01,NL,EUR,0.14,standard,
+1969-01-01,1971-01-01,NL,EUR,0.12,standard,
+2012-10-01,,"NL-AW
+AW",AWG,0,standard,Aruba (Dutch country) are exempted of VAT.
+2012-10-01,,"NL-CW
+NL-SX
+CW
+SX",ANG,0,standard,Curacao and Sint Maarten (Dutch countries) are exempted of VAT.
+2012-10-01,,"NL-BQ1
+NL-BQ2
+NL-BQ3
+BQ
+BQ-BO
+BQ-SA
+BQ-SE",USD,0,standard,"Bonaire, Saba and Sint Eustatius (Dutch special municipalities) are exempted of VAT."
+2011-01-01,,PL,PLN,0.23,standard,Poland (member state) standard VAT rate.
+1993-01-08,2011-01-01,PL,PLN,0.22,standard,
+2011-01-04,,PN,NZD,0,standard,Pitcairn Islands (British overseas territory) is exempted of VAT.
+2011-01-01,,PT,EUR,0.23,standard,Portugal (member state) standard VAT rate.
+2010-07-01,2011-01-01,PT,EUR,0.21,standard,
+2008-07-01,2010-07-01,PT,EUR,0.2,standard,
+2005-07-01,2008-07-01,PT,EUR,0.21,standard,
+2002-06-05,2005-07-01,PT,EUR,0.19,standard,
+1995-01-01,2002-06-05,PT,EUR,0.17,standard,
+1992-03-24,1995-01-01,PT,EUR,0.16,standard,
+1988-02-01,1992-03-24,PT,EUR,0.17,standard,
+1986-01-01,1988-02-01,PT,EUR,0.16,standard,
+2011-01-01,,PT-20,EUR,0.18,standard,Azores (Portuguese autonomous region) special VAT rate.
+2011-01-01,,PT-30,EUR,0.22,standard,Madeira (Portuguese autonomous region) special VAT rate.
+2017-01-01,,RO,RON,0.19,standard,Romania (member state) standard VAT rate.
+2016-01-01,2017-01-01,RO,RON,0.2,standard,Romania (member state) standard VAT rate.
+2010-07-01,2016-01-01,RO,RON,0.24,standard,
+2000-01-01,2010-07-01,RO,RON,0.19,standard,
+1998-02-01,2000-01-01,RO,RON,0.22,standard,
+1993-07-01,1998-02-01,RO,RON,0.18,standard,
+1990-07-01,,SE,SEK,0.25,standard,Sweden (member state) standard VAT rate.
+1983-01-01,1990-07-01,SE,SEK,0.2346,standard,
+1981-11-16,1983-01-01,SE,SEK,0.2151,standard,
+1980-09-08,1981-11-16,SE,SEK,0.2346,standard,
+1977-06-01,1980-09-08,SE,SEK,0.2063,standard,
+1971-01-01,1977-06-01,SE,SEK,0.1765,standard,
+1969-01-01,1971-01-01,SE,SEK,0.1111,standard,
+2011-01-04,,"AC
+SH
+SH-AC
+SH-HL",SHP,0,standard,Ascension and Saint Helena (British overseas territory) is exempted of VAT.
+2011-01-04,,"TA
+SH-TA",GBP,0,standard,Tristan da Cunha (British oversea territory) is exempted of VAT.
+2013-07-01,,SI,EUR,0.22,standard,Slovenia (member state) standard VAT rate.
+2002-01-01,2013-07-01,SI,EUR,0.2,standard,
+1999-07-01,2002-01-01,SI,EUR,0.19,standard,
+2011-01-01,,SK,EUR,0.2,standard,Slovakia (member state) standard VAT rate.
+2004-01-01,2011-01-01,SK,EUR,0.19,standard,
+2003-01-01,2004-01-01,SK,EUR,0.2,standard,
+1996-01-01,2003-01-01,SK,EUR,0.23,standard,
+1993-08-01,1996-01-01,SK,EUR,0.25,standard,
+1993-01-01,1993-08-01,SK,EUR,0.23,standard,
+2011-01-04,,TC,USD,0,standard,Turks and Caicos Islands (British overseas territory) is exempted of VAT.
+2011-01-04,,"GB
+UK
+IM",GBP,0.2,standard,"United Kingdom (member state) standard VAT rate.
+Isle of Man (British self-governing dependency) is member of the EU VAT area and subjected to UK's standard VAT rate."
+2010-01-01,2011-01-04,"GB
+UK
+IM",GBP,0.175,standard,
+2008-12-01,2010-01-01,"GB
+UK
+IM",GBP,0.15,standard,
+1991-04-01,2008-12-01,"GB
+UK
+IM",GBP,0.175,standard,
+1979-06-18,1991-04-01,"GB
+UK
+IM",GBP,0.15,standard,
+1974-07-29,1979-06-18,"GB
+UK
+IM",GBP,0.08,standard,
+1973-04-01,1974-07-29,"GB
+UK
+IM",GBP,0.1,standard,
+2011-01-04,,VG,USD,0,standard,British Virgin Islands (British overseas territory) is exempted of VAT.
+2014-01-01,,CP,EUR,0,standard,Clipperton Island (French overseas possession) is exempted of VAT.
+2019-11-15,,CH,CHF,0.077,standard,Switzerland standard VAT (added manually)
+2019-11-15,,MC,EUR,0.196,standard,Monaco standard VAT (added manually)
+2019-11-15,,FR,EUR,0.2,standard,France standard VAT (added manually)
+2019-11-15,,GR,EUR,0.24,standard,Greece standard VAT (added manually)
+2019-11-15,,GB,EUR,0.2,standard,UK standard VAT (added manually)
+2019-12-17,,AD,EUR,0.045,standard,Andorra standard VAT (added manually)
+2019-12-17,,TK,EUR,0.18,standard,Turkey standard VAT (added manually)
+2019-12-17,,IS,EUR,0.24,standard,Iceland standard VAT (added manually)
+2019-12-17,,FX,EUR,0.20,standard,France metropolitan standard VAT (added manually)
+2020-01-04,,CY,EUR,0.19,standard,Cyprus standard VAT (added manually)
+2019-01-04,,IL,EUR,0.23,standard,Ireland standard VAT (added manually)
+2019-01-04,,LI,EUR,0.077,standard,Liechtenstein standard VAT (added manually)
diff --git a/scripts/uncloud b/scripts/uncloud
deleted file mode 100755
index 28d8344..0000000
--- a/scripts/uncloud
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/env python3
-import argparse
-import logging
-import importlib
-import multiprocessing as mp
-import sys
-
-from logging.handlers import SysLogHandler
-from uncloud.configure.main import configure_parser
-
-from uncloud import UncloudException
-
-def exception_hook(exc_type, exc_value, exc_traceback):
- logging.getLogger(__name__).error(
- 'Uncaught exception',
- exc_info=(exc_type, exc_value, exc_traceback)
- )
-
-
-sys.excepthook = exception_hook
-
-
-if __name__ == '__main__':
- # Setting up root logger
- logger = logging.getLogger()
-
- logger.setLevel(logging.DEBUG)
-
- parent_parser = argparse.ArgumentParser(add_help=False)
- parent_parser.add_argument("--debug", "-d", action='store_true')
-
- arg_parser = argparse.ArgumentParser()
-
- subparsers = arg_parser.add_subparsers(dest="command")
-
- api_parser = subparsers.add_parser("api", parents=[parent_parser])
- api_parser.add_argument("--port", "-p")
-
- host_parser = subparsers.add_parser("host")
- host_parser.add_argument("--hostname", required=True)
-
- scheduler_parser = subparsers.add_parser("scheduler")
- filescanner_parser = subparsers.add_parser("filescanner")
- imagescanner_parser = subparsers.add_parser("imagescanner")
- metadata_parser = subparsers.add_parser("metadata")
- config_parser = subparsers.add_parser("configure")
-
- configure_parser(config_parser)
- args = arg_parser.parse_args()
-
- if not args.command:
- arg_parser.print_help()
- else:
-
- # if we start etcd in seperate process with default settings
- # i.e inheriting few things from parent process etcd3 module
- # errors out, so the following command configure multiprocessing
- # module to not inherit anything from parent.
- mp.set_start_method('spawn')
-
- arguments = vars(args)
- try:
- name = arguments.pop('command')
- mod = importlib.import_module("uncloud.{}.main".format(name))
- main = getattr(mod, "main")
- main(**arguments)
- except UncloudException as err:
- logger.error(err)
- except Exception as err:
- logger.exception(err)
diff --git a/uncloud/.gitignore b/uncloud/.gitignore
new file mode 100644
index 0000000..b03e0a5
--- /dev/null
+++ b/uncloud/.gitignore
@@ -0,0 +1,2 @@
+local_settings.py
+ldap_max_uid_file
\ No newline at end of file
diff --git a/uncloud/__init__.py b/uncloud/__init__.py
index 2920f47..3ce2d95 100644
--- a/uncloud/__init__.py
+++ b/uncloud/__init__.py
@@ -1,2 +1,253 @@
-class UncloudException(Exception):
- pass
+from django.utils.translation import gettext_lazy as _
+import decimal
+
+# Define DecimalField properties, used to represent amounts of money.
+AMOUNT_MAX_DIGITS=10
+AMOUNT_DECIMALS=2
+
+decimal.getcontext().prec = AMOUNT_DECIMALS
+
+# http://xml.coverpages.org/country3166.html
+COUNTRIES = (
+ ('AD', _('Andorra')),
+ ('AE', _('United Arab Emirates')),
+ ('AF', _('Afghanistan')),
+ ('AG', _('Antigua & Barbuda')),
+ ('AI', _('Anguilla')),
+ ('AL', _('Albania')),
+ ('AM', _('Armenia')),
+ ('AN', _('Netherlands Antilles')),
+ ('AO', _('Angola')),
+ ('AQ', _('Antarctica')),
+ ('AR', _('Argentina')),
+ ('AS', _('American Samoa')),
+ ('AT', _('Austria')),
+ ('AU', _('Australia')),
+ ('AW', _('Aruba')),
+ ('AZ', _('Azerbaijan')),
+ ('BA', _('Bosnia and Herzegovina')),
+ ('BB', _('Barbados')),
+ ('BD', _('Bangladesh')),
+ ('BE', _('Belgium')),
+ ('BF', _('Burkina Faso')),
+ ('BG', _('Bulgaria')),
+ ('BH', _('Bahrain')),
+ ('BI', _('Burundi')),
+ ('BJ', _('Benin')),
+ ('BM', _('Bermuda')),
+ ('BN', _('Brunei Darussalam')),
+ ('BO', _('Bolivia')),
+ ('BR', _('Brazil')),
+ ('BS', _('Bahama')),
+ ('BT', _('Bhutan')),
+ ('BV', _('Bouvet Island')),
+ ('BW', _('Botswana')),
+ ('BY', _('Belarus')),
+ ('BZ', _('Belize')),
+ ('CA', _('Canada')),
+ ('CC', _('Cocos (Keeling) Islands')),
+ ('CF', _('Central African Republic')),
+ ('CG', _('Congo')),
+ ('CH', _('Switzerland')),
+ ('CI', _('Ivory Coast')),
+ ('CK', _('Cook Iislands')),
+ ('CL', _('Chile')),
+ ('CM', _('Cameroon')),
+ ('CN', _('China')),
+ ('CO', _('Colombia')),
+ ('CR', _('Costa Rica')),
+ ('CU', _('Cuba')),
+ ('CV', _('Cape Verde')),
+ ('CX', _('Christmas Island')),
+ ('CY', _('Cyprus')),
+ ('CZ', _('Czech Republic')),
+ ('DE', _('Germany')),
+ ('DJ', _('Djibouti')),
+ ('DK', _('Denmark')),
+ ('DM', _('Dominica')),
+ ('DO', _('Dominican Republic')),
+ ('DZ', _('Algeria')),
+ ('EC', _('Ecuador')),
+ ('EE', _('Estonia')),
+ ('EG', _('Egypt')),
+ ('EH', _('Western Sahara')),
+ ('ER', _('Eritrea')),
+ ('ES', _('Spain')),
+ ('ET', _('Ethiopia')),
+ ('FI', _('Finland')),
+ ('FJ', _('Fiji')),
+ ('FK', _('Falkland Islands (Malvinas)')),
+ ('FM', _('Micronesia')),
+ ('FO', _('Faroe Islands')),
+ ('FR', _('France')),
+ ('FX', _('France, Metropolitan')),
+ ('GA', _('Gabon')),
+ ('GB', _('United Kingdom (Great Britain)')),
+ ('GD', _('Grenada')),
+ ('GE', _('Georgia')),
+ ('GF', _('French Guiana')),
+ ('GH', _('Ghana')),
+ ('GI', _('Gibraltar')),
+ ('GL', _('Greenland')),
+ ('GM', _('Gambia')),
+ ('GN', _('Guinea')),
+ ('GP', _('Guadeloupe')),
+ ('GQ', _('Equatorial Guinea')),
+ ('GR', _('Greece')),
+ ('GS', _('South Georgia and the South Sandwich Islands')),
+ ('GT', _('Guatemala')),
+ ('GU', _('Guam')),
+ ('GW', _('Guinea-Bissau')),
+ ('GY', _('Guyana')),
+ ('HK', _('Hong Kong')),
+ ('HM', _('Heard & McDonald Islands')),
+ ('HN', _('Honduras')),
+ ('HR', _('Croatia')),
+ ('HT', _('Haiti')),
+ ('HU', _('Hungary')),
+ ('ID', _('Indonesia')),
+ ('IE', _('Ireland')),
+ ('IL', _('Israel')),
+ ('IN', _('India')),
+ ('IO', _('British Indian Ocean Territory')),
+ ('IQ', _('Iraq')),
+ ('IR', _('Islamic Republic of Iran')),
+ ('IS', _('Iceland')),
+ ('IT', _('Italy')),
+ ('JM', _('Jamaica')),
+ ('JO', _('Jordan')),
+ ('JP', _('Japan')),
+ ('KE', _('Kenya')),
+ ('KG', _('Kyrgyzstan')),
+ ('KH', _('Cambodia')),
+ ('KI', _('Kiribati')),
+ ('KM', _('Comoros')),
+ ('KN', _('St. Kitts and Nevis')),
+ ('KP', _('Korea, Democratic People\'s Republic of')),
+ ('KR', _('Korea, Republic of')),
+ ('KW', _('Kuwait')),
+ ('KY', _('Cayman Islands')),
+ ('KZ', _('Kazakhstan')),
+ ('LA', _('Lao People\'s Democratic Republic')),
+ ('LB', _('Lebanon')),
+ ('LC', _('Saint Lucia')),
+ ('LI', _('Liechtenstein')),
+ ('LK', _('Sri Lanka')),
+ ('LR', _('Liberia')),
+ ('LS', _('Lesotho')),
+ ('LT', _('Lithuania')),
+ ('LU', _('Luxembourg')),
+ ('LV', _('Latvia')),
+ ('LY', _('Libyan Arab Jamahiriya')),
+ ('MA', _('Morocco')),
+ ('MC', _('Monaco')),
+ ('MD', _('Moldova, Republic of')),
+ ('MG', _('Madagascar')),
+ ('MH', _('Marshall Islands')),
+ ('ML', _('Mali')),
+ ('MN', _('Mongolia')),
+ ('MM', _('Myanmar')),
+ ('MO', _('Macau')),
+ ('MP', _('Northern Mariana Islands')),
+ ('MQ', _('Martinique')),
+ ('MR', _('Mauritania')),
+ ('MS', _('Monserrat')),
+ ('MT', _('Malta')),
+ ('MU', _('Mauritius')),
+ ('MV', _('Maldives')),
+ ('MW', _('Malawi')),
+ ('MX', _('Mexico')),
+ ('MY', _('Malaysia')),
+ ('MZ', _('Mozambique')),
+ ('NA', _('Namibia')),
+ ('NC', _('New Caledonia')),
+ ('NE', _('Niger')),
+ ('NF', _('Norfolk Island')),
+ ('NG', _('Nigeria')),
+ ('NI', _('Nicaragua')),
+ ('NL', _('Netherlands')),
+ ('NO', _('Norway')),
+ ('NP', _('Nepal')),
+ ('NR', _('Nauru')),
+ ('NU', _('Niue')),
+ ('NZ', _('New Zealand')),
+ ('OM', _('Oman')),
+ ('PA', _('Panama')),
+ ('PE', _('Peru')),
+ ('PF', _('French Polynesia')),
+ ('PG', _('Papua New Guinea')),
+ ('PH', _('Philippines')),
+ ('PK', _('Pakistan')),
+ ('PL', _('Poland')),
+ ('PM', _('St. Pierre & Miquelon')),
+ ('PN', _('Pitcairn')),
+ ('PR', _('Puerto Rico')),
+ ('PT', _('Portugal')),
+ ('PW', _('Palau')),
+ ('PY', _('Paraguay')),
+ ('QA', _('Qatar')),
+ ('RE', _('Reunion')),
+ ('RO', _('Romania')),
+ ('RU', _('Russian Federation')),
+ ('RW', _('Rwanda')),
+ ('SA', _('Saudi Arabia')),
+ ('SB', _('Solomon Islands')),
+ ('SC', _('Seychelles')),
+ ('SD', _('Sudan')),
+ ('SE', _('Sweden')),
+ ('SG', _('Singapore')),
+ ('SH', _('St. Helena')),
+ ('SI', _('Slovenia')),
+ ('SJ', _('Svalbard & Jan Mayen Islands')),
+ ('SK', _('Slovakia')),
+ ('SL', _('Sierra Leone')),
+ ('SM', _('San Marino')),
+ ('SN', _('Senegal')),
+ ('SO', _('Somalia')),
+ ('SR', _('Suriname')),
+ ('ST', _('Sao Tome & Principe')),
+ ('SV', _('El Salvador')),
+ ('SY', _('Syrian Arab Republic')),
+ ('SZ', _('Swaziland')),
+ ('TC', _('Turks & Caicos Islands')),
+ ('TD', _('Chad')),
+ ('TF', _('French Southern Territories')),
+ ('TG', _('Togo')),
+ ('TH', _('Thailand')),
+ ('TJ', _('Tajikistan')),
+ ('TK', _('Tokelau')),
+ ('TM', _('Turkmenistan')),
+ ('TN', _('Tunisia')),
+ ('TO', _('Tonga')),
+ ('TP', _('East Timor')),
+ ('TR', _('Turkey')),
+ ('TT', _('Trinidad & Tobago')),
+ ('TV', _('Tuvalu')),
+ ('TW', _('Taiwan, Province of China')),
+ ('TZ', _('Tanzania, United Republic of')),
+ ('UA', _('Ukraine')),
+ ('UG', _('Uganda')),
+ ('UM', _('United States Minor Outlying Islands')),
+ ('US', _('United States of America')),
+ ('UY', _('Uruguay')),
+ ('UZ', _('Uzbekistan')),
+ ('VA', _('Vatican City State (Holy See)')),
+ ('VC', _('St. Vincent & the Grenadines')),
+ ('VE', _('Venezuela')),
+ ('VG', _('British Virgin Islands')),
+ ('VI', _('United States Virgin Islands')),
+ ('VN', _('Viet Nam')),
+ ('VU', _('Vanuatu')),
+ ('WF', _('Wallis & Futuna Islands')),
+ ('WS', _('Samoa')),
+ ('YE', _('Yemen')),
+ ('YT', _('Mayotte')),
+ ('YU', _('Yugoslavia')),
+ ('ZA', _('South Africa')),
+ ('ZM', _('Zambia')),
+ ('ZR', _('Zaire')),
+ ('ZW', _('Zimbabwe')),
+)
+
+
+__all__ = ()
diff --git a/uncloud/admin.py b/uncloud/admin.py
new file mode 100644
index 0000000..38f8cce
--- /dev/null
+++ b/uncloud/admin.py
@@ -0,0 +1,6 @@
+from django.contrib import admin
+
+from .models import *
+
+for m in [ UncloudProvider, UncloudNetwork ]:
+ admin.site.register(m)
diff --git a/uncloud/api/create_image_store.py b/uncloud/api/create_image_store.py
deleted file mode 100755
index 73b92f1..0000000
--- a/uncloud/api/create_image_store.py
+++ /dev/null
@@ -1,20 +0,0 @@
-import json
-import os
-
-from uuid import uuid4
-
-from uncloud.shared import shared
-from uncloud.settings import settings
-
-data = {
- "is_public": True,
- "type": "ceph",
- "name": "images",
- "description": "first ever public image-store",
- "attributes": {"list": [], "key": [], "pool": "images"},
-}
-
-shared.etcd_client.put(
- os.path.join(settings["etcd"]["image_store_prefix"], uuid4().hex),
- json.dumps(data),
-)
diff --git a/uncloud/asgi.py b/uncloud/asgi.py
new file mode 100644
index 0000000..2b5a7a3
--- /dev/null
+++ b/uncloud/asgi.py
@@ -0,0 +1,16 @@
+"""
+ASGI config for uncloud project.
+
+It exposes the ASGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
+"""
+
+import os
+
+from django.core.asgi import get_asgi_application
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'uncloud.settings')
+
+application = get_asgi_application()
diff --git a/uncloud/common/etcd_wrapper.py b/uncloud/common/etcd_wrapper.py
deleted file mode 100644
index 6a979ba..0000000
--- a/uncloud/common/etcd_wrapper.py
+++ /dev/null
@@ -1,118 +0,0 @@
-import etcd3
-import json
-import queue
-import copy
-from uncloud import UncloudException
-
-from collections import namedtuple
-from functools import wraps
-
-from . import logger
-
-PseudoEtcdMeta = namedtuple("PseudoEtcdMeta", ["key"])
-
-
-class EtcdEntry:
- # key: str
- # value: str
-
- def __init__(self, meta, value, value_in_json=False):
- self.key = meta.key.decode("utf-8")
- self.value = value.decode("utf-8")
-
- if value_in_json:
- self.value = json.loads(self.value)
-
-
-def readable_errors(func):
- @wraps(func)
- def wrapper(*args, **kwargs):
- try:
- return func(*args, **kwargs)
- except etcd3.exceptions.ConnectionFailedError as err:
- raise UncloudException(
- "Cannot connect to etcd: is etcd running as configured in uncloud.conf?"
- )
- except etcd3.exceptions.ConnectionTimeoutError as err:
- raise etcd3.exceptions.ConnectionTimeoutError(
- "etcd connection timeout."
- ) from err
- except Exception:
- logger.exception(
- "Some etcd error occured. See syslog for details."
- )
-
- return wrapper
-
-
-class Etcd3Wrapper:
- @readable_errors
- def __init__(self, *args, **kwargs):
- self.client = etcd3.client(*args, **kwargs)
-
- @readable_errors
- def get(self, *args, value_in_json=False, **kwargs):
- _value, _key = self.client.get(*args, **kwargs)
- if _key is None or _value is None:
- return None
- return EtcdEntry(_key, _value, value_in_json=value_in_json)
-
- @readable_errors
- def put(self, *args, value_in_json=False, **kwargs):
- _key, _value = args
- if value_in_json:
- _value = json.dumps(_value)
-
- if not isinstance(_key, str):
- _key = _key.decode("utf-8")
-
- return self.client.put(_key, _value, **kwargs)
-
- @readable_errors
- def get_prefix(self, *args, value_in_json=False, **kwargs):
- r = self.client.get_prefix(*args, **kwargs)
- for entry in r:
- e = EtcdEntry(*entry[::-1], value_in_json=value_in_json)
- if e.value:
- yield e
-
- @readable_errors
- def watch_prefix(self, key, timeout=0, value_in_json=False):
- timeout_event = EtcdEntry(
- PseudoEtcdMeta(key=b"TIMEOUT"),
- value=str.encode(
- json.dumps({"status": "TIMEOUT", "type": "TIMEOUT"})
- ),
- value_in_json=value_in_json,
- )
-
- event_queue = queue.Queue()
-
- def add_event_to_queue(event):
- if hasattr(event, "events"):
- for e in event.events:
- if e.value:
- event_queue.put(
- EtcdEntry(
- e, e.value, value_in_json=value_in_json
- )
- )
-
- self.client.add_watch_prefix_callback(key, add_event_to_queue)
-
- while True:
- try:
- while True:
- v = event_queue.get(timeout=timeout)
- yield v
- except queue.Empty:
- event_queue.put(copy.deepcopy(timeout_event))
-
-
-class PsuedoEtcdEntry(EtcdEntry):
- def __init__(self, key, value, value_in_json=False):
- super().__init__(
- PseudoEtcdMeta(key=key.encode("utf-8")),
- value,
- value_in_json=value_in_json,
- )
diff --git a/uncloud/configure/main.py b/uncloud/configure/main.py
deleted file mode 100644
index a9b4901..0000000
--- a/uncloud/configure/main.py
+++ /dev/null
@@ -1,79 +0,0 @@
-import os
-
-from uncloud.settings import settings
-from uncloud.shared import shared
-
-
-def update_config(section, kwargs):
- uncloud_config = shared.etcd_client.get(
- settings.config_key, value_in_json=True
- )
- if not uncloud_config:
- uncloud_config = {}
- else:
- uncloud_config = uncloud_config.value
-
- uncloud_config[section] = kwargs
- shared.etcd_client.put(
- settings.config_key, uncloud_config, value_in_json=True
- )
-
-
-def configure_parser(parser):
- configure_subparsers = parser.add_subparsers(dest="subcommand")
-
- otp_parser = configure_subparsers.add_parser("otp")
- otp_parser.add_argument(
- "--verification-controller-url", required=True, metavar="URL"
- )
- otp_parser.add_argument(
- "--auth-name", required=True, metavar="OTP-NAME"
- )
- otp_parser.add_argument(
- "--auth-realm", required=True, metavar="OTP-REALM"
- )
- otp_parser.add_argument(
- "--auth-seed", required=True, metavar="OTP-SEED"
- )
-
- network_parser = configure_subparsers.add_parser("network")
- network_parser.add_argument(
- "--prefix-length", required=True, type=int
- )
- network_parser.add_argument("--prefix", required=True)
- network_parser.add_argument("--vxlan-phy-dev", required=True)
-
- netbox_parser = configure_subparsers.add_parser("netbox")
- netbox_parser.add_argument("--url", required=True)
- netbox_parser.add_argument("--token", required=True)
-
- ssh_parser = configure_subparsers.add_parser("ssh")
- ssh_parser.add_argument("--username", default="root")
- ssh_parser.add_argument(
- "--private-key-path",
- default=os.path.expanduser("~/.ssh/id_rsa"),
- )
-
- storage_parser = configure_subparsers.add_parser("storage")
- storage_parser.add_argument("--file-dir", required=True)
- storage_parser_subparsers = storage_parser.add_subparsers(
- dest="storage_backend"
- )
-
- filesystem_storage_parser = storage_parser_subparsers.add_parser(
- "filesystem"
- )
- filesystem_storage_parser.add_argument("--vm-dir", required=True)
- filesystem_storage_parser.add_argument("--image-dir", required=True)
-
- ceph_storage_parser = storage_parser_subparsers.add_parser("ceph")
- ceph_storage_parser.add_argument("--ceph-vm-pool", required=True)
- ceph_storage_parser.add_argument("--ceph-image-pool", required=True)
-
-
-def main(**kwargs):
- subcommand = kwargs.pop("subcommand")
- if not subcommand:
- pass
- else:
- update_config(subcommand, kwargs)
diff --git a/uncloud/docs/source/hacking.rst b/uncloud/docs/source/hacking.rst
deleted file mode 100644
index 2df42a7..0000000
--- a/uncloud/docs/source/hacking.rst
+++ /dev/null
@@ -1,17 +0,0 @@
-Hacking
-=======
-How to hack on the code.
-
-[ to be done by Balazs:
-
-* make nice
-* indent with shell script mode
-
-]
-
-* git clone the repo
-* cd to the repo
-* Setup your venv: python -m venv venv
-* . ./venv/bin/activate # you need the leading dot for sourcing!
-* Run ./bin/ucloud-run-reinstall - it should print you an error
- message on how to use ucloud
diff --git a/uncloud/filescanner/main.py b/uncloud/filescanner/main.py
deleted file mode 100755
index 7ce8654..0000000
--- a/uncloud/filescanner/main.py
+++ /dev/null
@@ -1,89 +0,0 @@
-import glob
-import os
-import pathlib
-import subprocess as sp
-import time
-
-from uuid import uuid4
-
-from . import logger
-from uncloud.settings import settings
-from uncloud.shared import shared
-
-
-def sha512sum(file: str):
- """Use sha512sum utility to compute sha512 sum of arg:file
-
- IF arg:file does not exists:
- raise FileNotFoundError exception
- ELSE IF sum successfully computer:
- return computed sha512 sum
- ELSE:
- return None
- """
- if not isinstance(file, str):
- raise TypeError
- try:
- output = sp.check_output(["sha512sum", file], stderr=sp.PIPE)
- except sp.CalledProcessError as e:
- error = e.stderr.decode("utf-8")
- if "No such file or directory" in error:
- raise FileNotFoundError from None
- else:
- output = output.decode("utf-8").strip()
- output = output.split(" ")
- return output[0]
- return None
-
-
-def track_file(file, base_dir):
- file_id = uuid4()
-
- # Get Username
- owner = pathlib.Path(file).parts[len(pathlib.Path(base_dir).parts)]
-
- # Get Creation Date of File
- # Here, we are assuming that ctime is creation time
- # which is mostly not true.
- creation_date = time.ctime(os.stat(file).st_ctime)
-
- file_path = pathlib.Path(file).parts[-1]
-
- # Create Entry
- entry_key = os.path.join(
- settings["etcd"]["file_prefix"], str(file_id)
- )
- entry_value = {
- "filename": file_path,
- "owner": owner,
- "sha512sum": sha512sum(file),
- "creation_date": creation_date,
- "size": os.path.getsize(file),
- }
-
- logger.info("Tracking %s", file)
-
- shared.etcd_client.put(entry_key, entry_value, value_in_json=True)
- os.setxattr(file, "user.utracked", b"True")
-
-
-def main():
- base_dir = settings["storage"]["file_dir"]
-
- # Recursively Get All Files and Folder below BASE_DIR
- files = glob.glob("{}/**".format(base_dir), recursive=True)
-
- # Retain only Files
- files = [file for file in files if os.path.isfile(file)]
-
- untracked_files = []
- for file in files:
- try:
- os.getxattr(file, "user.utracked")
- except OSError:
- track_file(file, base_dir)
- untracked_files.append(file)
-
-
-if __name__ == "__main__":
- main()
diff --git a/uncloud/forms.py b/uncloud/forms.py
new file mode 100644
index 0000000..153a49a
--- /dev/null
+++ b/uncloud/forms.py
@@ -0,0 +1,8 @@
+from django import forms
+from django.contrib.auth.models import User
+
+
+class UserDeleteForm(forms.ModelForm):
+ class Meta:
+ model = User
+ fields = []
diff --git a/uncloud/host/main.py b/uncloud/host/main.py
deleted file mode 100755
index d1e7c9a..0000000
--- a/uncloud/host/main.py
+++ /dev/null
@@ -1,116 +0,0 @@
-import argparse
-import multiprocessing as mp
-import time
-from uuid import uuid4
-
-from uncloud.common.request import RequestEntry, RequestType
-from uncloud.shared import shared
-from uncloud.settings import settings
-from uncloud.common.vm import VMStatus
-from uncloud.vmm import VMM
-from os.path import join as join_path
-
-from . import virtualmachine, logger
-
-
-def update_heartbeat(hostname):
- """Update Last HeartBeat Time for :param hostname: in etcd"""
- host_pool = shared.host_pool
- this_host = next(
- filter(lambda h: h.hostname == hostname, host_pool.hosts), None
- )
- while True:
- this_host.update_heartbeat()
- host_pool.put(this_host)
- time.sleep(10)
-
-
-def maintenance(host):
- vmm = VMM()
- running_vms = vmm.discover()
- for vm_uuid in running_vms:
- if vmm.is_running(vm_uuid) and vmm.get_status(vm_uuid) == "running":
- logger.debug('VM {} is running on {}'.format(vm_uuid, host))
- vm = shared.vm_pool.get(
- join_path(settings["etcd"]["vm_prefix"], vm_uuid)
- )
- vm.status = VMStatus.running
- vm.vnc_socket = vmm.get_vnc(vm_uuid)
- vm.hostname = host
- shared.vm_pool.put(vm)
-
-
-def main(hostname):
- host_pool = shared.host_pool
- host = next(filter(lambda h: h.hostname == hostname, host_pool.hosts), None)
-
- # Does not yet exist, create it
- if not host:
- host_key = join_path(
- settings["etcd"]["host_prefix"], uuid4().hex
- )
- host_entry = {
- "specs": "",
- "hostname": hostname,
- "status": "DEAD",
- "last_heartbeat": "",
- }
- shared.etcd_client.put(
- host_key, host_entry, value_in_json=True
- )
-
- try:
- heartbeat_updating_process = mp.Process(target=update_heartbeat, args=(hostname,))
- heartbeat_updating_process.start()
- except Exception as e:
- raise Exception("uncloud-host heartbeat updating mechanism is not working") from e
-
- for events_iterator in [
- shared.etcd_client.get_prefix(settings["etcd"]["request_prefix"], value_in_json=True),
- shared.etcd_client.watch_prefix(settings["etcd"]["request_prefix"], timeout=10, value_in_json=True)
- ]:
- for request_event in events_iterator:
- request_event = RequestEntry(request_event)
-
- if request_event.type == "TIMEOUT":
- maintenance(host.key)
-
- elif request_event.hostname == host.key:
- logger.debug("VM Request: %s on Host %s", request_event, host.hostname)
- shared.request_pool.client.client.delete(request_event.key)
- vm_entry = shared.etcd_client.get(
- join_path(settings["etcd"]["vm_prefix"], request_event.uuid)
- )
- logger.debug("VM hostname: {}".format(vm_entry.value))
- vm = virtualmachine.VM(vm_entry)
- if request_event.type == RequestType.StartVM:
- vm.start()
-
- elif request_event.type == RequestType.StopVM:
- vm.stop()
-
- elif request_event.type == RequestType.DeleteVM:
- vm.delete()
-
- elif request_event.type == RequestType.InitVMMigration:
- vm.start(destination_host_key=host.key)
-
- elif request_event.type == RequestType.TransferVM:
- destination_host = host_pool.get(request_event.destination_host_key)
- if destination_host:
- vm.migrate(
- destination_host=destination_host.hostname,
- destination_sock_path=request_event.destination_sock_path,
- )
- else:
- logger.error("Host %s not found!", request_event.destination_host_key)
-
-
-if __name__ == "__main__":
- argparser = argparse.ArgumentParser()
- argparser.add_argument(
- "hostname", help="Name of this host. e.g uncloud1.ungleich.ch"
- )
- args = argparser.parse_args()
- mp.set_start_method("spawn")
- main(args.hostname)
diff --git a/uncloud/management/commands/db-add-defaults.py b/uncloud/management/commands/db-add-defaults.py
new file mode 100644
index 0000000..605c8f5
--- /dev/null
+++ b/uncloud/management/commands/db-add-defaults.py
@@ -0,0 +1,43 @@
+import random
+import string
+
+from django.core.management.base import BaseCommand
+from django.core.exceptions import ObjectDoesNotExist
+from django.contrib.auth import get_user_model
+from django.conf import settings
+
+from uncloud_pay.models import BillingAddress, RecurringPeriod, Product
+from uncloud.models import UncloudProvider, UncloudNetwork
+
+
+class Command(BaseCommand):
+ help = 'Add standard uncloud values'
+
+ def add_arguments(self, parser):
+ pass
+
+ def handle(self, *args, **options):
+ # Order matters, objects can be dependent on each other
+
+ admin_username="uncloud-admin"
+ pw_length = 32
+
+ # Only set password if the user did not exist before
+ try:
+ admin_user = get_user_model().objects.get(username=settings.UNCLOUD_ADMIN_NAME)
+ except ObjectDoesNotExist:
+ random_password = ''.join(random.SystemRandom().choice(string.ascii_lowercase + string.digits) for _ in range(pw_length))
+
+ admin_user = get_user_model().objects.create_user(username=settings.UNCLOUD_ADMIN_NAME, password=random_password)
+ admin_user.is_superuser=True
+ admin_user.is_staff=True
+ admin_user.save()
+
+ print(f"Created admin user '{admin_username}' with password '{random_password}'")
+
+ BillingAddress.populate_db_defaults()
+ RecurringPeriod.populate_db_defaults()
+ Product.populate_db_defaults()
+
+ UncloudNetwork.populate_db_defaults()
+ UncloudProvider.populate_db_defaults()
diff --git a/uncloud/management/commands/uncloud.py b/uncloud/management/commands/uncloud.py
new file mode 100644
index 0000000..bd47c6b
--- /dev/null
+++ b/uncloud/management/commands/uncloud.py
@@ -0,0 +1,28 @@
+import sys
+from datetime import datetime
+
+from django.core.management.base import BaseCommand
+
+from django.contrib.auth import get_user_model
+
+from opennebula.models import VM as VMModel
+from uncloud_vm.models import VMHost, VMProduct, VMNetworkCard, VMDiskImageProduct, VMDiskProduct, VMCluster
+
+import logging
+log = logging.getLogger(__name__)
+
+
+class Command(BaseCommand):
+ help = 'General uncloud commands'
+
+ def add_arguments(self, parser):
+ parser.add_argument('--bootstrap', action='store_true', help='Bootstrap a typical uncloud installation')
+
+ def handle(self, *args, **options):
+
+ if options['bootstrap']:
+ self.bootstrap()
+
+ def bootstrap(self):
+ default_cluster = VMCluster.objects.get_or_create(name="default")
+# local_host =
diff --git a/uncloud/migrations/0001_initial.py b/uncloud/migrations/0001_initial.py
new file mode 100644
index 0000000..10d1144
--- /dev/null
+++ b/uncloud/migrations/0001_initial.py
@@ -0,0 +1,46 @@
+# Generated by Django 3.1 on 2020-12-13 10:38
+
+import django.core.validators
+from django.db import migrations, models
+import django.db.models.deletion
+import uncloud.models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='UncloudNetwork',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('network_address', models.GenericIPAddressField(unique=True)),
+ ('network_mask', models.IntegerField(validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(128)])),
+ ('description', models.CharField(max_length=256)),
+ ],
+ ),
+ migrations.CreateModel(
+ name='UncloudProvider',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('full_name', models.CharField(max_length=256)),
+ ('organization', models.CharField(blank=True, max_length=256, null=True)),
+ ('street', models.CharField(max_length=256)),
+ ('city', models.CharField(max_length=256)),
+ ('postal_code', models.CharField(max_length=64)),
+ ('country', uncloud.models.CountryField(blank=True, choices=[('AD', 'Andorra'), ('AE', 'United Arab Emirates'), ('AF', 'Afghanistan'), ('AG', 'Antigua & Barbuda'), ('AI', 'Anguilla'), ('AL', 'Albania'), ('AM', 'Armenia'), ('AN', 'Netherlands Antilles'), ('AO', 'Angola'), ('AQ', 'Antarctica'), ('AR', 'Argentina'), ('AS', 'American Samoa'), ('AT', 'Austria'), ('AU', 'Australia'), ('AW', 'Aruba'), ('AZ', 'Azerbaijan'), ('BA', 'Bosnia and Herzegovina'), ('BB', 'Barbados'), ('BD', 'Bangladesh'), ('BE', 'Belgium'), ('BF', 'Burkina Faso'), ('BG', 'Bulgaria'), ('BH', 'Bahrain'), ('BI', 'Burundi'), ('BJ', 'Benin'), ('BM', 'Bermuda'), ('BN', 'Brunei Darussalam'), ('BO', 'Bolivia'), ('BR', 'Brazil'), ('BS', 'Bahama'), ('BT', 'Bhutan'), ('BV', 'Bouvet Island'), ('BW', 'Botswana'), ('BY', 'Belarus'), ('BZ', 'Belize'), ('CA', 'Canada'), ('CC', 'Cocos (Keeling) Islands'), ('CF', 'Central African Republic'), ('CG', 'Congo'), ('CH', 'Switzerland'), ('CI', 'Ivory Coast'), ('CK', 'Cook Iislands'), ('CL', 'Chile'), ('CM', 'Cameroon'), ('CN', 'China'), ('CO', 'Colombia'), ('CR', 'Costa Rica'), ('CU', 'Cuba'), ('CV', 'Cape Verde'), ('CX', 'Christmas Island'), ('CY', 'Cyprus'), ('CZ', 'Czech Republic'), ('DE', 'Germany'), ('DJ', 'Djibouti'), ('DK', 'Denmark'), ('DM', 'Dominica'), ('DO', 'Dominican Republic'), ('DZ', 'Algeria'), ('EC', 'Ecuador'), ('EE', 'Estonia'), ('EG', 'Egypt'), ('EH', 'Western Sahara'), ('ER', 'Eritrea'), ('ES', 'Spain'), ('ET', 'Ethiopia'), ('FI', 'Finland'), ('FJ', 'Fiji'), ('FK', 'Falkland Islands (Malvinas)'), ('FM', 'Micronesia'), ('FO', 'Faroe Islands'), ('FR', 'France'), ('FX', 'France, Metropolitan'), ('GA', 'Gabon'), ('GB', 'United Kingdom (Great Britain)'), ('GD', 'Grenada'), ('GE', 'Georgia'), ('GF', 'French Guiana'), ('GH', 'Ghana'), ('GI', 'Gibraltar'), ('GL', 'Greenland'), ('GM', 'Gambia'), ('GN', 'Guinea'), ('GP', 'Guadeloupe'), ('GQ', 'Equatorial Guinea'), ('GR', 'Greece'), ('GS', 'South Georgia and the South Sandwich Islands'), ('GT', 'Guatemala'), ('GU', 'Guam'), ('GW', 'Guinea-Bissau'), ('GY', 'Guyana'), ('HK', 'Hong Kong'), ('HM', 'Heard & McDonald Islands'), ('HN', 'Honduras'), ('HR', 'Croatia'), ('HT', 'Haiti'), ('HU', 'Hungary'), ('ID', 'Indonesia'), ('IE', 'Ireland'), ('IL', 'Israel'), ('IN', 'India'), ('IO', 'British Indian Ocean Territory'), ('IQ', 'Iraq'), ('IR', 'Islamic Republic of Iran'), ('IS', 'Iceland'), ('IT', 'Italy'), ('JM', 'Jamaica'), ('JO', 'Jordan'), ('JP', 'Japan'), ('KE', 'Kenya'), ('KG', 'Kyrgyzstan'), ('KH', 'Cambodia'), ('KI', 'Kiribati'), ('KM', 'Comoros'), ('KN', 'St. Kitts and Nevis'), ('KP', "Korea, Democratic People's Republic of"), ('KR', 'Korea, Republic of'), ('KW', 'Kuwait'), ('KY', 'Cayman Islands'), ('KZ', 'Kazakhstan'), ('LA', "Lao People's Democratic Republic"), ('LB', 'Lebanon'), ('LC', 'Saint Lucia'), ('LI', 'Liechtenstein'), ('LK', 'Sri Lanka'), ('LR', 'Liberia'), ('LS', 'Lesotho'), ('LT', 'Lithuania'), ('LU', 'Luxembourg'), ('LV', 'Latvia'), ('LY', 'Libyan Arab Jamahiriya'), ('MA', 'Morocco'), ('MC', 'Monaco'), ('MD', 'Moldova, Republic of'), ('MG', 'Madagascar'), ('MH', 'Marshall Islands'), ('ML', 'Mali'), ('MN', 'Mongolia'), ('MM', 'Myanmar'), ('MO', 'Macau'), ('MP', 'Northern Mariana Islands'), ('MQ', 'Martinique'), ('MR', 'Mauritania'), ('MS', 'Monserrat'), ('MT', 'Malta'), ('MU', 'Mauritius'), ('MV', 'Maldives'), ('MW', 'Malawi'), ('MX', 'Mexico'), ('MY', 'Malaysia'), ('MZ', 'Mozambique'), ('NA', 'Namibia'), ('NC', 'New Caledonia'), ('NE', 'Niger'), ('NF', 'Norfolk Island'), ('NG', 'Nigeria'), ('NI', 'Nicaragua'), ('NL', 'Netherlands'), ('NO', 'Norway'), ('NP', 'Nepal'), ('NR', 'Nauru'), ('NU', 'Niue'), ('NZ', 'New Zealand'), ('OM', 'Oman'), ('PA', 'Panama'), ('PE', 'Peru'), ('PF', 'French Polynesia'), ('PG', 'Papua New Guinea'), ('PH', 'Philippines'), ('PK', 'Pakistan'), ('PL', 'Poland'), ('PM', 'St. Pierre & Miquelon'), ('PN', 'Pitcairn'), ('PR', 'Puerto Rico'), ('PT', 'Portugal'), ('PW', 'Palau'), ('PY', 'Paraguay'), ('QA', 'Qatar'), ('RE', 'Reunion'), ('RO', 'Romania'), ('RU', 'Russian Federation'), ('RW', 'Rwanda'), ('SA', 'Saudi Arabia'), ('SB', 'Solomon Islands'), ('SC', 'Seychelles'), ('SD', 'Sudan'), ('SE', 'Sweden'), ('SG', 'Singapore'), ('SH', 'St. Helena'), ('SI', 'Slovenia'), ('SJ', 'Svalbard & Jan Mayen Islands'), ('SK', 'Slovakia'), ('SL', 'Sierra Leone'), ('SM', 'San Marino'), ('SN', 'Senegal'), ('SO', 'Somalia'), ('SR', 'Suriname'), ('ST', 'Sao Tome & Principe'), ('SV', 'El Salvador'), ('SY', 'Syrian Arab Republic'), ('SZ', 'Swaziland'), ('TC', 'Turks & Caicos Islands'), ('TD', 'Chad'), ('TF', 'French Southern Territories'), ('TG', 'Togo'), ('TH', 'Thailand'), ('TJ', 'Tajikistan'), ('TK', 'Tokelau'), ('TM', 'Turkmenistan'), ('TN', 'Tunisia'), ('TO', 'Tonga'), ('TP', 'East Timor'), ('TR', 'Turkey'), ('TT', 'Trinidad & Tobago'), ('TV', 'Tuvalu'), ('TW', 'Taiwan, Province of China'), ('TZ', 'Tanzania, United Republic of'), ('UA', 'Ukraine'), ('UG', 'Uganda'), ('UM', 'United States Minor Outlying Islands'), ('US', 'United States of America'), ('UY', 'Uruguay'), ('UZ', 'Uzbekistan'), ('VA', 'Vatican City State (Holy See)'), ('VC', 'St. Vincent & the Grenadines'), ('VE', 'Venezuela'), ('VG', 'British Virgin Islands'), ('VI', 'United States Virgin Islands'), ('VN', 'Viet Nam'), ('VU', 'Vanuatu'), ('WF', 'Wallis & Futuna Islands'), ('WS', 'Samoa'), ('YE', 'Yemen'), ('YT', 'Mayotte'), ('YU', 'Yugoslavia'), ('ZA', 'South Africa'), ('ZM', 'Zambia'), ('ZR', 'Zaire'), ('ZW', 'Zimbabwe')], default='CH', max_length=2)),
+ ('starting_date', models.DateField()),
+ ('ending_date', models.DateField(blank=True, null=True)),
+ ('billing_network', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='uncloudproviderbill', to='uncloud.uncloudnetwork')),
+ ('coupon_network', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='uncloudprovidercoupon', to='uncloud.uncloudnetwork')),
+ ('referral_network', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='uncloudproviderreferral', to='uncloud.uncloudnetwork')),
+ ],
+ options={
+ 'abstract': False,
+ },
+ ),
+ ]
diff --git a/uncloud/migrations/0002_uncloudtasks.py b/uncloud/migrations/0002_uncloudtasks.py
new file mode 100644
index 0000000..9c69606
--- /dev/null
+++ b/uncloud/migrations/0002_uncloudtasks.py
@@ -0,0 +1,19 @@
+# Generated by Django 3.1 on 2020-12-20 17:16
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('uncloud', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='UncloudTasks',
+ fields=[
+ ('task_id', models.UUIDField(primary_key=True, serialize=False)),
+ ],
+ ),
+ ]
diff --git a/uncloud/migrations/0003_auto_20201220_1728.py b/uncloud/migrations/0003_auto_20201220_1728.py
new file mode 100644
index 0000000..2ec0eec
--- /dev/null
+++ b/uncloud/migrations/0003_auto_20201220_1728.py
@@ -0,0 +1,17 @@
+# Generated by Django 3.1 on 2020-12-20 17:28
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('uncloud', '0002_uncloudtasks'),
+ ]
+
+ operations = [
+ migrations.RenameModel(
+ old_name='UncloudTasks',
+ new_name='UncloudTask',
+ ),
+ ]
diff --git a/uncloud/migrations/0004_auto_20210101_1308.py b/uncloud/migrations/0004_auto_20210101_1308.py
new file mode 100644
index 0000000..8385b16
--- /dev/null
+++ b/uncloud/migrations/0004_auto_20210101_1308.py
@@ -0,0 +1,19 @@
+# Generated by Django 3.1 on 2021-01-01 13:08
+
+from django.db import migrations
+import uncloud.models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('uncloud', '0003_auto_20201220_1728'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='uncloudprovider',
+ name='country',
+ field=uncloud.models.CountryField(choices=[('AD', 'Andorra'), ('AE', 'United Arab Emirates'), ('AF', 'Afghanistan'), ('AG', 'Antigua & Barbuda'), ('AI', 'Anguilla'), ('AL', 'Albania'), ('AM', 'Armenia'), ('AN', 'Netherlands Antilles'), ('AO', 'Angola'), ('AQ', 'Antarctica'), ('AR', 'Argentina'), ('AS', 'American Samoa'), ('AT', 'Austria'), ('AU', 'Australia'), ('AW', 'Aruba'), ('AZ', 'Azerbaijan'), ('BA', 'Bosnia and Herzegovina'), ('BB', 'Barbados'), ('BD', 'Bangladesh'), ('BE', 'Belgium'), ('BF', 'Burkina Faso'), ('BG', 'Bulgaria'), ('BH', 'Bahrain'), ('BI', 'Burundi'), ('BJ', 'Benin'), ('BM', 'Bermuda'), ('BN', 'Brunei Darussalam'), ('BO', 'Bolivia'), ('BR', 'Brazil'), ('BS', 'Bahama'), ('BT', 'Bhutan'), ('BV', 'Bouvet Island'), ('BW', 'Botswana'), ('BY', 'Belarus'), ('BZ', 'Belize'), ('CA', 'Canada'), ('CC', 'Cocos (Keeling) Islands'), ('CF', 'Central African Republic'), ('CG', 'Congo'), ('CH', 'Switzerland'), ('CI', 'Ivory Coast'), ('CK', 'Cook Iislands'), ('CL', 'Chile'), ('CM', 'Cameroon'), ('CN', 'China'), ('CO', 'Colombia'), ('CR', 'Costa Rica'), ('CU', 'Cuba'), ('CV', 'Cape Verde'), ('CX', 'Christmas Island'), ('CY', 'Cyprus'), ('CZ', 'Czech Republic'), ('DE', 'Germany'), ('DJ', 'Djibouti'), ('DK', 'Denmark'), ('DM', 'Dominica'), ('DO', 'Dominican Republic'), ('DZ', 'Algeria'), ('EC', 'Ecuador'), ('EE', 'Estonia'), ('EG', 'Egypt'), ('EH', 'Western Sahara'), ('ER', 'Eritrea'), ('ES', 'Spain'), ('ET', 'Ethiopia'), ('FI', 'Finland'), ('FJ', 'Fiji'), ('FK', 'Falkland Islands (Malvinas)'), ('FM', 'Micronesia'), ('FO', 'Faroe Islands'), ('FR', 'France'), ('FX', 'France, Metropolitan'), ('GA', 'Gabon'), ('GB', 'United Kingdom (Great Britain)'), ('GD', 'Grenada'), ('GE', 'Georgia'), ('GF', 'French Guiana'), ('GH', 'Ghana'), ('GI', 'Gibraltar'), ('GL', 'Greenland'), ('GM', 'Gambia'), ('GN', 'Guinea'), ('GP', 'Guadeloupe'), ('GQ', 'Equatorial Guinea'), ('GR', 'Greece'), ('GS', 'South Georgia and the South Sandwich Islands'), ('GT', 'Guatemala'), ('GU', 'Guam'), ('GW', 'Guinea-Bissau'), ('GY', 'Guyana'), ('HK', 'Hong Kong'), ('HM', 'Heard & McDonald Islands'), ('HN', 'Honduras'), ('HR', 'Croatia'), ('HT', 'Haiti'), ('HU', 'Hungary'), ('ID', 'Indonesia'), ('IE', 'Ireland'), ('IL', 'Israel'), ('IN', 'India'), ('IO', 'British Indian Ocean Territory'), ('IQ', 'Iraq'), ('IR', 'Islamic Republic of Iran'), ('IS', 'Iceland'), ('IT', 'Italy'), ('JM', 'Jamaica'), ('JO', 'Jordan'), ('JP', 'Japan'), ('KE', 'Kenya'), ('KG', 'Kyrgyzstan'), ('KH', 'Cambodia'), ('KI', 'Kiribati'), ('KM', 'Comoros'), ('KN', 'St. Kitts and Nevis'), ('KP', "Korea, Democratic People's Republic of"), ('KR', 'Korea, Republic of'), ('KW', 'Kuwait'), ('KY', 'Cayman Islands'), ('KZ', 'Kazakhstan'), ('LA', "Lao People's Democratic Republic"), ('LB', 'Lebanon'), ('LC', 'Saint Lucia'), ('LI', 'Liechtenstein'), ('LK', 'Sri Lanka'), ('LR', 'Liberia'), ('LS', 'Lesotho'), ('LT', 'Lithuania'), ('LU', 'Luxembourg'), ('LV', 'Latvia'), ('LY', 'Libyan Arab Jamahiriya'), ('MA', 'Morocco'), ('MC', 'Monaco'), ('MD', 'Moldova, Republic of'), ('MG', 'Madagascar'), ('MH', 'Marshall Islands'), ('ML', 'Mali'), ('MN', 'Mongolia'), ('MM', 'Myanmar'), ('MO', 'Macau'), ('MP', 'Northern Mariana Islands'), ('MQ', 'Martinique'), ('MR', 'Mauritania'), ('MS', 'Monserrat'), ('MT', 'Malta'), ('MU', 'Mauritius'), ('MV', 'Maldives'), ('MW', 'Malawi'), ('MX', 'Mexico'), ('MY', 'Malaysia'), ('MZ', 'Mozambique'), ('NA', 'Namibia'), ('NC', 'New Caledonia'), ('NE', 'Niger'), ('NF', 'Norfolk Island'), ('NG', 'Nigeria'), ('NI', 'Nicaragua'), ('NL', 'Netherlands'), ('NO', 'Norway'), ('NP', 'Nepal'), ('NR', 'Nauru'), ('NU', 'Niue'), ('NZ', 'New Zealand'), ('OM', 'Oman'), ('PA', 'Panama'), ('PE', 'Peru'), ('PF', 'French Polynesia'), ('PG', 'Papua New Guinea'), ('PH', 'Philippines'), ('PK', 'Pakistan'), ('PL', 'Poland'), ('PM', 'St. Pierre & Miquelon'), ('PN', 'Pitcairn'), ('PR', 'Puerto Rico'), ('PT', 'Portugal'), ('PW', 'Palau'), ('PY', 'Paraguay'), ('QA', 'Qatar'), ('RE', 'Reunion'), ('RO', 'Romania'), ('RU', 'Russian Federation'), ('RW', 'Rwanda'), ('SA', 'Saudi Arabia'), ('SB', 'Solomon Islands'), ('SC', 'Seychelles'), ('SD', 'Sudan'), ('SE', 'Sweden'), ('SG', 'Singapore'), ('SH', 'St. Helena'), ('SI', 'Slovenia'), ('SJ', 'Svalbard & Jan Mayen Islands'), ('SK', 'Slovakia'), ('SL', 'Sierra Leone'), ('SM', 'San Marino'), ('SN', 'Senegal'), ('SO', 'Somalia'), ('SR', 'Suriname'), ('ST', 'Sao Tome & Principe'), ('SV', 'El Salvador'), ('SY', 'Syrian Arab Republic'), ('SZ', 'Swaziland'), ('TC', 'Turks & Caicos Islands'), ('TD', 'Chad'), ('TF', 'French Southern Territories'), ('TG', 'Togo'), ('TH', 'Thailand'), ('TJ', 'Tajikistan'), ('TK', 'Tokelau'), ('TM', 'Turkmenistan'), ('TN', 'Tunisia'), ('TO', 'Tonga'), ('TP', 'East Timor'), ('TR', 'Turkey'), ('TT', 'Trinidad & Tobago'), ('TV', 'Tuvalu'), ('TW', 'Taiwan, Province of China'), ('TZ', 'Tanzania, United Republic of'), ('UA', 'Ukraine'), ('UG', 'Uganda'), ('UM', 'United States Minor Outlying Islands'), ('US', 'United States of America'), ('UY', 'Uruguay'), ('UZ', 'Uzbekistan'), ('VA', 'Vatican City State (Holy See)'), ('VC', 'St. Vincent & the Grenadines'), ('VE', 'Venezuela'), ('VG', 'British Virgin Islands'), ('VI', 'United States Virgin Islands'), ('VN', 'Viet Nam'), ('VU', 'Vanuatu'), ('WF', 'Wallis & Futuna Islands'), ('WS', 'Samoa'), ('YE', 'Yemen'), ('YT', 'Mayotte'), ('YU', 'Yugoslavia'), ('ZA', 'South Africa'), ('ZM', 'Zambia'), ('ZR', 'Zaire'), ('ZW', 'Zimbabwe')], default='CH', max_length=2),
+ ),
+ ]
diff --git a/uncloud/migrations/0005_delete_uncloudtask.py b/uncloud/migrations/0005_delete_uncloudtask.py
new file mode 100644
index 0000000..6d9b095
--- /dev/null
+++ b/uncloud/migrations/0005_delete_uncloudtask.py
@@ -0,0 +1,16 @@
+# Generated by Django 3.2.4 on 2021-07-07 15:11
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('uncloud', '0004_auto_20210101_1308'),
+ ]
+
+ operations = [
+ migrations.DeleteModel(
+ name='UncloudTask',
+ ),
+ ]
diff --git a/uncloud/migrations/__init__.py b/uncloud/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/uncloud/models.py b/uncloud/models.py
new file mode 100644
index 0000000..c2b3cf9
--- /dev/null
+++ b/uncloud/models.py
@@ -0,0 +1,209 @@
+from django.db import models
+from django.db.models import JSONField, Q
+from django.utils import timezone
+from django.utils.translation import gettext_lazy as _
+from django.core.validators import MinValueValidator, MaxValueValidator
+from django.core.exceptions import FieldError
+
+from uncloud import COUNTRIES
+from .selectors import filter_for_when
+
+class UncloudModel(models.Model):
+ """
+ This class extends the standard model with an
+ extra_data field that can be used to include public,
+ but internal information.
+
+ For instance if you migrate from an existing virtualisation
+ framework to uncloud.
+
+ The extra_data attribute should be considered a hack and whenever
+ data is necessary for running uncloud, it should **not** be stored
+ in there.
+
+ """
+
+ extra_data = JSONField(editable=False, blank=True, null=True)
+
+ class Meta:
+ abstract = True
+
+# See https://docs.djangoproject.com/en/dev/ref/models/fields/#field-choices-enum-types
+class UncloudStatus(models.TextChoices):
+ PENDING = 'PENDING', _('Pending')
+ AWAITING_PAYMENT = 'AWAITING_PAYMENT', _('Awaiting payment')
+ BEING_CREATED = 'BEING_CREATED', _('Being created')
+ SCHEDULED = 'SCHEDULED', _('Scheduled') # resource selected, waiting for dispatching
+ ACTIVE = 'ACTIVE', _('Active')
+ MODIFYING = 'MODIFYING', _('Modifying') # Resource is being changed
+ DELETED = 'DELETED', _('Deleted') # Resource has been deleted
+ DISABLED = 'DISABLED', _('Disabled') # Is usable, but cannot be used for new things
+ UNUSABLE = 'UNUSABLE', _('Unusable'), # Has some kind of error
+
+
+
+###
+# General address handling
+class CountryField(models.CharField):
+ def __init__(self, *args, **kwargs):
+ kwargs.setdefault('choices', COUNTRIES)
+ kwargs.setdefault('default', 'CH')
+ kwargs.setdefault('max_length', 2)
+
+ super().__init__(*args, **kwargs)
+
+ def get_internal_type(self):
+ return "CharField"
+
+
+class UncloudAddress(models.Model):
+ full_name = models.CharField(max_length=256, null=False)
+ organization = models.CharField(max_length=256, blank=True, null=True)
+ street = models.CharField(max_length=256, null=False)
+ city = models.CharField(max_length=256, null=False)
+ postal_code = models.CharField(max_length=64)
+ country = CountryField(blank=False, null=False)
+
+ class Meta:
+ abstract = True
+
+
+class UncloudValidTimeFrame(models.Model):
+ """
+ A model that allows to limit validity of something to a certain
+ time frame. Used for versioning basically.
+
+ Logic:
+
+ """
+
+ class Meta:
+ abstract = True
+
+ constraints = [
+ models.UniqueConstraint(fields=['owner'],
+ condition=models.Q(active=True),
+ name='one_active_card_per_user')
+ ]
+
+
+ valid_from = models.DateTimeField(default=timezone.now, null=True, blank=True)
+ valid_to = models.DateTimeField(null=True, blank=True)
+
+ @classmethod
+ def get_current(cls, *args, **kwargs):
+ now = timezone.now()
+
+ # With both given
+ cls.objects.filter(valid_from__lte=now,
+ valid_to__gte=now)
+
+ # With to missing
+ cls.objects.filter(valid_from__lte=now,
+ valid_to__isnull=true)
+
+ # With from missing
+ cls.objects.filter(valid_from__isnull=true,
+ valid_to__gte=now)
+
+ # Both missing
+ cls.objects.filter(valid_from__isnull=true,
+ valid_to__gte=now)
+
+
+
+
+
+###
+# UncloudNetworks are used as identifiers - such they are a base of uncloud
+
+class UncloudNetwork(models.Model):
+ """
+ Storing IP networks
+ """
+
+ network_address = models.GenericIPAddressField(null=False, unique=True)
+ network_mask = models.IntegerField(null=False,
+ validators=[MinValueValidator(0),
+ MaxValueValidator(128)]
+ )
+
+ description = models.CharField(max_length=256)
+
+ @classmethod
+ def populate_db_defaults(cls):
+ for net, desc in [
+ ( "2a0a:e5c0:11::", "uncloud Billing" ),
+ ( "2a0a:e5c0:11:1::", "uncloud Referral" ),
+ ( "2a0a:e5c0:11:2::", "uncloud Coupon" )
+ ]:
+ obj, created = cls.objects.get_or_create(network_address=net,
+ defaults= {
+ 'network_mask': 64,
+ 'description': desc
+ }
+ )
+
+
+ def save(self, *args, **kwargs):
+ if not ':' in self.network_address and self.network_mask > 32:
+ raise FieldError("Mask cannot exceed 32 for IPv4")
+
+ super().save(*args, **kwargs)
+
+
+ def __str__(self):
+ return f"{self.network_address}/{self.network_mask} {self.description}"
+
+###
+# Who is running / providing this instance of uncloud?
+
+class UncloudProvider(UncloudAddress):
+ """
+ A class resembling who is running this uncloud instance.
+ This might change over time so we allow starting/ending dates
+
+ This also defines the taxation rules.
+
+ starting/ending date define from when to when this is valid. This way
+ we can model address changes and have it correct in the bills.
+ """
+
+ # Meta:
+ # FIXMe: only allow non overlapping time frames -- how to define this as a constraint?
+ starting_date = models.DateField()
+ ending_date = models.DateField(blank=True, null=True)
+
+ billing_network = models.ForeignKey(UncloudNetwork, related_name="uncloudproviderbill", on_delete=models.CASCADE)
+ referral_network = models.ForeignKey(UncloudNetwork, related_name="uncloudproviderreferral", on_delete=models.CASCADE)
+ coupon_network = models.ForeignKey(UncloudNetwork, related_name="uncloudprovidercoupon", on_delete=models.CASCADE)
+
+
+ @classmethod
+ def get_provider(cls, when=None):
+ """
+ Find active provide at a certain time - if there was any
+ """
+
+
+ return cls.objects.get(Q(starting_date__gte=when, ending_date__lte=when) |
+ Q(starting_date__gte=when, ending_date__isnull=True))
+
+
+ @classmethod
+ def populate_db_defaults(cls):
+ obj, created = cls.objects.get_or_create(full_name="ungleich glarus ag",
+ street="Bahnhofstrasse 1",
+ postal_code="8783",
+ city="Linthal",
+ country="CH",
+ starting_date=timezone.now(),
+ billing_network=UncloudNetwork.objects.get(description="uncloud Billing"),
+ referral_network=UncloudNetwork.objects.get(description="uncloud Referral"),
+ coupon_network=UncloudNetwork.objects.get(description="uncloud Coupon")
+ )
+
+
+ def __str__(self):
+ return f"{self.full_name} {self.country}"
+
diff --git a/uncloud/scheduler/main.py b/uncloud/scheduler/main.py
deleted file mode 100755
index 5a4014f..0000000
--- a/uncloud/scheduler/main.py
+++ /dev/null
@@ -1,75 +0,0 @@
-# TODO
-# 1. send an email to an email address defined by env['admin-email']
-# if resources are finished
-# 2. Introduce a status endpoint of the scheduler -
-# maybe expose a prometheus compatible output
-
-from uncloud.common.request import RequestEntry, RequestType
-from uncloud.shared import shared
-from uncloud.settings import settings
-from .helper import (
- dead_host_mitigation,
- dead_host_detection,
- assign_host,
- NoSuitableHostFound,
-)
-from . import logger
-
-
-def main():
- for request_iterator in [
- shared.etcd_client.get_prefix(
- settings["etcd"]["request_prefix"], value_in_json=True
- ),
- shared.etcd_client.watch_prefix(
- settings["etcd"]["request_prefix"],
- timeout=5,
- value_in_json=True,
- ),
- ]:
- for request_event in request_iterator:
- request_entry = RequestEntry(request_event)
- # Never Run time critical mechanism inside timeout
- # mechanism because timeout mechanism only comes
- # when no other event is happening. It means under
- # heavy load there would not be a timeout event.
- if request_entry.type == "TIMEOUT":
-
- # Detect hosts that are dead and set their status
- # to "DEAD", and their VMs' status to "KILLED"
- dead_hosts = dead_host_detection()
- if dead_hosts:
- logger.debug("Dead hosts: %s", dead_hosts)
- dead_host_mitigation(dead_hosts)
-
- elif request_entry.type == RequestType.ScheduleVM:
- print(request_event.value)
- logger.debug(
- "%s, %s", request_entry.key, request_entry.value
- )
-
- vm_entry = shared.vm_pool.get(request_entry.uuid)
- if vm_entry is None:
- logger.info(
- "Trying to act on {} but it is deleted".format(
- request_entry.uuid
- )
- )
- continue
- shared.etcd_client.client.delete(
- request_entry.key
- ) # consume Request
-
- try:
- assign_host(vm_entry)
- except NoSuitableHostFound:
- vm_entry.add_log(
- "Can't schedule VM. No Resource Left."
- )
- shared.vm_pool.put(vm_entry)
-
- logger.info("No Resource Left. Emailing admin....")
-
-
-if __name__ == "__main__":
- main()
diff --git a/uncloud/selectors.py b/uncloud/selectors.py
new file mode 100644
index 0000000..52b8548
--- /dev/null
+++ b/uncloud/selectors.py
@@ -0,0 +1,23 @@
+from django.db.models import Q
+from django.utils import timezone
+
+def filter_for_when(queryset, when=None):
+ """
+ Return a filtered queryset which is valid for the given date
+
+ Logic:
+
+ Look for entries that have a starting date before when
+ and either
+ - No ending date
+ - Ending date after "when"
+
+ Returns a queryset, you'll neet to apply .first() or similar on it
+
+ """
+
+ if not when:
+ when = timezone.now()
+
+ return queryset.filter(starting_date__lte=when).filter(Q(ending_date__gte=when) |
+ Q(ending_date__isnull=True))
diff --git a/uncloud/settings.py b/uncloud/settings.py
new file mode 100644
index 0000000..be6cc11
--- /dev/null
+++ b/uncloud/settings.py
@@ -0,0 +1,265 @@
+"""
+Django settings for uncloud project.
+
+Generated by 'django-admin startproject' using Django 3.0.3.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/3.0/topics/settings/
+
+For the full list of settings and their values, see
+https://docs.djangoproject.com/en/3.0/ref/settings/
+"""
+
+import os
+import re
+import ldap
+import sys
+
+from django.core.management.utils import get_random_secret_key
+from django_auth_ldap.config import LDAPSearch, LDAPSearchUnion
+
+
+LOGGING = {}
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+sys.modules['fontawesome_free'] = __import__('fontawesome-free')
+
+# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.sqlite3',
+ 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
+ }
+}
+
+
+# Quick-start development settings - unsuitable for production
+# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = True
+
+SITE_ID = 1
+
+# Application definition
+
+INSTALLED_APPS = [
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.sites',
+ 'allauth',
+ 'allauth.account',
+ 'allauth.socialaccount',
+ 'django.contrib.staticfiles',
+ 'django_extensions',
+ 'rest_framework',
+ 'bootstrap5',
+ 'django_q',
+ 'fontawesome_free',
+ 'uncloud',
+ 'uncloud_pay',
+ 'uncloud_auth',
+ 'uncloud_net',
+ 'uncloud_storage',
+ 'uncloud_vm',
+ 'uncloud_service',
+ 'opennebula',
+ 'matrixhosting',
+]
+
+MIDDLEWARE = [
+ 'django.middleware.security.SecurityMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.middleware.common.CommonMiddleware',
+ 'django.middleware.csrf.CsrfViewMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+ 'django.contrib.messages.middleware.MessageMiddleware',
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
+]
+
+ROOT_URLCONF = 'uncloud.urls'
+
+TEMPLATES = [
+ {
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
+ 'DIRS': [],
+ 'APP_DIRS': True,
+ 'OPTIONS': {
+ 'context_processors': [
+ 'django.template.context_processors.debug',
+ 'django.template.context_processors.request',
+ 'django.contrib.auth.context_processors.auth',
+ 'django.contrib.messages.context_processors.messages',
+ ],
+ },
+ },
+]
+
+WSGI_APPLICATION = 'uncloud.wsgi.application'
+
+
+# Password validation
+# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
+
+AUTH_PASSWORD_VALIDATORS = [
+ {
+ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
+ },
+ {
+ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
+ },
+ {
+ 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
+ },
+ {
+ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
+ },
+]
+###############################################################################
+# Authall Settings
+ACCOUNT_AUTHENTICATION_METHOD = "username"
+ACCOUNT_EMAIL_CONFIRMATION_EXPIRE_DAYS = 1
+ACCOUNT_EMAIL_REQUIRED = False
+ACCOUNT_EMAIL_VERIFICATION = "optional"
+ACCOUNT_UNIQUE_EMAIL = False
+################################################################################
+# AUTH/LDAP
+
+AUTH_LDAP_SERVER_URI = ""
+AUTH_LDAP_BIND_DN = ""
+AUTH_LDAP_BIND_PASSWORD = ""
+AUTH_LDAP_USER_SEARCH = LDAPSearch("dc=example,dc=com",
+ ldap.SCOPE_SUBTREE,
+ "(uid=%(user)s)")
+
+AUTH_LDAP_USER_ATTR_MAP = {
+ "first_name": "givenName",
+ "last_name": "sn",
+ "email": "mail"
+}
+
+################################################################################
+# AUTH/Django
+AUTHENTICATION_BACKENDS = [
+ "django_auth_ldap.backend.LDAPBackend",
+ "django.contrib.auth.backends.ModelBackend",
+ 'allauth.account.auth_backends.AuthenticationBackend',
+]
+
+AUTH_USER_MODEL = 'uncloud_auth.User'
+
+
+################################################################################
+# AUTH/REST
+REST_FRAMEWORK = {
+ 'DEFAULT_AUTHENTICATION_CLASSES': [
+ 'rest_framework.authentication.BasicAuthentication',
+ 'rest_framework.authentication.SessionAuthentication',
+ ]
+}
+
+
+# Internationalization
+# https://docs.djangoproject.com/en/3.0/topics/i18n/
+
+LANGUAGE_CODE = 'en-us'
+
+TIME_ZONE = 'UTC'
+
+USE_I18N = True
+
+USE_L10N = True
+
+USE_TZ = True
+
+
+# Static files (CSS, JavaScript, Images)
+# https://docs.djangoproject.com/en/3.0/howto/static-files/
+STATIC_URL = '/static/'
+STATICFILES_DIRS = [ os.path.join(BASE_DIR, "static") ]
+STATICFILES_FINDERS = [
+ 'django.contrib.staticfiles.finders.FileSystemFinder',
+ 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
+]
+
+#VM Deployment TEMPLATE
+GITLAB_SERVER = 'https://code.ungleich.ch'
+GITLAB_OAUTH_TOKEN = ''
+GITLAB_PROJECT_ID = 388
+GITLAB_AUTHOR_EMAIL = ''
+GITLAB_AUTHOR_NAME = ''
+GITLAB_YAML_DIR = ''
+
+# XML-RPC interface of opennebula
+OPENNEBULA_URL = 'https://opennebula.example.com:2634/RPC2'
+
+# user:pass for accessing opennebula
+OPENNEBULA_USER_PASS = 'user:password'
+
+# Stripe (Credit Card payments)
+STRIPE_KEY=""
+STRIPE_PUBLIC_KEY=""
+BILL_PAYMENT_DELAY = 0
+# The django secret key
+SECRET_KEY=get_random_secret_key()
+
+ALLOWED_HOSTS = []
+
+# required for hardcopy / pdf rendering: https://github.com/loftylabs/django-hardcopy
+CHROME_PATH = '/usr/bin/chromium-browser'
+
+# Username that is created by default and owns the configuration objects
+UNCLOUD_ADMIN_NAME = "uncloud-admin"
+
+LOGIN_REDIRECT_URL = '/'
+LOGOUT_REDIRECT_URL = '/'
+
+# replace these in local_settings.py
+AUTH_LDAP_SERVER_URI = "ldaps://ldap1.example.com,ldaps://ldap2.example.com"
+AUTH_LDAP_BIND_DN="uid=django,ou=system,dc=example,dc=com"
+AUTH_LDAP_BIND_PASSWORD="a very secure ldap password"
+AUTH_LDAP_USER_SEARCH = LDAPSearch("dc=example,dc=com",
+ ldap.SCOPE_SUBTREE,
+ "(uid=%(user)s)")
+
+# where to create customers
+LDAP_CUSTOMER_DN="ou=customer,dc=example,dc=com"
+
+EMAIL_USE_TLS = True
+EMAIL_HOST = ''
+EMAIL_PORT = 465
+EMAIL_HOST_USER = DEFAULT_FROM_EMAIL = ''
+EMAIL_HOST_PASSWORD = ''
+DEFAULT_FROM_EMAIL = ''
+RENEWAL_FROM_EMAIL = 'test@example.com'
+# Should be removed in production
+EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
+
+##############
+# Jobs
+Q_CLUSTER = {
+ 'name': 'matrixhosting',
+ 'workers': 1,
+ 'recycle': 500,
+ 'timeout': 60,
+ 'compress': True,
+ 'cpu_affinity': 1,
+ 'save_limit': 250,
+ 'queue_limit': 500,
+ 'label': 'Django Q',
+ 'redis': {
+ 'host': '127.0.0.1',
+ 'port': 6379,
+ 'db': 0, }
+}
+
+# Overwrite settings with local settings, if existing
+try:
+ from uncloud.local_settings import *
+except (ModuleNotFoundError, ImportError):
+ pass
diff --git a/uncloud/settings/__init__.py b/uncloud/settings/__init__.py
deleted file mode 100644
index 629660e..0000000
--- a/uncloud/settings/__init__.py
+++ /dev/null
@@ -1,128 +0,0 @@
-import configparser
-import logging
-import sys
-import os
-
-from uncloud.common.etcd_wrapper import Etcd3Wrapper
-
-logger = logging.getLogger(__name__)
-
-
-class CustomConfigParser(configparser.RawConfigParser):
- def __getitem__(self, key):
- try:
- result = super().__getitem__(key)
- except KeyError as err:
- raise KeyError(
- "Key '{}' not found in configuration. Make sure you configure uncloud.".format(
- key
- )
- ) from err
- else:
- return result
-
-
-class Settings(object):
- def __init__(self, config_key="/uncloud/config/"):
- conf_name = "uncloud.conf"
- conf_dir = os.environ.get(
- "UCLOUD_CONF_DIR", os.path.expanduser("~/uncloud/")
- )
- self.config_file = os.path.join(conf_dir, conf_name)
-
- self.config_parser = CustomConfigParser(allow_no_value=True)
- self.config_key = config_key
-
- self.read_internal_values()
- try:
- self.config_parser.read(self.config_file)
- except Exception as err:
- logger.error("%s", err)
-
- def get_etcd_client(self):
- args = tuple()
- try:
- kwargs = {
- "host": self.config_parser.get("etcd", "url"),
- "port": self.config_parser.get("etcd", "port"),
- "ca_cert": self.config_parser.get("etcd", "ca_cert"),
- "cert_cert": self.config_parser.get(
- "etcd", "cert_cert"
- ),
- "cert_key": self.config_parser.get("etcd", "cert_key"),
- }
- except configparser.Error as err:
- raise configparser.Error(
- "{} in config file {}".format(
- err.message, self.config_file
- )
- ) from err
- else:
- try:
- wrapper = Etcd3Wrapper(*args, **kwargs)
- except Exception as err:
- logger.error(
- "etcd connection not successfull. Please check your config file."
- "\nDetails: %s\netcd connection parameters: %s",
- err,
- kwargs,
- )
- sys.exit(1)
- else:
- return wrapper
-
- def read_internal_values(self):
- self.config_parser.read_dict(
- {
- "etcd": {
- "file_prefix": "/files/",
- "host_prefix": "/hosts/",
- "image_prefix": "/images/",
- "image_store_prefix": "/imagestore/",
- "network_prefix": "/networks/",
- "request_prefix": "/requests/",
- "user_prefix": "/users/",
- "vm_prefix": "/vms/",
- }
- }
- )
-
- def read_config_file_values(self, config_file):
- try:
- # Trying to read configuration file
- with open(config_file, "r") as config_file_handle:
- self.config_parser.read_file(config_file_handle)
- except FileNotFoundError:
- sys.exit(
- "Configuration file {} not found!".format(config_file)
- )
- except Exception as err:
- logger.exception(err)
- sys.exit("Error occurred while reading configuration file")
-
- def read_values_from_etcd(self):
- etcd_client = self.get_etcd_client()
- config_from_etcd = etcd_client.get(
- self.config_key, value_in_json=True
- )
- if config_from_etcd:
- self.config_parser.read_dict(config_from_etcd.value)
- else:
- raise KeyError(
- "Key '{}' not found in etcd. Please configure uncloud.".format(
- self.config_key
- )
- )
-
- def __getitem__(self, key):
- # Allow failing to read from etcd if we have
- # it locally
- try:
- self.read_values_from_etcd()
- except KeyError as e:
- pass
-
- return self.config_parser[key]
-
-
-settings = Settings()
diff --git a/uncloud/shared/__init__.py b/uncloud/shared/__init__.py
deleted file mode 100644
index db2093f..0000000
--- a/uncloud/shared/__init__.py
+++ /dev/null
@@ -1,34 +0,0 @@
-from uncloud.settings import settings
-from uncloud.common.vm import VmPool
-from uncloud.common.host import HostPool
-from uncloud.common.request import RequestPool
-from uncloud.common.storage_handlers import get_storage_handler
-
-
-class Shared:
- @property
- def etcd_client(self):
- return settings.get_etcd_client()
-
- @property
- def host_pool(self):
- return HostPool(
- self.etcd_client, settings["etcd"]["host_prefix"]
- )
-
- @property
- def vm_pool(self):
- return VmPool(self.etcd_client, settings["etcd"]["vm_prefix"])
-
- @property
- def request_pool(self):
- return RequestPool(
- self.etcd_client, settings["etcd"]["request_prefix"]
- )
-
- @property
- def storage_handler(self):
- return get_storage_handler()
-
-
-shared = Shared()
diff --git a/uncloud/static/uncloud/uncloud.css b/uncloud/static/uncloud/uncloud.css
new file mode 100644
index 0000000..51d93ef
--- /dev/null
+++ b/uncloud/static/uncloud/uncloud.css
@@ -0,0 +1,4 @@
+#content {
+ width: 400px;
+ margin: auto;
+}
diff --git a/uncloud/templates/uncloud/base.html b/uncloud/templates/uncloud/base.html
new file mode 100644
index 0000000..cbf0686
--- /dev/null
+++ b/uncloud/templates/uncloud/base.html
@@ -0,0 +1,29 @@
+{% extends 'bootstrap5/bootstrap5.html' %}
+{% block bootstrap5_before_content %}
+
+
+{% endblock %}
diff --git a/uncloud/templates/uncloud/index.html b/uncloud/templates/uncloud/index.html
new file mode 100644
index 0000000..b8b5828
--- /dev/null
+++ b/uncloud/templates/uncloud/index.html
@@ -0,0 +1,170 @@
+{% extends 'uncloud/base.html' %}
+{% block title %}Welcome to uncloud [beta]{% endblock %}
+
+{% block bootstrap5_content %}
+
+
+
+
+
Welcome to uncloud [beta]
+
+
+
+
+
About uncloud
+
+
+ Welcome to uncloud, the Open Source cloud management
+ system by ungleich.
+ It is an API driven system with
+ some convience views provided by
+ the Django Rest
+ Framework. You can
+ freely access
+ the source code of uncloud.
+ This is a BETA service. As such, some
+ functionality might not be very sophisticated.
+
+
+
+
+
Getting started
+
+
uncloud is designed to be as easy as possible to use. However,
+ there are some "real world" requirements that need to be met to
+ start using uncloud:
+
+
If you have forgotten your password or other issues with
+ logging in, you can contact the ungleich support
+ via support at ungleich.ch.
+
+
Secondy you will need to
+ create a billing
+ address. This is required for determining the correct
+ tax.
+
Next you will need to
+ register a credit card
+ from which payments can be made. Your credit card will not
+ be charged without your consent.
+
+
+
+
+
Introduction to uncloud concepts
+
+
We plan to offer many services on uncloud ranging from
+ for free, for a small amount or regular charges. As transfer
+ fees are a major challenge for our business, we based uncloud
+ on the pre-paid account model. Which means
+ that you can charge your account and then use your balance to
+ pay for product usage.
+
+
+
+
+
Credit cards
+
+
+ Credit cards are registered with stripe. We only save a the
+ last 4 digits and the expiry date of the card to make
+ identification for you easier.
+
+
+
Register a credit card
+ (this is required to be done via Javascript so that we never see
+ your credit card, but it is sent directly to stripe)
+
You can list your
+ credit cards
+ By default the first credit card is used for charging
+ ("active: true") and later added cards will not be
+ used. To change this, first disable the active flag and
+ then set it on another credit card.
+
+
+
+
Billing Address, Payments and Balance
+
+
Billing addresses behave similar to credit cards: you can
+ have many of them, but only one can be active. The active
+ billing address is taken for creating new orders.
+
+
In uncloud we use the pre-paid model: you can add money to
+ your account via payments. You can always check your
+ balance. The products you use will automatically be charged from
+ your existing balance.
+
+
+
In the future you will be able opt-in to automatically
+ recharging your account at a certain time frame or whenever it
+ is below a certain amount
+ By submitting I authorise to send instructions to
+ the financial institution that issued my card to take
+ payments from my card account in accordance with the
+ terms of my agreement with you.
+