def __init__(self, startfolder, configs, options, logger): KindoCore.__init__(self, startfolder, configs, options, logger) host = self.configs.get("h", self.configs.get("host", "")).strip() password = self.configs.get("p", self.configs.get("password", "")).strip() group = self.configs.get("g", self.configs.get("group", "")).strip() host = "%s:22" % host if host is not None and host.rfind(":") == -1 else host host = "root@%s" % host if host is not None and host.rfind("@") == -1 else host hosts = self.get_hosts_setting() if group and group not in hosts: self.logger.warn("GROUP NOT FOUND: %s" % group) self.activate_hosts = [] if host: host, port, username = hostparse(host) while not password: password = getpass.getpass("please input password: "******"host": host, "port": port, "username": username, "password": password}) if group in hosts: for k, v in hosts[group].items(): host, port, username = hostparse(k) self.activate_hosts.append({"host": host, "port": port, "username": username, "password": v}) self.runCommand = RunCommand(startfolder, configs, options, logger)
def __init__(self, startfolder, configs, options, logger): KindoCore.__init__(self, startfolder, configs, options, logger) env.colorize_errors = True env.command_timeout = self.configs.get("timout", 60 * 30) env.output_prefix = "" env.passwords = {} output.debug = False output.running = False host = self.configs.get("h", None) host = "%s:22" % host if host is not None and host.rfind(":") == -1 else host host = "root@%s" % host if host is not None and host.rfind("@") == -1 else host password = self.configs.get("p", "") if host is not None: env.passwords[host] = password hosts = self.get_hosts_setting() groups = configs["g"].split(",") if "g" in configs else [] for group in groups: group = group.strip() if group not in hosts: self.logger.warn("GROUP NOT FOUND: %s" % group) continue for k, v in hosts[group].items(): env.passwords[k] = v if len(env.passwords) == 0 and "default" in hosts: for k, v in hosts["default"].items(): env.passwords[k] = v if "ssh" in self.configs: env.use_ssh_config = True env.ssh_config_path = os.path.realpath(self.configs["ssh"]) self.ki_path = self.get_ki_path() self.handlers = { "from": FromCommand(startfolder, configs, options, logger), "add": AddCommand(startfolder, configs, options, logger), "check": CheckCommand(startfolder, configs, options, logger), "run": RunCommand(startfolder, configs, options, logger), "workdir": WorkdirCommand(startfolder, configs, options, logger), "download": DownloadCommand(startfolder, configs, options, logger), "ubuntu": UbuntuCommand(startfolder, configs, options, logger), "centos": CentOSCommand(startfolder, configs, options, logger), "addonrun": AddOnRunCommand(startfolder, configs, options, logger), "env": EnvCommand(startfolder, configs, options, logger), "maintainer": MaintainerCommand(startfolder, configs, options, logger) }
def __init__(self, startfolder, configs, options, logger): KindoCore.__init__(self, startfolder, configs, options, logger) self.kic_path_infos = [] # get kics path from the command line # support to build multi kics with one command for option in options[2:]: filename, ext = os.path.splitext(option) if "." not in ext: ext = ".kic" option = "{0}.kic".format(option) if ext.lower() != ".kic": continue kic_path, outfolder = self.get_kic_info(option) if kic_path is not None and outfolder is None: self.logger.warn("invalid target: {0}".format(self.configs.get("o", ""))) continue if kic_path is None or not kic_path: self.logger.warn("{0} not found".format(option)) continue self.kic_path_infos.append( { "path": kic_path, "outfolder": outfolder } ) # cache commands self.handlers = { "from": FromCommand(startfolder, configs, options, logger), "add": AddCommand(startfolder, configs, options, logger), "check": CheckCommand(startfolder, configs, options, logger), "run": RunCommand(startfolder, configs, options, logger), "workdir": WorkdirCommand(startfolder, configs, options, logger), "download": DownloadCommand(startfolder, configs, options, logger), "ubuntu": UbuntuCommand(startfolder, configs, options, logger), "centos": CentOSCommand(startfolder, configs, options, logger), "addonrun": AddOnRunCommand(startfolder, configs, options, logger), "env": EnvCommand(startfolder, configs, options, logger), "maintainer": MaintainerCommand(startfolder, configs, options, logger) } self.re_pattern = "^\s*(%s)\s+" % "|".join(self.handlers.keys())
def __init__(self, startfolder, configs, options, logger): KindoCore.__init__(self, startfolder, configs, options, logger)
def __init__(self, startfolder, configs, options, logger): KindoCore.__init__(self, startfolder, configs, options, logger) self._system_info = None
def __init__(self, startfolder, configs, options, logger): KindoCore.__init__(self, startfolder, configs, options, logger) self.ki_path = self.get_ki_path()
def __init__(self, startfolder, configs, options, logger): KindoCore.__init__(self, startfolder, configs, options, logger) self.commands_info = { "build": { "description": "Build an image from the kicfile", "command": "kindo build [kic path]", "options": { "-d": "Enable debug information", "-o": "Specify the output folder", "-t": "set the image tag, for example: author/name:version", "--kipwd": "set unpackage password" } }, "commit": { "description": "Commit local image to the image's path", "command": "kindo commit [ki path]", "options": { "-d": "Enable debug information", "-t": "set the image tag, for example: author/name:version" } }, "clean": { "description": "Clean the local caches", "command": "kindo clean", "options": { "-d": "Enable debug information" } }, "help": { "description": "Show the command options", "command": "kindo help [kindo command name]", "options": { "-d": "Enable debug information" } }, "images": { "description": "List local images", "command": "kindo images", "options": { "-d": "Enable debug information" } }, "info": { "description": "Display system-wide information", "command": "kindo info", "options": { "-d": "Enable debug information" } }, "login": { "description": "account login, set account info automatically", "command": "kindo login [username] [password]", "options": { "-d": "Enable debug information" } }, "logout": { "description": "account logout, clean account info automatically", "command": "kindo logout", "options": { "-d": "Enable debug information" } }, "pull": { "description": "Pull an image from the kindo hub", "command": "kindo pull [author/name:version]", "options": { "-d": "Enable debug information", "--code": "Set the extraction code, only six characters are allowed" } }, "push": { "description": "Push an image to the kindo hub", "command": "kindo push [ki image path|ki image name]", "options": { "-d": "Enable debug information", "--code": "Set the extraction code, only six characters are allowed" } }, "register": { "description": "Register the kindo hub's account", "command": "kindo register", "options": { "-d": "Enable debug information" } }, "rm": { "description": "Delete the owned image in the kindo hub", "command": "kindo rm [author/name:version]", "options": { "-d": "Enable debug information" } }, "rmi": { "description": "Remove one or more local images", "command": "kindo rmi [author/name:version]", "options": { "-d": "Enable debug information" } }, "run": { "description": "Run image commands to the target operating system", "command": "kindo run [ki image path|ki image name]", "options": { "-d": "Enable debug information", "-h": "host, for example: account@ip:port", "-p": "account password", "-g": "set the hosts group name", "--kipwd": "set unpackage password" } }, "search": { "description": "Search an image on the kindo hub", "command": "kindo search [image name]", "options": { "-d": "Enable debug information" } }, "version": { "description": "Show the kindo information", "command": "kindo version", "options": { "-d": "Enable debug information" } } }