feat: docs: vm management commands
ci/woodpecker/push/woodpecker Pipeline was successful
Details
ci/woodpecker/push/woodpecker Pipeline was successful
Details
parent
927c2a7703
commit
71d4f793ba
|
@ -0,0 +1,28 @@
|
|||
## Manage Virtual Machines
|
||||
|
||||
### 1. Create VM: Creates a new VM, bypasing payments
|
||||
|
||||
#### Pre-requisites:
|
||||
|
||||
1. A registered and active/email-verified user
|
||||
|
||||
#### Example:
|
||||
|
||||
```bash
|
||||
python manage.py vm create <VM-name> --owner=<owner-username> --flavor=<flavor>
|
||||
# flavor=[small,medium,large]
|
||||
```
|
||||
|
||||
This command is not idempotent. The command throws an error when a
|
||||
supplied flavor is not available or when a VM with the same name exists.
|
||||
|
||||
### 2. Delete VM:
|
||||
|
||||
#### Example
|
||||
|
||||
```bash
|
||||
python manage.py vm delete <VM-name>
|
||||
```
|
||||
|
||||
This command is not idempotent. The command throws an error when a
|
||||
a VM with the given name doesn't exist.
|
|
@ -1,77 +0,0 @@
|
|||
# Create your tests here.
|
||||
|
||||
# Copyright © 2022 Aravinth Manivannan <realaravinth@batsense.net>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as
|
||||
# published by the Free Software Foundation, either version 3 of the
|
||||
# License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
import time
|
||||
import os
|
||||
from io import StringIO
|
||||
from urllib.parse import urlparse, urlunparse
|
||||
|
||||
import requests
|
||||
|
||||
from django.core import mail
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.core.management import call_command
|
||||
from django.urls import reverse
|
||||
from django.test import TestCase, Client, override_settings
|
||||
from django.utils.http import urlencode
|
||||
from django.contrib.auth import authenticate
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
from accounts.tests import register_util
|
||||
from dash.models import Instance
|
||||
from infrastructure.models import InstanceCreated, InstanceConfiguration
|
||||
|
||||
|
||||
class VMCommands(TestCase):
|
||||
"""
|
||||
Test command: manage.py create_oidc
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.username = "hosteacustomer"
|
||||
register_util(t=self, username=self.username)
|
||||
self.vm_name = "MyHosteaVM"
|
||||
|
||||
def test_cmd(self):
|
||||
|
||||
Application = get_application_model()
|
||||
|
||||
stdout = StringIO()
|
||||
stderr = StringIO()
|
||||
|
||||
redirect_uri = "http://example.org"
|
||||
app_name = "test_cmd_oidc"
|
||||
|
||||
self.assertEqual(Instance.objects.filter(name=vm_name).exists(), False)
|
||||
# username exists
|
||||
call_command(
|
||||
"vm", "create", self.vm_name, f"--owner={self.username}", "==flavor=medium"
|
||||
)
|
||||
out = stdout.getvalue()
|
||||
|
||||
self.assertIn(f"Instance created", out)
|
||||
|
||||
instance = Instance.objects.get(name=self.vm_name)
|
||||
self.assertEqual(instance.owned_by, self.user)
|
||||
self.assertEqual(
|
||||
instance.configuration_id, InstanceConfiguration.objects.get(name="s1-4")
|
||||
)
|
||||
|
||||
instance_created = InstanceCreated.objects.get(name=self.vm_name)
|
||||
self.assertEqual(instance_created.instance, instance)
|
||||
|
||||
self.assertEqual(instance_created.created, True)
|
Loading…
Reference in New Issue