Commit 0a365fab authored by Furkan Mustafa's avatar Furkan Mustafa

remove beiran_cli module. merge it into client library

Reasoning: they always move together
cli is just a small wrapper around the client library. therefore merging.
this also helps with module naming
parent d3cc3667
......@@ -8,6 +8,5 @@ run
*
!beirand
!beiran
!beiran_cli
!Dockerfile
!plugins
......@@ -25,17 +25,11 @@ pipeline:
commands:
- pylint beirand/beirand
lint-lib:
lint-client:
image: dkr.rsnc.io/poc/beiran/pylint:drone-build-${DRONE_BUILD_NUMBER}
group: lint
commands:
- pylint beiran
lint-cli:
image: dkr.rsnc.io/poc/beiran/pylint:drone-build-${DRONE_BUILD_NUMBER}
group: lint
commands:
- pylint beiran_cli
dockerd:
image: docker:18.03.0-ce-dind
......
......@@ -10,9 +10,6 @@ WORKDIR /opt
ADD beiran/requirements.txt /opt/beiran/r-lib.txt
RUN pip install -r /opt/beiran/r-lib.txt
ADD beiran_cli/requirements.txt /opt/beiran/r-cli.txt
RUN pip install -r /opt/beiran/r-cli.txt
ADD beirand/requirements.txt /opt/beiran/r-daemon.txt
RUN pip install -r /opt/beiran/r-daemon.txt
......@@ -30,7 +27,6 @@ RUN pip install -r /opt/beiran/r-docker.txt
ADD [ "beirand", "/opt/beiran/beirand" ]
ADD [ "beiran", "/opt/beiran/beiran" ]
ADD [ "beiran_cli", "/opt/beiran/beiran_cli" ]
ADD [ "plugins/beiran_discovery_dns", "/opt/beiran/beiran_discovery_dns" ]
ADD [ "plugins/beiran_discovery_zeroconf", "/opt/beiran/beiran_discovery_zeroconf" ]
......
......@@ -61,17 +61,10 @@ Storage Driver: overlay2
### - Setup
This will setup a virtualenv under `env` folder here
```sh
mkdir env
virtualenv env --python=$(which python3.6)
source env/bin/activate
pip install -r beirand/requirements.txt
pip install -r beiran/requirements.txt
pip install -r beiran_cli/requirements.txt
pip install ipython
ln -s $(pwd)/beirand/beirand env/lib/python3.6/site-packages/
ln -s $(pwd)/beiran env/lib/python3.6/site-packages/
ln -s $(pwd)/beiran_cli env/lib/python3.6/site-packages/
$ ./dev.sh
```
#### - Settings (Environment Variables)
......@@ -87,34 +80,34 @@ export CONFIG_FOLDER_PATH=$(pwd)
#### - Start Daemon
```sh
source env/bin/activate
python -m beirand
./dev.sh
beirand
```
or as root (potentially UNSAFE) to allow beiran to peek into /var/lib/docker
```sh
source env/bin/activate
sudo -E python -m beirand
./dev.sh
sudo -E beirand
```
#### - Use cli
```sh
python -m beiran_cli image list
beiran image list
```
## Build
```sh
./make.sh build_daemon_image
docker-compose build
```
## Environment variables
All has default values.
```sh
```
LISTEN_INTERFACE
LISTEN_ADDR
HOSTNAME
......@@ -124,8 +117,7 @@ BEIRAN_SOCK
## Using (PoC)
```sh
cd beirand
docker-compose up --scale beirand=3
docker-compose up
```
CURL'ing unix socket
......
"""Main script for beiran cli"""
from beiran_cli import cli
from .cli import main
cli.main()
main()
......@@ -9,14 +9,14 @@ from tabulate import tabulate
from beiran.util import exit_print
from beiran.util import Unbuffered
from beiran.version import get_version
from beiran.client import Client
from beiran.sync_client import Client
from beiran.log import build_logger
LOG_LEVEL = logging.getLevelName(os.getenv('LOG_LEVEL', 'WARNING'))
# LOG_FILE = os.getenv('LOG_FILE', '/var/log/beirand.log')
logger = build_logger(None, LOG_LEVEL) # pylint: disable=invalid-name
VERSION = get_version('short', 'cli')
VERSION = get_version('short', 'library')
sys.stdout = Unbuffered(sys.stdout)
......
tornado==4.5.2
peewee==3.1.2
click==6.7
tabulate==0.8.2
......@@ -103,7 +103,6 @@ class Client:
except Exception as error:
print("Cannot connect to beiran daemon at %s" % self.url)
print("Error: " + str(error))
sys.exit(1)
# Other errors are possible, such as IOError.
raise error
......@@ -173,7 +172,7 @@ class Client:
if node_uuid and all_nodes:
raise Exception("node_uuid and all_nodes cannot be defined at the same time")
path = '/images'
path = '/docker/images'
if node_uuid:
path = path + '?node={}'.format(node_uuid)
......@@ -192,7 +191,7 @@ class Client:
if node_uuid and all_nodes:
raise Exception("node_uuid and all_nodes cannot be defined at the same time")
path = '/layers'
path = '/docker/layers'
if node_uuid:
path = path + '?node={}'.format(node_uuid)
......
click==6.7
tabulate==0.8.2
......@@ -27,7 +27,7 @@ source ${DIR}/env/bin/activate
STAMP=$(date +%s)
INSTALLED=0
LAST_INSTALL=$(date -r ${DIR}/env/.last_install +%s 2>/dev/null || echo "0")
packages="beiran beirand beiran_cli plugins/*"
packages="beiran beirand plugins/*"
for package in $packages; do
package_name=$(basename $package)
if [ ! -d env/lib/python3.6/site-packages/$package_name ]; then
......@@ -47,19 +47,17 @@ if [ $INSTALLED -eq 1 ]; then
echo $STAMP > ${DIR}/env/.last_install
fi
if [ ! -x $VIRTUAL_ENV/bin/beiran ]; then
cat > $VIRTUAL_ENV/bin/beiran <<EOF
cat > $VIRTUAL_ENV/bin/beiran <<EOF
#!/bin/sh -e
exec python3.6 -m beiran_cli "\$@"
exec python3.6 -m beiran "\$@"
EOF
cat > $VIRTUAL_ENV/bin/beirand <<EOF
cat > $VIRTUAL_ENV/bin/beirand <<EOF
#!/bin/sh -e
exec python3.6 -m beirand "\$@"
EOF
chmod +x $VIRTUAL_ENV/bin/beiran*
fi
chmod +x $VIRTUAL_ENV/bin/beiran*
export PATH="$VIRTUAL_ENV/bin:$PATH"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment