From 774c5f2485cef9939bad1a380409439ab14cdb11 Mon Sep 17 00:00:00 2001 From: vanzhiganov Date: Tue, 1 Dec 2015 02:32:52 +0300 Subject: [PATCH] init --- README.md | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..6920311 --- /dev/null +++ b/README.md @@ -0,0 +1,128 @@ +Version: 1.0 + +# Install + +``` +$ 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")``` \ No newline at end of file