#!/usr/bin/env python ''' This file is part of LIO(tm). Copyright (c) 2012-2014 by Datera, Inc. More information on www.datera.io. Original author: Jerome Martin Datera and LIO are trademarks of Datera, Inc., which may be registered in some jurisdictions. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' import sys from pyparsing import ParseException from rtslib.config import ConfigError from targetcli.cli_live import CliLive from targetcli.cli_config import CliConfig from targetcli.cli_logger import logger as log # TODO Add tests for non-interactive mode # TODO Add batch mode if stdin is not a terminal if __name__ == '__main__': try: args = sys.argv[1:] if not args: config = 'live' CliLive(interactive=True).cmdloop() elif args[0] == "configure" and len(args) == 1: config = 'candidate' CliConfig(interactive=True).cmdloop() elif args[0] == "configure": config = 'candidate' CliConfig(interactive=False).onecmd(" ".join(args[1:])) else: config = 'live' CliLive(interactive=False).onecmd(" ".join(args)) except IOError, e: log.critical("Failed to read %s configuration: %s" % (config, e)) log.info("Check your user permissions") except ParseException, e: log.critical("Failed to parse %s configuration: %s" % (config, e)) except ParseException, e: log.critical("Failed to validate %s configuration: %s" % (config, e))