ITDevLtd / MCVirt

MCVirt - Command line virtual machine management utility
http://mcvirt.itdev.co.uk
GNU General Public License v2.0
24 stars 7 forks source link

Write development practices #383

Open MatthewJohn opened 6 years ago

MatthewJohn commented 6 years ago

When developing on MCVirt (and particularly adding new functionality), there's a lot of combined boiler plating, used to exposing methods, permissions etc. which need documenting.

MatthewJohn commented 5 years ago

Since the project has been stale for a month or so, I will write documentation for bits and pieces that I pick up

MatthewJohn commented 5 years ago

Should create a class, which does everything as we expect to continue, i.e. exposing of methods, permissions, well layed out factory etc.

MatthewJohn commented 5 years ago

Initial setup notes:

Create virtual machine(s):
* Generally best to developer with 3 VMs
* Usually use 15GB HDD (20/25 might be better)
* 1 cpu core and 1GB RAM each
* Ensure that 'CPU feature passthrough' is enabled (
* Ensure that the VMs are on the same network, have access to the internet and are accessible from your PC (probably NAT network or similar)

* Generally develop using Ubuntu 18.04. (CI on build server runs against Ubuntu 14.04, 16.04, 18.04, Debian 8 and 9)
* Generally good to name the VMs something like 'mcvirt1, mcvirt2...'
* During installation: Use LVM and allocate around 5GB

Once installed, on each VM:
* Copy your SSH public key to root user on each VM, so that you can login automatically to root user.
* Update the VM name in /etc/hosts on the machine so that the names resolves to the private IP (not 127.0.0.1)

Clone repo on local machine and rsync to each of the VMs
Use https://github.com/ITDevLtd/MCVirt/blob/add-installation-steps/scripts/get_build_install.sh on each of the VMs:
{{{
curl https://github.com/ITDevLtd/MCVirt/blob/add-installation-steps/scripts/get_build_install.sh | SOURCE_PATH=/path/to/rsynced/workingcopy bash -
}}}

Update /etc/network/interfaces, so that:
* Update ensX (or ethX) interface is set to manual
* Add the following:
{{{
auto vmbr0
iface vmbr0 inet manual
 bridge_ports XXXX
 bridge_stp off
 bridge_fd 0
}}}
Replacing XXXX with the name of the interface ethX or ensX
Reboot VM

## Configuring
On each VM
Set IP address:
mcvirt node --set-cluster-ip xxx.xxx.xxx.xxx
Replacing with the IP address of the VM

Create a cluster:

On a VM, run:
mcvirt cluster get-connect-string

On another node, run:
mcvirt cluster add-node --connection-string <Output from other VM>

Repeat this, running the first command on the third VM, ensuring that the second command is run on a machine that this has already been performed on. e.g. join 2 to 1 and then 3 to 1.

Create storage:
mcvirt storage add --type Lvm --node mcvirt1 mcvirt1-vg --node mcvirt2 mcvirt2-vg --node mcvirt3 mcvirt3-vg local-vg-store

Create network
mcvirt network create --physical-interface vmbr0 local-net
MatthewJohn commented 5 years ago
Whilst developing, if you receive: 'Could not connect to connect to X. Is the MCVirt daemon/nameserver running'
Try running 'mcvirtd' manually to see if it's throwing an exception