diff options
author | George Kraft <george.kraft@calxeda.com> | 2012-08-23 09:30:40 -0500 |
---|---|---|
committer | George Kraft <george.kraft@calxeda.com> | 2012-08-23 09:30:40 -0500 |
commit | 8dac8062279e8efa5355edf3c5f951178440ea0c (patch) | |
tree | ffc9c84f9474f1868a9655c746fcbd29aff54b1d | |
parent | 4dcdb1639f8687d79acf5421bd12a912fea2086e (diff) | |
download | cxmanage-8dac8062279e8efa5355edf3c5f951178440ea0c.tar.gz |
controller: Make output more consistent between commands
Always print a list of discovered IP addresses, and always print
the current action just above the indicator.
-rw-r--r-- | cxmanage/controller.py | 45 |
1 files changed, 15 insertions, 30 deletions
diff --git a/cxmanage/controller.py b/cxmanage/controller.py index 98833a5..623b487 100644 --- a/cxmanage/controller.py +++ b/cxmanage/controller.py @@ -175,6 +175,7 @@ class Controller: ########################### Targets-specific methods ######################### + def add_target(self, address, username, password): """ Add a target to the controller """ for target in self.targets: @@ -189,15 +190,23 @@ class Controller: targets = [self.target_class(x, username, password, self.verbosity) for x in addresses] + # Get IP info if self.verbosity >= 1: print "Getting IP addresses..." results, errors = self._run_command(targets, "get_ipinfo", self.tftp) + # Add all resulting targets for target in targets: if target.address in results: for ipinfo in results[target.address]: self.add_target(ipinfo[1], username, password) + # Print results and errors + if self.verbosity >= 1: + print "Discovered the following IP addresses:" + for target in self.targets: + print target.address + print self._print_errors(targets, errors) return len(errors) > 0 @@ -207,11 +216,7 @@ class Controller: def power(self, mode): """ Send the given power command to all targets """ if self.verbosity >= 1: - print "Sending power %s command to these hosts:" % mode - for target in self.targets: - print target.address - print - + print "Sending power %s command..." % mode return self._retry_command("set_power", mode) def power_status(self): @@ -241,11 +246,7 @@ class Controller: def power_policy(self, mode): """ Set the power policy for all targets """ if self.verbosity >= 1: - print "Setting power policy on these hosts:" - for target in self.targets: - print target.address - print - + print "Setting power policy to %s..." % mode return self._retry_command("set_power_policy", mode) def power_policy_status(self): @@ -271,21 +272,13 @@ class Controller: def mc_reset(self): """ Send an MC reset command to all targets """ if self.verbosity >= 1: - print "Sending MC reset command to these hosts:" - for target in self.targets: - print target.address - print - + print "Sending MC reset command..." return self._retry_command("mc_reset") def update_firmware(self, partition_arg="INACTIVE"): """ Send firmware update commands to all targets """ if self.verbosity >= 1: - print "Updating firmware on these hosts:" - for target in self.targets: - print target.address - print - + print "Updating firmware..." return self._retry_command("update_firmware", self.tftp, self.images, partition_arg) @@ -418,11 +411,7 @@ class Controller: def config_reset(self): """ Send config reset command to all targets """ if self.verbosity >= 1: - print "Resetting configuration on these hosts:" - for target in self.targets: - print target.address - print - + print "Sending config reset command..." return self._retry_command("config_reset", self.tftp) def config_boot(self, boot_args): @@ -436,11 +425,7 @@ class Controller: return True if self.verbosity >= 1: - print "Setting boot order on these hosts:" - for target in self.targets: - print target.address - print - + print "Setting boot order..." return self._retry_command("set_boot_order", self.tftp, boot_args) def config_boot_status(self): |