Esempio n. 1
0
    def run(self, args):
        host = args[0]
        state = args[1]
        rsakey = args[2]

        if not rsakey:
            print 'need to supply a private key'
            sys.exit(-1)

        #
        # if 'airboss' is set, then we assume this is a virtual
        # frontend and we want to send a command to the airboss
        # for this virtual cluster.
        #
        vm_controller = self.db.getHostAttr('localhost', 'airboss')
        if vm_controller:
            vm = stack.vm.VMControl(self.db, vm_controller, rsakey)

            if state == 'on':
                op = 'power on'
            elif state == 'off':
                op = 'power off'
            elif state == 'install':
                op = 'power on + install'

            (status, reason) = vm.cmd(op, host)

            if status != 0:
                print 'command failed\n%s' % reason
                sys.exit(-1)
Esempio n. 2
0
    def run(self, args):
        host = args[0]
        state = args[1]
        rsakey = args[2]

        if not rsakey:
            print "need to supply a private key"
            sys.exit(-1)

            #
            # if 'airboss' is set, then we assume this is a virtual
            # frontend and we want to send a command to the airboss
            # for this virtual cluster.
            #
        vm_controller = self.db.getHostAttr("localhost", "airboss")
        if vm_controller:
            vm = stack.vm.VMControl(self.db, vm_controller, rsakey)

            if state == "on":
                op = "power on"
            elif state == "off":
                op = "power off"
            elif state == "install":
                op = "power on + install"

            (status, reason) = vm.cmd(op, host)

            if status != 0:
                print "command failed\n%s" % reason
                sys.exit(-1)
Esempio n. 3
0
    def run(self):
        vm = stack.vm.VMControl(self.db, self.vm_controller, self.rsakey,
                                self.vncflags)

        (status, reason) = vm.cmd('console', self.host)

        if status != 0:
            print 'command failed\n%s' % reason
Esempio n. 4
0
	def run(self):
		vm = stack.vm.VMControl(self.db, self.vm_controller,
			self.rsakey, self.vncflags)

		(status, reason) = vm.cmd('console', self.host)

		if status != 0:
			print 'command failed\n%s' % reason
Esempio n. 5
0
	def run(self, params, args):
		(key, s) = self.fillParams([ ('key', ), ('status', 'n') ])

		if not key:
			self.abort('must supply a path name to a private key')
		if not os.path.exists(key):
			self.abort('private key "%s" does not exist' % key)

		state = self.str2bool(s)

		vm_controller = self.db.getHostAttr('localhost', 'airboss')

		if not vm_controller:
			self.abort('the "airboss" attribute is not set')

		if len(args) == 0:
			self.abort('must supply one host name')
		if len(args) > 1:
			self.abort('must supply only one host name')

		hosts = self.getHostnames(args)
		host = hosts[0]

		rsakey = M2Crypto.RSA.load_key(key)

		vm = stack.vm.VMControl(self.db, vm_controller, rsakey)
		if state:
			(status, macs) = vm.cmd('list macs + status', host)
		else:
			(status, macs) = vm.cmd('list macs', host)
		if status != 0:
			self.abort('command failed: %s' % macs)

		self.beginOutput()
		for mac in macs.split('\n'):
			if len(mac) > 0:
				if state:
					m = mac.split()
					self.addOutput('', (m[0], m[1]))
				else:
					self.addOutput('', (mac))
		if state:
			self.endOutput(header=['', 'macs in cluster', 'state'])
		else:
			self.endOutput(header=['', 'macs in cluster'])
Esempio n. 6
0
    def run(self, params, args):
        (key, s) = self.fillParams([('key', None, True), ('status', 'n')])

        if not os.path.exists(key):
            raise CommandError(self, 'private key "%s" does not exist' % key)

        state = self.str2bool(s)

        vm_controller = self.getAttr('airboss')

        if not vm_controller:
            raise CommandError(self, 'the "airboss" attribute is not set')

        if not len(args) == 1:
            raise ArgUnique(self, 'host')

        hosts = self.getHostnames(args)
        host = hosts[0]

        rsakey = M2Crypto.RSA.load_key(key)

        vm = stack.vm.VMControl(self.db, vm_controller, rsakey)
        if state:
            (status, macs) = vm.cmd('list macs + status', host)
        else:
            (status, macs) = vm.cmd('list macs', host)
        if status != 0:
            raise CommandError(self, 'command failed: %s' % macs)

        self.beginOutput()
        for mac in macs.split('\n'):
            if len(mac) > 0:
                if state:
                    m = mac.split()
                    self.addOutput('', (m[0], m[1]))
                else:
                    self.addOutput('', (mac))
        if state:
            self.endOutput(header=['', 'macs in cluster', 'state'])
        else:
            self.endOutput(header=['', 'macs in cluster'])