Beispiel #1
0
    def delete(self, args):
        """ Remove a physical machine from abiquo """
        parser = OptionParser(usage="machine delete <options>")
        parser.add_option("-n", "--name",
                help="the name of the physical machine",
                action="store", dest="name")
        parser.add_option("-i", "--host",
                help="the ip of the physical machine",
                action="store", dest="host")
        (options, args) = parser.parse_args(args)
        name = options.name
        host = options.host

        if not name and not host:
            parser.print_help()
            return

        try:
            admin = self._context.getAdministrationService()
            if name:
                machine = admin.findMachine(MachinePredicates.name(name))
            else:
                machine = admin.findMachine(MachinePredicates.ip(host))
            if not machine:
                print "Machine not found"
                return
            name = machine.getName()
            machine.delete()
            log.debug("Machine %s deleted succesfully" % name)

        except (AbiquoException, AuthorizationException), ex:
            print "Error %s" % ex.getMessage()
Beispiel #2
0
    def checkMachines(self, args):
        """ Check state from physical machine. """
        parser = OptionParser(usage="machine check <options>")
        parser.add_option("-n","--name",help="the name of the physical machine",action="store",dest="name")
        parser.add_option("-i","--host",help="the ip of the physical machine",action="store",dest="host")
        parser.add_option("-a","--all",help="check all machines",action="store_true",dest="a")
        (options, args) = parser.parse_args(args)
        all_true = options.a
        name = options.name
        host = options.host

        if not name and not host and not all_true:
            parser.print_help()
            return

        context = ContextLoader().load()
        try:
            admin =  context.getAdministrationService()
            if all_true:
                machines = admin.listMachines()
                log.debug("%s machines found." % str(len(machines)))
                [self._checkMachine for machine in machines]
                pprint_machines(machines)
            else:
                if name:
                    machine = admin.findMachine(MachinePredicates.name(name))
                else:
                    machine = admin.findMachine(MachinePredicates.ip(host))
                self._checkMachine(machine)
                pprint_machines([machine]);
        except (AbiquoException, AuthorizationException), ex:
            print "Error %s" % ex.getMessage()
    def check(self, args):
        """ Check state from physical machine """
        parser = OptionParser(usage="machine check <options>")
        parser.add_option('-n',
                          '--name',
                          help='the name of the physical machine',
                          action='store',
                          dest='name')
        parser.add_option('-i',
                          '--host',
                          help='the ip of the physical machine',
                          action='store',
                          dest='host')
        parser.add_option('-a',
                          '--all',
                          help='check all machines',
                          action='store_true',
                          dest='a')
        (options, args) = parser.parse_args(args)
        all_true = options.a
        name = options.name
        host = options.host

        if not name and not host and not all_true:
            parser.print_help()
            return

        try:
            admin = self._context.getAdministrationService()
            if all_true:
                machines = admin.listMachines()
                log.debug("%s machines found." % str(len(machines)))
                [self._checkMachine for machine in machines]
                pprint_machines(machines)
            else:
                if name:
                    machine = admin.findMachine(MachinePredicates.name(name))
                else:
                    machine = admin.findMachine(MachinePredicates.ip(host))
                self._checkMachine(machine)
                pprint_machines([machine])
        except (AbiquoException, AuthorizationException), ex:
            print "Error %s" % ex.getMessage()
Beispiel #4
0
    def check(self, args):
        """ Check state from physical machine """
        parser = OptionParser(usage="machine check <options>")
        parser.add_option('-n', '--name',
                help='the name of the physical machine',
                action='store', dest='name')
        parser.add_option('-i', '--host',
                help='the ip of the physical machine',
                action='store', dest='host')
        parser.add_option('-a', '--all', help='check all machines',
                action='store_true', dest='a')
        (options, args) = parser.parse_args(args)
        all_true = options.a
        name = options.name
        host = options.host

        if not name and not host and not all_true:
            parser.print_help()
            return

        try:
            admin = self._context.getAdministrationService()
            if all_true:
                machines = admin.listMachines()
                log.debug("%s machines found." % str(len(machines)))
                [self._checkMachine for machine in machines]
                pprint_machines(machines)
            else:
                if name:
                    machine = admin.findMachine(MachinePredicates.name(name))
                else:
                    machine = admin.findMachine(MachinePredicates.ip(host))
                self._checkMachine(machine)
                pprint_machines([machine])
        except (AbiquoException, AuthorizationException), ex:
            print "Error %s" % ex.getMessage()
    def delete(self, args):
        """ Remove a physical machine from abiquo """
        parser = OptionParser(usage="machine delete <options>")
        parser.add_option("-n",
                          "--name",
                          help="the name of the physical machine",
                          action="store",
                          dest="name")
        parser.add_option("-i",
                          "--host",
                          help="the ip of the physical machine",
                          action="store",
                          dest="host")
        (options, args) = parser.parse_args(args)
        name = options.name
        host = options.host

        if not name and not host:
            parser.print_help()
            return

        try:
            admin = self._context.getAdministrationService()
            if name:
                machine = admin.findMachine(MachinePredicates.name(name))
            else:
                machine = admin.findMachine(MachinePredicates.ip(host))
            if not machine:
                print "Machine not found"
                return
            name = machine.getName()
            machine.delete()
            log.debug("Machine %s deleted succesfully" % name)

        except (AbiquoException, AuthorizationException), ex:
            print "Error %s" % ex.getMessage()