144 lines
2 KiB
Markdown
144 lines
2 KiB
Markdown
# SWSCloudNode
|
|
|
|
Version: 1.0
|
|
|
|
## Install
|
|
|
|
### rockylinux 9
|
|
|
|
```shell
|
|
dnf install -y python3-netaddr python3-libvirt python3-requests
|
|
```
|
|
|
|
### ubuntu (old)
|
|
|
|
```
|
|
$ apt-get install sqlite3
|
|
$ apt-get install lxc
|
|
$ apt-get install python-pip
|
|
$ pip install pylxc
|
|
$ pip install simplejson
|
|
$ pip install pyparsing
|
|
$ apt-get install dnsmasq
|
|
```
|
|
|
|
## Setting DNSMASQ
|
|
|
|
Uncomment string in file `/etc/dnsmasq.conf`:
|
|
|
|
```conf-file=/etc/lxc/dnsmasq.conf```
|
|
|
|
Create config file and create simlink:
|
|
|
|
```
|
|
touch /etc/lxc/dnsmasq.conf
|
|
```
|
|
|
|
Change some lines in file: ```/etc/default/lxc```
|
|
|
|
```
|
|
LXC_AUTO="true"
|
|
LXC_SHUTDOWN_TIMEOUT=120
|
|
```
|
|
|
|
Change some lines in file: ```/etc/default/lxc-net```
|
|
|
|
```
|
|
USE_LXC_BRIDGE="true"
|
|
...
|
|
LXC_BRIDGE="lxcbr0"
|
|
LXC_ADDR="10.0.3.1"
|
|
LXC_NETMASK="255.255.255.0"
|
|
LXC_NETWORK="10.0.3.0/24"
|
|
LXC_DHCP_RANGE="10.0.3.2,10.0.3.254"
|
|
LXC_DHCP_MAX="253"
|
|
...
|
|
LXC_DHCP_CONFILE=/etc/lxc/dnsmasq.conf
|
|
...
|
|
LXC_DOMAIN="container.ly"
|
|
...
|
|
```
|
|
|
|
## Firewall
|
|
|
|
### Forwarding
|
|
|
|
`nano /etc/sysctl.conf`
|
|
|
|
`net.ipv4.ip_forward=1`
|
|
|
|
### UFW
|
|
|
|
`nano /etc/default/ufw`
|
|
|
|
and change string
|
|
|
|
`DEFAULT_FORWARD_POLICY="DROP"`
|
|
|
|
to
|
|
|
|
`DEFAULT_FORWARD_POLICY="ACCEPT"`
|
|
|
|
```
|
|
$ ufw allow 22
|
|
$ ufw allow 5555
|
|
$ ufw allow 7001
|
|
$ ufw enable
|
|
```
|
|
|
|
## Requests
|
|
|
|
task_get
|
|
task_update
|
|
report_container_status
|
|
report_container_info
|
|
|
|
## Methods
|
|
|
|
container_create
|
|
container_destroy
|
|
container_start
|
|
container_stop
|
|
container_restart
|
|
container_clone
|
|
|
|
service_mx_add
|
|
service_mx_delete
|
|
|
|
service_web_add
|
|
service_web_delete
|
|
service_web_update
|
|
|
|
service_ssh_allow
|
|
service_ssh_deny
|
|
|
|
# Using
|
|
|
|
For execute task from central server (create, start, stop and destroy container)
|
|
|
|
```python client.py```
|
|
|
|
For collect information about containers and host-system into local database
|
|
|
|
```python logger.py```
|
|
|
|
## API
|
|
|
|
List containers
|
|
|
|
```lxc().list()```
|
|
|
|
Check exists container with name 'test'
|
|
|
|
```lxc().exists("control.container.ly")```
|
|
|
|
Start container
|
|
|
|
```lxc().start("control.container.ly")```
|
|
|
|
|
|
## Develop
|
|
|
|
### Publish to Pypi server
|
|
|
|
`python setup.py sdist register -r local upload -r local`
|