Image Creation Message Corrected + ucloud-host read Physical Device for VXLAN from .env

This commit is contained in:
ahmadbilalkhalid 2019-11-12 15:26:10 +05:00
parent e37222c1c7
commit 5d613df33d
5 changed files with 183 additions and 3 deletions

View file

@ -108,7 +108,7 @@ class CreateImage(Resource):
os.path.join(IMAGE_PREFIX, data["uuid"]), json.dumps(image_entry_json)
)
return {"message": "Image successfully created"}
return {"message": "Image queued for creation."}
return validator.get_errors(), 400

View file

@ -40,7 +40,7 @@ Install Dependencies
apk add git python3 alpine-sdk python3-dev etcd etcd-ctl openntpd \
libffi-dev openssl-dev make py3-protobuf py3-tempita chrony \
qemu qemu-system-x86_64
qemu qemu-system-x86_64 qemu-img
pip3 install pipenv
@ -148,6 +148,8 @@ You just need to update **AUTH_SEED** in the below code to match your auth's see
ssh_username=meow
ssh_pkey="~/.ssh/id_rsa"
VXLAN_PHY_DEV="eth0"
EOF
@ -166,6 +168,10 @@ Install and configure ucloud-cli
UCLOUD_API_SERVER=http://localhost:5000
EOF
mkdir /var/www/
mkdir /var/image/
mkdir /var/vm/
Environment Variables and aliases
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View file

@ -3,6 +3,13 @@ Introduction
**Open** + **Simple** + **Easy to hack** + **IPv6 First**
ucloud is an easy to use cloud management system.
It is an alternative to OpenStack, OpenNebula or Cloudstack.
ucloud is the first cloud management system that puts IPv6 first. ucloud also has an integral ordering process that we missed in existing solutions.
Tech Stack
----------
* Python 3 as main language.

View file

@ -28,8 +28,175 @@ You should see something like the following
Start Scheduler
---------------
Scheduler is responsible for scheduling VMs on appropriate host.
.. code-block:: sh
ucloud scheduler
Start Host
----------
Host is responsible for handling the following actions
* Start VM.
* Stop VM.
* Create VM.
* Delete VM.
* Migrate VM.
* Manage Network Resources needed by VMs.
It uses a hypervisor such as QEMU to perform these actions.
To start host we created earlier, execute the following command
.. code-block:: sh
ucloud host ungleich.ch
Create OS Image
---------------
First, we need to upload the file.
.. code-block:: sh
mkdir /var/www/admin
(cd /var/www/admin && wget http://[2a0a:e5c0:2:12:0:f0ff:fea9:c3d9]/alpine-untouched.qcow2)
Run File Scanner and Image Scanner
------------------------------------
Currently, our uploaded file *alpine-untouched.qcow2* is not tracked by ucloud. We can only make
images from tracked files. So, we need to track the file by running File Scanner
.. code-block:: sh
ucloud filescanner
File Scanner would run, scan your uploaded image and track it. You can check whether your image
is successfully tracked by executing the :code:`ucloud-cli user files`, It will return something like the following
.. _list-user-files:
.. code-block:: json
{
"message": [
{
"filename": "alpine-untouched.qcow2",
"uuid": "3f75bd20-45d6-4013-89c4-7fceaedc8dda"
}
]
}
Our file is now being tracked by ucloud. Lets create an OS image using the uploaded file.
An image belongs to an image store. There are two types of store
* Public Image Store
* Private Image Store (Not Implemented Yet)
.. note::
**Quick Quiz** Have we create an image store yet?
The answer is **No, we haven't**. Creating an example image store is very easy.
Just execute the following command
.. code-block:: sh
pipenv run python ~/ucloud/api/create_image_store.py
An image store (with name = "images") would be created. Now, we are fully ready for creating our
very own image. Executing the following command to create image using the file uploaded earlier
.. code-block:: sh
ucloud-cli image create-from-file --name alpine --uuid 3f75bd20-45d6-4013-89c4-7fceaedc8dda --image-store-name images
Please note that your **uuid** would be different. See :ref:`List of user files <list-user-files>`.
Now, ucloud have received our request to create an image from file. We have to run Image Scanner to make the image.
.. code-block:: sh
ucloud imagescanner
To make sure, that our image is create run :code:`ucloud-cli image list --public`. You would get
output something like the following
.. code-block:: json
{
"images": [
{
"name": "images:alpine",
"status": "CREATED"
}
]
}
Create VM
---------
The following command would create a Virtual Machine (name: meow) with following specs
* CPU: 1
* RAM: 1GB
* OS-SSD: 4GB
* OS: Alpine Linux
.. code-block:: sh
ucloud-cli vm create --vm-name meow --cpu 1 --ram '1gb' --os-ssd '4gb' --image images:alpine
Check VM Status
---------------
.. code-block:: sh
ucloud-cli vm status --vm-name meow
.. code-block:: json
{
"hostname": "/v1/host/74c21c332f664972bf5078e8de080eea",
"image_uuid": "3f75bd20-45d6-4013-89c4-7fceaedc8dda",
"in_migration": null,
"log": [
"2019-11-12T09:11:09.800798 - Started successfully"
],
"metadata": {
"ssh-keys": []
},
"name": "meow",
"network": [],
"owner": "admin",
"owner_realm": "ungleich-admin",
"specs": {
"cpu": 1,
"hdd": [],
"os-ssd": "4.0 GB",
"ram": "1.0 GB"
},
"status": "RUNNING",
"vnc_socket": "/tmp/tmpj1k6sdo_"
}
Create Network
--------------
.. code-block:: sh
ucloud-cli network create --network-name mynet --network-type vxlan
.. code-block:: json
{
"message": "Network successfully added."
}
Create VM using this network
.. code-block:: sh
ucloud-cli vm create --vm-name meow2 --cpu 1 --ram '1gb' --os-ssd '4gb' --image images:alpine --network mynet

View file

@ -121,7 +121,7 @@ def get_start_command_args(
network_id = str(network.value["id"])
if network_type == "vxlan":
tap = create_vxlan_br_tap(network_id, "eno1")
tap = create_vxlan_br_tap(network_id, config("VXLAN_PHY_DEV"))
command += " -netdev tap,id=vmnet{net_id},ifname={tap},script=no,downscript=no"\
" -device virtio-net-pci,netdev=vmnet{net_id},mac={mac}"\