python-compute/docs/source/cli/getting_started.rst

133 lines
3.1 KiB
ReStructuredText
Raw Permalink Normal View History

2023-12-13 01:42:50 +03:00
Getting started
===============
2023-12-03 23:25:34 +03:00
Creating compute instances
--------------------------
2023-12-13 01:42:50 +03:00
Compute instances are created through a description in yaml format. The description may be partial, the configuration will be supplemented with default parameters.
2023-12-03 23:25:34 +03:00
2023-12-13 01:42:50 +03:00
This page describes how to start up a basic instance, you'll probably want to use cloud-init to get the guest up and running, see the instructions at `Using cloud-init <cloud_init.html>`_.
The following examples contains minimal instance configuration. See also full example `here <instance_file.html>`_
Using prebuilt QCOW2 disk image
```````````````````````````````
First place your image into ``images`` pool path.
Create :file:`instance.yaml` config file with following content. Replace `debian_12.qcow2` with your actual image filename.
2023-12-03 23:25:34 +03:00
.. code-block:: yaml
:caption: Using prebuilt QCOW2 disk image
:emphasize-lines: 4
:linenos:
name: myinstance
memory: 2048
vcpus: 2
image: debian_12.qcow2
volumes:
- type: file
is_system: true
capacity:
value: 10
unit: GiB
Check out what configuration will be applied when ``init``::
2023-12-13 01:42:50 +03:00
compute init --test
2023-12-03 23:25:34 +03:00
Initialise instance with command::
compute init
Also you can use following syntax::
compute init yourfile.yaml
Start instance::
compute start myinstance
Using ISO installation medium
`````````````````````````````
Download ISO image and set it as source for ``cdrom`` device.
Note that the ``image`` parameter is not used here.
.. code-block:: yaml
:caption: Using ISO image
2023-12-13 01:42:50 +03:00
:emphasize-lines: 10-12
2023-12-03 23:25:34 +03:00
:linenos:
name: myinstance
memory: 2048
vcpus: 2
volumes:
- type: file
is_system: true
capacity:
value: 10
unit: GiB
- type: file
device: cdrom
source: /images/debian-12.2.0-amd64-netinst.iso
::
compute init
Now edit instance XML configuration to add VNC-server listen address::
virsh edit myinstance
Add ``address`` attribute to start listen on all host network interfaces.
.. code-block:: xml
:caption: libvirt XML config fragment
:emphasize-lines: 2
2023-12-13 01:42:50 +03:00
<graphics type='vnc' port='-1' autoport='yes'>
2023-12-03 23:25:34 +03:00
<listen type='address' address='0.0.0.0'/>
</graphics>
Also you can specify VNC server port. This is **5900** by default.
Start instance and connect to VNC via any VNC client such as `Remmina <https://remmina.org/>`_ or something else.
::
compute start myinstance
Finish the OS installation over VNC and then do::
2023-12-13 01:42:50 +03:00
compute setcdrom myinstance --detach /images/debian-12.2.0-amd64-netinst.iso
2023-12-03 23:25:34 +03:00
compute powrst myinstance
CDROM will be detached. ``powrst`` command will perform instance shutdown and start. Instance will booted from `vda` disk.
2023-12-13 01:42:50 +03:00
Using existing disk
```````````````````
Place your disk image in ``volumes`` storage pool.
Replace `/volume/myvolume.qcow2` with actual path to disk.
.. code-block:: yaml
:caption: Using existing disk
:emphasize-lines: 7
:linenos:
name: myinstance
memory: 2048
vcpus: 2
volumes:
- type: file
is_system: true
source: /volumes/myvolume.qcow2
Initialise and start instance::
compute init --start