summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/caas/__init__.py0
-rw-r--r--src/caas/admin.py3
-rw-r--r--src/caas/apps.py5
-rw-r--r--src/caas/migrations/__init__.py0
-rw-r--r--src/caas/models.py3
-rw-r--r--src/caas/tests.py3
-rw-r--r--src/caas/views.py3
-rw-r--r--src/far_edge_ops_api/.gitignore1
-rw-r--r--src/far_edge_ops_api/__init__.py0
-rw-r--r--src/far_edge_ops_api/asgi.py16
-rw-r--r--src/far_edge_ops_api/setting.py.example124
-rw-r--r--src/far_edge_ops_api/urls.py22
-rw-r--r--src/far_edge_ops_api/wsgi.py16
-rwxr-xr-xsrc/manage.py21
-rw-r--r--src/orchestration/__init__.py0
-rw-r--r--src/orchestration/admin.py3
-rw-r--r--src/orchestration/apps.py5
-rw-r--r--src/orchestration/migrations/0001_initial.py39
-rw-r--r--src/orchestration/migrations/0002_auto_20200429_1826.py21
-rw-r--r--src/orchestration/migrations/0003_auto_20200429_1827.py21
-rw-r--r--src/orchestration/migrations/0004_auto_20200429_1831.py18
-rw-r--r--src/orchestration/migrations/0005_auto_20200429_1836.py18
-rw-r--r--src/orchestration/migrations/0006_auto_20200429_1836.py18
-rw-r--r--src/orchestration/migrations/0007_auto_20200429_1837.py18
-rw-r--r--src/orchestration/migrations/__init__.py0
-rw-r--r--src/orchestration/models.py26
-rw-r--r--src/orchestration/tests.py3
-rw-r--r--src/orchestration/urls.py8
-rw-r--r--src/orchestration/views.py24
29 files changed, 439 insertions, 0 deletions
diff --git a/src/caas/__init__.py b/src/caas/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/caas/__init__.py
diff --git a/src/caas/admin.py b/src/caas/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/src/caas/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/src/caas/apps.py b/src/caas/apps.py
new file mode 100644
index 0000000..5e92d0b
--- /dev/null
+++ b/src/caas/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class CaasConfig(AppConfig):
+ name = 'caas'
diff --git a/src/caas/migrations/__init__.py b/src/caas/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/caas/migrations/__init__.py
diff --git a/src/caas/models.py b/src/caas/models.py
new file mode 100644
index 0000000..71a8362
--- /dev/null
+++ b/src/caas/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/src/caas/tests.py b/src/caas/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/src/caas/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/src/caas/views.py b/src/caas/views.py
new file mode 100644
index 0000000..91ea44a
--- /dev/null
+++ b/src/caas/views.py
@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.
diff --git a/src/far_edge_ops_api/.gitignore b/src/far_edge_ops_api/.gitignore
new file mode 100644
index 0000000..fce19e4
--- /dev/null
+++ b/src/far_edge_ops_api/.gitignore
@@ -0,0 +1 @@
+settings.py
diff --git a/src/far_edge_ops_api/__init__.py b/src/far_edge_ops_api/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/far_edge_ops_api/__init__.py
diff --git a/src/far_edge_ops_api/asgi.py b/src/far_edge_ops_api/asgi.py
new file mode 100644
index 0000000..de8b0be
--- /dev/null
+++ b/src/far_edge_ops_api/asgi.py
@@ -0,0 +1,16 @@
+"""
+ASGI config for far_edge_ops_api 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', 'far_edge_ops_api.settings')
+
+application = get_asgi_application()
diff --git a/src/far_edge_ops_api/setting.py.example b/src/far_edge_ops_api/setting.py.example
new file mode 100644
index 0000000..f89eeea
--- /dev/null
+++ b/src/far_edge_ops_api/setting.py.example
@@ -0,0 +1,124 @@
+"""
+Django settings for far_edge_ops_api project.
+
+Generated by 'django-admin startproject' using Django 3.0.5.
+
+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
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+
+
+# Quick-start development settings - unsuitable for production
+# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
+
+# SECURITY WARNING: keep the secret key used in production secret!
+SECRET_KEY = '_%q*cv!0fu&z%#17ved2zq-6y^*#^1pt#gma))h6g(=jw!q14o'
+
+# SECURITY WARNING: don't run with debug turned on in production!
+DEBUG = False
+
+ALLOWED_HOSTS = ['*']
+
+
+# Application definition
+
+INSTALLED_APPS = [
+ 'django.contrib.admin',
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.messages',
+ 'django.contrib.staticfiles',
+]
+
+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 = 'far_edge_ops_api.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 = 'far_edge_ops_api.wsgi.application'
+
+
+# Database
+# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.mysql',
+ 'NAME': 'faredge',
+ 'HOST': 'localhost',
+ 'PORT': '3306',
+ 'USER': 'faredge',
+ 'PASSWORD': 'neweboy'
+ }
+}
+
+
+# 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',
+ },
+]
+
+
+# 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/'
diff --git a/src/far_edge_ops_api/urls.py b/src/far_edge_ops_api/urls.py
new file mode 100644
index 0000000..298a4a7
--- /dev/null
+++ b/src/far_edge_ops_api/urls.py
@@ -0,0 +1,22 @@
+"""far_edge_ops_api URL Configuration
+
+The `urlpatterns` list routes URLs to views. For more information please see:
+ https://docs.djangoproject.com/en/3.0/topics/http/urls/
+Examples:
+Function views
+ 1. Add an import: from my_app import views
+ 2. Add a URL to urlpatterns: path('', views.home, name='home')
+Class-based views
+ 1. Add an import: from other_app.views import Home
+ 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
+Including another URLconf
+ 1. Import the include() function: from django.urls import include, path
+ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
+"""
+from django.contrib import admin
+from django.urls import include, path
+
+urlpatterns = [
+ path('orchestration/', include('orchestration.urls')),
+ path('admin/', admin.site.urls)
+]
diff --git a/src/far_edge_ops_api/wsgi.py b/src/far_edge_ops_api/wsgi.py
new file mode 100644
index 0000000..3b5d6a6
--- /dev/null
+++ b/src/far_edge_ops_api/wsgi.py
@@ -0,0 +1,16 @@
+"""
+WSGI config for far_edge_ops_api project.
+
+It exposes the WSGI callable as a module-level variable named ``application``.
+
+For more information on this file, see
+https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
+"""
+
+import os
+
+from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'far_edge_ops_api.settings')
+
+application = get_wsgi_application()
diff --git a/src/manage.py b/src/manage.py
new file mode 100755
index 0000000..6f1cc4b
--- /dev/null
+++ b/src/manage.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+"""Django's command-line utility for administrative tasks."""
+import os
+import sys
+
+
+def main():
+ os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'far_edge_ops_api.settings')
+ try:
+ from django.core.management import execute_from_command_line
+ except ImportError as exc:
+ raise ImportError(
+ "Couldn't import Django. Are you sure it's installed and "
+ "available on your PYTHONPATH environment variable? Did you "
+ "forget to activate a virtual environment?"
+ ) from exc
+ execute_from_command_line(sys.argv)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/src/orchestration/__init__.py b/src/orchestration/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/orchestration/__init__.py
diff --git a/src/orchestration/admin.py b/src/orchestration/admin.py
new file mode 100644
index 0000000..8c38f3f
--- /dev/null
+++ b/src/orchestration/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/src/orchestration/apps.py b/src/orchestration/apps.py
new file mode 100644
index 0000000..f92ec6d
--- /dev/null
+++ b/src/orchestration/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class OrchestrationConfig(AppConfig):
+ name = 'orchestration'
diff --git a/src/orchestration/migrations/0001_initial.py b/src/orchestration/migrations/0001_initial.py
new file mode 100644
index 0000000..f2ff405
--- /dev/null
+++ b/src/orchestration/migrations/0001_initial.py
@@ -0,0 +1,39 @@
+# Generated by Django 3.0.5 on 2020-04-30 00:24
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ initial = True
+
+ dependencies = [
+ ]
+
+ operations = [
+ migrations.CreateModel(
+ name='ImageSync',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('remote_region_name', models.CharField(max_length=64)),
+ ('docker_image', models.TextField(max_length=65535)),
+ ('upload_start_time', models.DateTimeField()),
+ ('upload_end_time', models.DateTimeField(blank=True)),
+ ('upload_status', models.CharField(choices=[('STARTED', 'STARTED'), ('UPLOADING', 'UPLOADING'), ('COMPLETE', 'COMPLETE'), ('FAILED', 'FAILED')], max_length=9)),
+ ('upload_message', models.CharField(max_length=255)),
+ ],
+ ),
+ migrations.CreateModel(
+ name='RemoteRegionSetup',
+ fields=[
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+ ('caas_vendor_version', models.CharField(max_length=20)),
+ ('kubernetes_version', models.CharField(max_length=20)),
+ ('central_region_name', models.CharField(max_length=64)),
+ ('remote_region_name', models.CharField(max_length=64)),
+ ('kubernetes_namespace', models.CharField(max_length=64)),
+ ('serviceaccount', models.CharField(max_length=64)),
+ ('kubeconfig', models.TextField(max_length=16777215)),
+ ],
+ ),
+ ]
diff --git a/src/orchestration/migrations/0002_auto_20200429_1826.py b/src/orchestration/migrations/0002_auto_20200429_1826.py
new file mode 100644
index 0000000..176b8b9
--- /dev/null
+++ b/src/orchestration/migrations/0002_auto_20200429_1826.py
@@ -0,0 +1,21 @@
+# Generated by Django 3.0.5 on 2020-04-30 00:26
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('orchestration', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.RenameModel(
+ old_name='ImageSync',
+ new_name='Image_Sync',
+ ),
+ migrations.RenameModel(
+ old_name='RemoteRegionSetup',
+ new_name='Remote_Region_Setup',
+ ),
+ ]
diff --git a/src/orchestration/migrations/0003_auto_20200429_1827.py b/src/orchestration/migrations/0003_auto_20200429_1827.py
new file mode 100644
index 0000000..24c919c
--- /dev/null
+++ b/src/orchestration/migrations/0003_auto_20200429_1827.py
@@ -0,0 +1,21 @@
+# Generated by Django 3.0.5 on 2020-04-30 00:27
+
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('orchestration', '0002_auto_20200429_1826'),
+ ]
+
+ operations = [
+ migrations.RenameModel(
+ old_name='Image_Sync',
+ new_name='ImageSync',
+ ),
+ migrations.RenameModel(
+ old_name='Remote_Region_Setup',
+ new_name='RemoteRegionSetup',
+ ),
+ ]
diff --git a/src/orchestration/migrations/0004_auto_20200429_1831.py b/src/orchestration/migrations/0004_auto_20200429_1831.py
new file mode 100644
index 0000000..ef7d71d
--- /dev/null
+++ b/src/orchestration/migrations/0004_auto_20200429_1831.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.5 on 2020-04-30 00:31
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('orchestration', '0003_auto_20200429_1827'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='imagesync',
+ name='upload_end_time',
+ field=models.DateTimeField(null=True),
+ ),
+ ]
diff --git a/src/orchestration/migrations/0005_auto_20200429_1836.py b/src/orchestration/migrations/0005_auto_20200429_1836.py
new file mode 100644
index 0000000..f4215d0
--- /dev/null
+++ b/src/orchestration/migrations/0005_auto_20200429_1836.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.5 on 2020-04-30 00:36
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('orchestration', '0004_auto_20200429_1831'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='remoteregionsetup',
+ name='kubeconfig',
+ field=models.TextField(blank=True, default='', max_length=16777215),
+ ),
+ ]
diff --git a/src/orchestration/migrations/0006_auto_20200429_1836.py b/src/orchestration/migrations/0006_auto_20200429_1836.py
new file mode 100644
index 0000000..d624ebf
--- /dev/null
+++ b/src/orchestration/migrations/0006_auto_20200429_1836.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.5 on 2020-04-30 00:36
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('orchestration', '0005_auto_20200429_1836'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='remoteregionsetup',
+ name='kubeconfig',
+ field=models.TextField(blank=True, default='', max_length=16777215, null=True),
+ ),
+ ]
diff --git a/src/orchestration/migrations/0007_auto_20200429_1837.py b/src/orchestration/migrations/0007_auto_20200429_1837.py
new file mode 100644
index 0000000..210bf23
--- /dev/null
+++ b/src/orchestration/migrations/0007_auto_20200429_1837.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.5 on 2020-04-30 00:37
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('orchestration', '0006_auto_20200429_1836'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='remoteregionsetup',
+ name='kubeconfig',
+ field=models.TextField(blank=True, max_length=16777215, null=True),
+ ),
+ ]
diff --git a/src/orchestration/migrations/__init__.py b/src/orchestration/migrations/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/orchestration/migrations/__init__.py
diff --git a/src/orchestration/models.py b/src/orchestration/models.py
new file mode 100644
index 0000000..8e79d8d
--- /dev/null
+++ b/src/orchestration/models.py
@@ -0,0 +1,26 @@
+from django.db import models
+
+
+class ImageSync(models.Model):
+ remote_region_name = models.CharField(max_length=64)
+ docker_image = models.TextField(max_length=65535)
+ upload_start_time = models.DateTimeField()
+ upload_end_time = models.DateTimeField(null=True)
+ upload_status = models.CharField(max_length=9, choices=[('STARTED', 'STARTED'), ('UPLOADING', 'UPLOADING'), ('COMPLETE', 'COMPLETE'), ('FAILED', 'FAILED')])
+ upload_message = models.CharField(max_length=255)
+
+ def __str__(self):
+ return "%s : %s" % (self.remote_region_name, self.docker_image)
+
+
+class RemoteRegionSetup(models.Model):
+ caas_vendor_version = models.CharField(max_length=20)
+ kubernetes_version = models.CharField(max_length=20)
+ central_region_name = models.CharField(max_length=64)
+ remote_region_name = models.CharField(max_length=64)
+ kubernetes_namespace = models.CharField(max_length=64)
+ serviceaccount = models.CharField(max_length=64)
+ kubeconfig = models.TextField(max_length=16777215, null=True, blank=True)
+
+ def __str__(self):
+ return "%s : %s" % (self.remote_region_name, self.kubernetes_namespace)
diff --git a/src/orchestration/tests.py b/src/orchestration/tests.py
new file mode 100644
index 0000000..7ce503c
--- /dev/null
+++ b/src/orchestration/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/src/orchestration/urls.py b/src/orchestration/urls.py
new file mode 100644
index 0000000..6b7dbbc
--- /dev/null
+++ b/src/orchestration/urls.py
@@ -0,0 +1,8 @@
+from django.urls import path
+from . import views
+
+urlpatterns = [
+ path('', views.index, name='index'),
+ path('count/<int:count>/', views.count, name='count'),
+ path('imagesync/', views.imagesync, name='imagesync')
+]
diff --git a/src/orchestration/views.py b/src/orchestration/views.py
new file mode 100644
index 0000000..4c3910c
--- /dev/null
+++ b/src/orchestration/views.py
@@ -0,0 +1,24 @@
+from django.shortcuts import render
+from django.core import serializers
+from django.http import HttpResponse, JsonResponse
+from .models import ImageSync, RemoteRegionSetup
+
+
+def index(request):
+ return HttpResponse("Hello world")
+
+
+def count(request, count):
+ data = {
+ 'name': 'Vitor',
+ 'location': 'Finland',
+ 'is_active': True,
+ 'count': count
+ }
+ return JsonResponse(data)
+
+
+def imagesync(request):
+ rec = ImageSync.objects.order_by('-remote_region_name')
+ return JsonResponse(serializers.serialize('json', rec), safe=False)
+