From 11d629bb512854560cd5f720fd22921dca18c6ef Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 27 Feb 2020 11:42:42 +0100 Subject: [PATCH] [uncloud_api] completely remove it --- uncloud/uncloud_api/__init__.py | 0 uncloud/uncloud_api/admin.py | 6 --- uncloud/uncloud_api/apps.py | 5 -- uncloud/uncloud_api/management/__init__.py | 0 .../management/commands/__init__.py | 0 .../uncloud_api/management/commands/hack.py | 26 ---------- .../management/commands/snapshot.py | 29 ----------- .../uncloud_api/migrations/0001_initial.py | 31 ----------- .../0002_vmsnapshotproduct_vm_uuid.py | 19 ------- .../migrations/0003_auto_20200225_1950.py | 36 ------------- uncloud/uncloud_api/migrations/__init__.py | 0 uncloud/uncloud_api/serializers.py | 8 --- uncloud/uncloud_api/tests.py | 3 -- uncloud/uncloud_api/views.py | 51 ------------------- 14 files changed, 214 deletions(-) delete mode 100644 uncloud/uncloud_api/__init__.py delete mode 100644 uncloud/uncloud_api/admin.py delete mode 100644 uncloud/uncloud_api/apps.py delete mode 100644 uncloud/uncloud_api/management/__init__.py delete mode 100644 uncloud/uncloud_api/management/commands/__init__.py delete mode 100644 uncloud/uncloud_api/management/commands/hack.py delete mode 100644 uncloud/uncloud_api/management/commands/snapshot.py delete mode 100644 uncloud/uncloud_api/migrations/0001_initial.py delete mode 100644 uncloud/uncloud_api/migrations/0002_vmsnapshotproduct_vm_uuid.py delete mode 100644 uncloud/uncloud_api/migrations/0003_auto_20200225_1950.py delete mode 100644 uncloud/uncloud_api/migrations/__init__.py delete mode 100644 uncloud/uncloud_api/serializers.py delete mode 100644 uncloud/uncloud_api/tests.py delete mode 100644 uncloud/uncloud_api/views.py diff --git a/uncloud/uncloud_api/__init__.py b/uncloud/uncloud_api/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/uncloud/uncloud_api/admin.py b/uncloud/uncloud_api/admin.py deleted file mode 100644 index d242668..0000000 --- a/uncloud/uncloud_api/admin.py +++ /dev/null @@ -1,6 +0,0 @@ -from django.contrib import admin - -from .models import Product, Feature - -#admin.site.register(Product) -#admin.site.register(Feature) diff --git a/uncloud/uncloud_api/apps.py b/uncloud/uncloud_api/apps.py deleted file mode 100644 index 6830fa2..0000000 --- a/uncloud/uncloud_api/apps.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.apps import AppConfig - - -class ApiConfig(AppConfig): - name = 'uncloud_api' diff --git a/uncloud/uncloud_api/management/__init__.py b/uncloud/uncloud_api/management/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/uncloud/uncloud_api/management/commands/__init__.py b/uncloud/uncloud_api/management/commands/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/uncloud/uncloud_api/management/commands/hack.py b/uncloud/uncloud_api/management/commands/hack.py deleted file mode 100644 index e129952..0000000 --- a/uncloud/uncloud_api/management/commands/hack.py +++ /dev/null @@ -1,26 +0,0 @@ -import time -from django.conf import settings -from django.core.management.base import BaseCommand - -import uncloud_api.models - -import inspect -import sys -import re - -class Command(BaseCommand): - args = '' - help = 'hacking - only use if you are Nico' - - def add_arguments(self, parser): - parser.add_argument('command', type=str, help='Command') - - def handle(self, *args, **options): - getattr(self, options['command'])(**options) - - @classmethod - def classtest(cls, **_): - clsmembers = inspect.getmembers(sys.modules['uncloud_api.models'], inspect.isclass) - for name, c in clsmembers: - if re.match(r'.+Product$', name): - print("{} -> {}".format(name, c)) diff --git a/uncloud/uncloud_api/management/commands/snapshot.py b/uncloud/uncloud_api/management/commands/snapshot.py deleted file mode 100644 index 41d0e38..0000000 --- a/uncloud/uncloud_api/management/commands/snapshot.py +++ /dev/null @@ -1,29 +0,0 @@ -import time -from django.conf import settings -from django.core.management.base import BaseCommand - -from uncloud_api import models - - -class Command(BaseCommand): - args = '' - help = 'VM Snapshot support' - - def add_arguments(self, parser): - parser.add_argument('command', type=str, help='Command') - - def handle(self, *args, **options): - print("Snapshotting") - #getattr(self, options['command'])(**options) - - @classmethod - def monitor(cls, **_): - while True: - try: - tweets = models.Reply.get_target_tweets() - responses = models.Reply.objects.values_list('tweet_id', flat=True) - new_tweets = [x for x in tweets if x.id not in responses] - models.Reply.send(new_tweets) - except TweepError as e: - print(e) - time.sleep(60) diff --git a/uncloud/uncloud_api/migrations/0001_initial.py b/uncloud/uncloud_api/migrations/0001_initial.py deleted file mode 100644 index 67bdd2e..0000000 --- a/uncloud/uncloud_api/migrations/0001_initial.py +++ /dev/null @@ -1,31 +0,0 @@ -# Generated by Django 3.0.3 on 2020-02-23 17:12 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion -import uuid - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ] - - operations = [ - migrations.CreateModel( - name='VMSnapshotProduct', - fields=[ - ('uuid', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('status', models.CharField(choices=[('pending', 'Pending'), ('being_created', 'Being created'), ('active', 'Active'), ('deleted', 'Deleted')], default='pending', max_length=256)), - ('gb_ssd', models.FloatField()), - ('gb_hdd', models.FloatField()), - ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), - ], - options={ - 'abstract': False, - }, - ), - ] diff --git a/uncloud/uncloud_api/migrations/0002_vmsnapshotproduct_vm_uuid.py b/uncloud/uncloud_api/migrations/0002_vmsnapshotproduct_vm_uuid.py deleted file mode 100644 index b35317e..0000000 --- a/uncloud/uncloud_api/migrations/0002_vmsnapshotproduct_vm_uuid.py +++ /dev/null @@ -1,19 +0,0 @@ -# Generated by Django 3.0.3 on 2020-02-25 18:16 - -from django.db import migrations, models -import uuid - - -class Migration(migrations.Migration): - - dependencies = [ - ('uncloud_api', '0001_initial'), - ] - - operations = [ - migrations.AddField( - model_name='vmsnapshotproduct', - name='vm_uuid', - field=models.UUIDField(default=uuid.uuid4, editable=False), - ), - ] diff --git a/uncloud/uncloud_api/migrations/0003_auto_20200225_1950.py b/uncloud/uncloud_api/migrations/0003_auto_20200225_1950.py deleted file mode 100644 index be7624c..0000000 --- a/uncloud/uncloud_api/migrations/0003_auto_20200225_1950.py +++ /dev/null @@ -1,36 +0,0 @@ -# Generated by Django 3.0.3 on 2020-02-25 19:50 - -from django.conf import settings -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - dependencies = [ - migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('uncloud_api', '0002_vmsnapshotproduct_vm_uuid'), - ] - - operations = [ - migrations.AlterField( - model_name='vmsnapshotproduct', - name='gb_hdd', - field=models.FloatField(editable=False), - ), - migrations.AlterField( - model_name='vmsnapshotproduct', - name='gb_ssd', - field=models.FloatField(editable=False), - ), - migrations.AlterField( - model_name='vmsnapshotproduct', - name='owner', - field=models.ForeignKey(editable=False, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), - ), - migrations.AlterField( - model_name='vmsnapshotproduct', - name='vm_uuid', - field=models.UUIDField(), - ), - ] diff --git a/uncloud/uncloud_api/migrations/__init__.py b/uncloud/uncloud_api/migrations/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/uncloud/uncloud_api/serializers.py b/uncloud/uncloud_api/serializers.py deleted file mode 100644 index 89f4e83..0000000 --- a/uncloud/uncloud_api/serializers.py +++ /dev/null @@ -1,8 +0,0 @@ -from django.contrib.auth import get_user_model - -from rest_framework import serializers - -class UserSerializer(serializers.ModelSerializer): - class Meta: - model = get_user_model() - fields = ['url', 'username', 'email'] diff --git a/uncloud/uncloud_api/tests.py b/uncloud/uncloud_api/tests.py deleted file mode 100644 index 7ce503c..0000000 --- a/uncloud/uncloud_api/tests.py +++ /dev/null @@ -1,3 +0,0 @@ -from django.test import TestCase - -# Create your tests here. diff --git a/uncloud/uncloud_api/views.py b/uncloud/uncloud_api/views.py deleted file mode 100644 index c90b963..0000000 --- a/uncloud/uncloud_api/views.py +++ /dev/null @@ -1,51 +0,0 @@ -from django.shortcuts import render -from django.contrib.auth import get_user_model -from django.contrib.auth.models import Group - -from rest_framework import viewsets, permissions, generics - -from rest_framework.views import APIView -from rest_framework.response import Response - -from .serializers import UserSerializer - -import inspect -import sys -import re - - - -# maybe drop or not --- we need something to guide the user! -# class ProductsViewSet(viewsets.ViewSet): -# permission_classes = [permissions.IsAuthenticated] - -# def list(self, request): - -# clsmembers = [] -# for modules in [ 'uncloud_api.models', 'uncloud_vm.models' ]: -# clsmembers.extend(inspect.getmembers(sys.modules[modules], inspect.isclass)) - - -# products = [] -# for name, c in clsmembers: -# # Include everything that ends in Product, but not Product itself -# m = re.match(r'(?P.+)Product$', name) -# if m: -# products.append({ -# 'name': m.group('pname'), -# 'description': c.description, -# 'recurring_period': c.recurring_period, -# 'pricing_model': c.pricing_model() -# } -# ) - - -# return Response(products) - - -class UserViewSet(viewsets.ModelViewSet): - serializer_class = UserSerializer - permission_classes = [permissions.IsAuthenticated] - - def get_queryset(self): - return self.request.user