def list(self, arguments): """ Lists all available boxes. Usage: mech list [options] Options: -h, --help Print this help """ for instance_name, instance in utils.instances().items(): path = instance.get('path') if path and os.path.exists(path): self.activate(instance_name) mech_path = os.path.join(path, '.mech') if os.path.exists(mech_path): vmrun = VMrun(self.vmx) ip = vmrun.getGuestIPAddress(wait=False, quiet=True) if ip is None: ip = "poweroff" elif not ip: ip = colored.green("running") else: ip = colored.green(ip) else: ip = "" print("{}\t{}\t{}\t{}\t{}".format( colored.green("%20s" % instance_name), "%15s" % ip, "%35s" % self.box_name, self.box_version, path, ))
def list(self, arguments): """ Lists all available boxes. Usage: mech list [options] Options: -h, --help Print this help """ print("{}\t{}\t{}\t{}\t{}".format( 'NAME'.rjust(20), 'ADDRESS'.rjust(15), 'BOX'.rjust(35), 'VERSION'.rjust(12), 'PATH', )) for instance_name, instance in utils.instances().items(): path = instance.get('path') if path and os.path.exists(path): self.activate(instance_name) mech_path = os.path.join(path, '.mech') if os.path.exists(mech_path): vmrun = VMrun(self.vmx, user=self.user, password=self.password) lookup = self.get("enable_ip_lookup", False) ip = vmrun.getGuestIPAddress(wait=False, quiet=True, lookup=lookup) if ip is None: ip = colored.yellow("poweroff") elif not ip: ip = colored.green("running") else: ip = colored.green(ip) else: ip = "" box_name = self.box_name or "" box_version = self.box_version or "" print("{}\t{}\t{}\t{}\t{}".format( colored.green(instance_name.rjust(20)), ip.rjust(15), box_name.rjust(35), box_version.rjust(12), path, ))
def nodes(exp): "Select nodes based on a regular expression" for node in instances(exp): use(node) for node in cf_instances(exp): use(node)
def production(): "Production nodes" for node in instances('production-.*'): use(node) for node in cf_instances('production-.*'): use(node)
def preview(): "Preview nodes" for node in instances('preview-.*'): use(node) for node in cf_instances('preview-.*'): use(node)
def ec2(exp='.*'): for node in instances(exp): use(node)
def all(): "All nodes" for node in instances(): use(node) for node in cf_instances(): use(node)
def production(): "Production nodes" for node in instances("production-.*"): use(node) for node in cf_instances("production-.*"): use(node)
def preview(): "Preview nodes" for node in instances("preview-.*"): use(node) for node in cf_instances("preview-.*"): use(node)
def ec2(exp=".*"): for node in instances(exp): use(node)