Exemplo n.º 1
0
    def _list_server(self):
        try:
            self.machines = self.sdc.machines()
        except Exception as e:
            print "Unable to search for server: %s" % str(e)
            exit(1)
        for machine in self.machines:
            self._machine_format(machine)

        # Print results
        headers = ["Name", "State", "ID", "IPs", "Type", "DataSet", "Created"]
        question = "List joyent Machines in {}".format(TColors.yellow(self.location))
        print_table(self.results, headers=headers, question=question)
Exemplo n.º 2
0
    def _network_list(self):
        networks = []
        try:
            networks = self.sdc.networks()
        except Exception as e:
            print "Unable to search for networks: %s" % str(e)
            exit(1)
        for network in networks:
            self._network_format(network)

        headers = ["Public", "Name", "Id","Description"]
        question = "List of joyent networks in {}".format(TColors.yellow(self.location))
        print_table(self.results, headers=headers, question=question)
        exit(1)
Exemplo n.º 3
0
 def _machine_format(self, m):
     if m.state == "running":
         m.state = TColors.green(m.state)
     elif m.state == "stopped":
         m.state = TColors.red(m.state)
     else:
         m.state = TColors.yellow(m.state)
     m.created = format_last_run(m.created, color=False)
     m.dataset = str(m.dataset).split(":")
     self.results.append([m.name,
                          m.state,
                          "",
                          ", ".join(m.ips),
                          m.type[0].upper(),
                          ":".join(m.dataset[-2:]),
                          m.created])