diff --git a/PKG-INFO b/PKG-INFO index 851faff..1fc10d1 100755 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,10 +1,10 @@ -Metadata-Version: 0.0.1 +Metadata-Version: 1.0.0 Name: visualops -Version: 0.0.1 +Version: 1.0.0 Summary: VisualOps CLI Home-page: https://github.com/madeiracloud/cli -Author: Peng Zhao -Author-email: peng@visualops.io -License: UNKNOWN -Description: UNKNOWN +Author: Thibault Bronchain +Author-email: thibault@visualops.io +License: Apache License v2.0 +Description: CLI interface for VisualOps Platform: UNKNOWN diff --git a/README.rst b/README.rst index 351a37b..14dbfa2 100755 --- a/README.rst +++ b/README.rst @@ -9,7 +9,7 @@ note: output shown in this documentation is indicative only, please do not refer Requirements ------------ -Before install, ensure Docker is installed (see http://docs.docker.com) in version >= 1.2.0. +Before install, ensure Docker is installed (see http://docs.docker.com) in version >= 1.2.0 (1.3.1 is recommended). Platform -------- @@ -42,3 +42,9 @@ Use the help command to get help about one specific command: :: $ visualops help [command] + +Notes +----- + +When using `boot2docker` on OSX, ensure the latest version is installed (1.3.1 tested). +Not that only files/directories located under /Users will be mounted. diff --git a/setup.py b/setup.py index 18af87f..c5d86cc 100755 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ def grep(attrname): include_package_data=True, zip_safe=False, scripts=[], - install_requires=['cliff','requests>=2.2.1','six>=1.7.0','pyyaml','docker-py'], + install_requires=['cliff','requests>=2.6.0','six>=1.9.0','pyyaml','docker-py'], entry_points={ 'console_scripts': [ 'visualops = visualops.main:main' diff --git a/visualops/__init__.py b/visualops/__init__.py index 881ced1..7540058 100755 --- a/visualops/__init__.py +++ b/visualops/__init__.py @@ -1,2 +1,2 @@ -__version__ = '0.3.2' +__version__ = '1.0.2' VERSION = __version__ diff --git a/visualops/cmd/app/restart.py b/visualops/cmd/app/restart.py index 0a4f1f7..2a82703 100644 --- a/visualops/cmd/app/restart.py +++ b/visualops/cmd/app/restart.py @@ -74,6 +74,7 @@ def restart_app(self, config, appname, app_dict): boot2docker.run(config, appname) config["docker_sock"] = "tcp://%s:2375"%(boot2docker.ip(config,appname)) config["chroot"] = os.path.join("/mnt/host",config.get("chroot","")) + boot2docker.set_config(config,appname) config["hosts_table"] = app_dict.get("hosts_table",{}) app = {} for hostname in app_dict.get("hosts",{}): diff --git a/visualops/cmd/app/start.py b/visualops/cmd/app/start.py index 76aea1c..4dbbb43 100755 --- a/visualops/cmd/app/start.py +++ b/visualops/cmd/app/start.py @@ -77,7 +77,8 @@ def start_app(self, config, appname, app_dict): if boot2docker.has(): boot2docker.run(config, appname) config["docker_sock"] = "tcp://%s:2375"%(boot2docker.ip(config,appname)) - config["chroot"] = os.path.join("/mnt/host",config.get("chroot","")) +# config["chroot"] = os.path.join("/mnt/host",config.get("chroot","")) + boot2docker.set_config(config,appname) config["hosts_table"] = app_dict.get("hosts_table",{}) actions = {} for hostname in app_dict.get("hosts",{}): diff --git a/visualops/cmd/app/stop.py b/visualops/cmd/app/stop.py index a330540..c27b803 100755 --- a/visualops/cmd/app/stop.py +++ b/visualops/cmd/app/stop.py @@ -70,6 +70,7 @@ def stop_app(self, config, appname, app_dict): if boot2docker.has(): config["docker_sock"] = "tcp://%s:2375"%(boot2docker.ip(config,appname)) + boot2docker.set_config(config,appname) for hostname in app_dict.get("hosts",{}): for state in app_dict["hosts"][hostname]: if state == "linux.docker.deploy": diff --git a/visualops/cmd/app/terminate.py b/visualops/cmd/app/terminate.py index 9c3dd82..d106c4f 100755 --- a/visualops/cmd/app/terminate.py +++ b/visualops/cmd/app/terminate.py @@ -72,6 +72,7 @@ def take_action(self, parsed_args): def terminate_app(self, config, appname, app_dict): if boot2docker.has(): config["docker_sock"] = "tcp://%s:2375"%(boot2docker.ip(config,appname)) + boot2docker.set_config(config,appname) for hostname in app_dict.get("hosts",{}): for state in app_dict["hosts"][hostname]: if state == "linux.docker.deploy": diff --git a/visualops/cmd/stack/run.py b/visualops/cmd/stack/run.py index 1200b5a..f9b80b0 100755 --- a/visualops/cmd/stack/run.py +++ b/visualops/cmd/stack/run.py @@ -124,27 +124,28 @@ def run_stack(config, app_dict, force=True): os.makedirs(config["dirs"][d]) if boot2docker.has(): print "Starting Boot2docker ... (this may take a while)" - if not os.path.isfile(os.path.join(config["dirs"]["boot2docker"],"boot2docker.iso")): - utils.download(config["boot2docker_iso"],os.path.join(config["dirs"]["boot2docker"],"boot2docker.iso")) +# if not os.path.isfile(os.path.join(config["dirs"]["boot2docker"],"boot2docker.iso")): +# utils.download(config["boot2docker_iso"],os.path.join(config["dirs"]["boot2docker"],"boot2docker.iso")) if not boot2docker.gen_config(config, config["appname"]): utils.error("Unable to generate boot2docker configuration") return False boot2docker.delete(config, config["appname"]) boot2docker.init(config, config["appname"]) - boot2docker.mount(config["appname"], [{ - "volume": "visops_root", - "hostpath": "/", - },{ - "volume": "visops_containers", - "hostpath": config["dirs"]["containers"], - }]) +# boot2docker.mount(config["appname"], [{ +# "volume": "visops_root", +# "hostpath": "/", +# },{ +# "volume": "visops_containers", +# "hostpath": config["dirs"]["containers"], +# }]) if boot2docker.run(config, config["appname"]): print "Boot2docker successfully running!" else: utils.error("Unable to run Boot2docker.") - config["chroot"] = os.path.join("/mnt/host",config.get("chroot","")) +# config["chroot"] = os.path.join("/mnt/host",config.get("chroot","")) config["docker_sock"] = "tcp://%s:2375"%(boot2docker.ip(config,config["appname"])) + boot2docker.set_config(config,config["appname"]) config["hosts_table"] = app_dict.get("hosts_table",{}) actions = {} for hostname in app_dict.get("hosts",{}): diff --git a/visualops/utils/boot2docker.py b/visualops/utils/boot2docker.py index 6ea8fff..72d2f79 100755 --- a/visualops/utils/boot2docker.py +++ b/visualops/utils/boot2docker.py @@ -23,10 +23,13 @@ def running(config, appid, verbose=False): return False if not re.search("running",out): return False if verbose: + ip_addr = ip(config,appid) print "Boot2docker VM ip: %s\nTo use the docker client in a terminal, set the following environment variable:\n\n%s"%( - ip(config,appid), + ip_addr, shellinit(config,appid) ) + print "If you are using boot2docker >= 1.3.0, you must add an entry to you host file in order to be able to use the TLS authentication.\n\nPlease, add the following entry to your local host file (`/etc/hosts`):\n\n%s boot2docker\n\n"%(ip_addr) + raw_input("Press Enter to continue...") return True # Get boot2docker VM IP @@ -41,6 +44,15 @@ def ip(config, appid): return "127.0.0.1" return out +# Set boot2docker VM configuration +def set_config(config, appid): + conf = shellinit(config,appid).split("\n") + for v in conf: + v = v.strip() + if v: + v = v.split(" ")[-1].split("=") + os.environ[v[0]] = v[1] + # Run boot2docker VM def run(config, appid, verbose=True): if running(config, appid, verbose) is not True: @@ -122,7 +134,8 @@ def gen_config(config, appid, replace=True): conf = { "VM":"\"%s\""%appid, "Dir":"\"%s\""%config["dirs"]["boot2docker"], - "ISO":"\"%s\""%os.path.join(config["dirs"]["boot2docker"],"boot2docker.iso"), + "ISO":"\"%s\""%os.path.join(os.path.expanduser("~/.visualops"),"boot2docker.iso"), +# "ISO":"\"%s\""%os.path.join(config["dirs"]["boot2docker"],"boot2docker.iso"), "SerialFile":"\"%s\""%os.path.join(config["dirs"]["boot2docker"],"%s.sock"%appid), } out = re.sub(r"boot2docker profile filename:(.*)\n","", out) diff --git a/visualops/utils/dockervisops.py b/visualops/utils/dockervisops.py index 2a52b41..874b33c 100755 --- a/visualops/utils/dockervisops.py +++ b/visualops/utils/dockervisops.py @@ -10,11 +10,14 @@ import time import json import os -import docker import datetime import re import socket +import docker +from docker.client import Client +from docker.utils import kwargs_from_env + import visualops from visualops.utils import boot2docker from visualops.utils import utils @@ -74,7 +77,12 @@ def _get_client(config, url=None, version=None, timeout=None): ''' if config.get("docker_sock"): url=config["docker_sock"] - client = docker.Client(base_url=url) + try: + client = docker.Client(**kwargs_from_env()) + print "New docker version detected" + except Exception: + client = docker.Client(base_url=url) + print "Old docker version detected" # force 1..5 API for registry login if not version: if client._version == '1.4': diff --git a/visualops/utils/utils.py b/visualops/utils/utils.py index 1b67ed1..903d52b 100755 --- a/visualops/utils/utils.py +++ b/visualops/utils/utils.py @@ -90,7 +90,7 @@ def load_current_project(): project_cfg = home_folder + '/.visualops/project' if not os.path.isfile(project_cfg): print('please run "visualops project list" first!') - return (None, None) + return (None, None, None) config = ConfigParser.SafeConfigParser() config.read(project_cfg) project_name = config.get('config','project_name') @@ -99,7 +99,7 @@ def load_current_project(): return (project_name, project_id,key_id) except: print('load project failed, try login again!') - return (None, None) + return (None, None, None) #Handle AppService Error def hanlde_error(err, result):