Beispiel #1
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()
Beispiel #2
0
 def list(self, args):
     """ List physical machines from abiquo """
     context = ContextLoader().load()
     try:
         admin = context.getAdministrationService()
         machines = admin.listMachines()
         pprint_machines(machines)
     except (AbiquoException, AuthorizationException), ex:
         print "Error %s" % ex.getMessage()
 def list(self, args):
     """ List physical machines from abiquo """
     context = ContextLoader().load()
     try:
         admin = context.getAdministrationService()
         machines = admin.listMachines()
         pprint_machines(machines)
     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 #5
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()
Beispiel #6
0
                return
            ds.setEnabled(True)

            # setting virtual switch
            vs = machine.findAvailableVirtualSwitch(vswitch)
            if not vs:
                print "Missing virtual switch %s in machine" % vswitch
                return
            nst = dc.defaultNetworkServiceType()
            vs.setNetworkServiceType(nst)

            # saving machine
            machine.setRack(rack)
            machine.save()
            log.debug("Machine saved")
            pprint_machines([machine])

        except (AbiquoException, AuthorizationException), ex:
            if ex.hasError("HYPERVISOR-1") or ex.hasError("HYPERVISOR-2"):
                print "Error: Machine already exists"
            else:
                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",
                return
            ds.setEnabled(True)

            # setting virtual switch
            vs = machine.findAvailableVirtualSwitch(vswitch)
            if not vs:
                print "Missing virtual switch %s in machine" % vswitch
                return
            nst = dc.defaultNetworkServiceType()
            vs.setNetworkServiceType(nst)

            # saving machine
            machine.setRack(rack)
            machine.save()
            log.debug("Machine saved")
            pprint_machines([machine])

        except (AbiquoException, AuthorizationException), ex:
            if ex.hasError("HYPERVISOR-1") or ex.hasError("HYPERVISOR-2"):
                print "Error: Machine already exists"
            else:
                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")