def run(self, args):
		host = args[0]
		state = args[1]
		key = args[2]

		#
		# 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 = rocks.vm.VMControl(self.db, vm_controller)

			if not vm.setKey(key):
				print "you need to provide a valid ssh key (%s)" % key
				sys.exit(1)

			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)
Exemplo n.º 2
0
    def run(self, params, args):
        (key, cdrom) = self.fillParams([('key', ), ('cdrom', '')])

        if not cdrom:
            self.abort("you need to specify the path to the cdrom")

        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]

        vm = rocks.vm.VMControl(self.db, vm_controller)

        if not vm.setKey(key):
            self.abort("Unable to find a valid the key (%s)" % key)

        if cdrom.lower() == 'none':
            command = 'cdrom'
        else:
            command = 'cdrom ' + cdrom
        (status, macs) = vm.cmd('cdrom ' + cdrom, host)

        if status != 0:
            self.abort('command failed: %s' % macs)
Exemplo n.º 3
0
    def run(self, params, args):
        (key, cdrom) = self.fillParams([("key",), ("cdrom", "")])

        if not cdrom:
            self.abort("you need to specify the path to the cdrom")

        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]

        vm = rocks.vm.VMControl(self.db, vm_controller)

        if not vm.setKey(key):
            self.abort("Unable to find a valid the key (%s)" % key)

        if cdrom.lower() == "none":
            command = "cdrom"
        else:
            command = "cdrom " + cdrom
        (status, macs) = vm.cmd("cdrom " + cdrom, host)

        if status != 0:
            self.abort("command failed: %s" % macs)
Exemplo n.º 4
0
    def run(self, args):
        host = args[0]
        state = args[1]
        key = args[2]

        #
        # 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 = rocks.vm.VMControl(self.db, vm_controller)

            if not vm.setKey(key):
                print "you need to provide a valid ssh key (%s)" % key
                sys.exit(1)

            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)
Exemplo n.º 5
0
	def run(self, params, args):
		(key, cdrom) = self.fillParams([ ('key', ), ('cdrom', '') ])

		if not cdrom:
			self.abort("you need to specify the path to the cdrom")

		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]

		vm = rocks.vm.VMControl(self.db, vm_controller)

		if not vm.setKey(key):
			self.abort("Unable to find a valid the key (%s)" % key)

		if cdrom.lower() == 'none':
			command = 'cdrom'
		else:
			command = 'cdrom ' + cdrom
		(status, macs) = vm.cmd('cdrom ' + cdrom, host)

		if status != 0:
			self.abort('command failed: %s' % macs)
Exemplo n.º 6
0
    def run(self):
        vm = rocks.vm.VMControl(self.db, self.vm_controller, self.vncflags)

        if not vm.setKey(self.rsakey):
            print "Unable to find a valid key(%s)" % self.rsakey

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

        if status != 0:
            print 'command failed\n%s' % reason
Exemplo n.º 7
0
    def run(self):
        vm = rocks.vm.VMControl(self.db, self.vm_controller, self.vncflags)

        if not vm.setKey(self.rsakey):
            print "Unable to find a valid key(%s)" % self.rsakey

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

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

        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]

        vm = rocks.vm.VMControl(self.db, vm_controller)

        if not vm.setKey(key):
            self.abort("Unable to find a valid the key (%s)" % key)

        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:
                m = mac.split()
                if state:
                    self.addOutput('', (m[0], m[1], m[2]))
                else:
                    self.addOutput('', (m[0], m[1]))
        if state:
            self.endOutput(
                header=['', 'macs in cluster', 'state', 'host names'])
        else:
            self.endOutput(header=['', 'macs in cluster', 'host names'])
Exemplo n.º 9
0
	def run(self, params, args):
		(key, s) = self.fillParams([ ('key', ), ('status', 'n') ])

		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]

		vm = rocks.vm.VMControl(self.db, vm_controller)

		if not vm.setKey(key):
			self.abort("Unable to find a valid the key (%s)" % key)

		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:
				m = mac.split()
				if state:
					self.addOutput('', (m[0], m[1], m[2]))
				else:
					self.addOutput('', (m[0], m[1]))
		if state:
			self.endOutput(header=['', 'macs in cluster', 'state', 'host names'])
		else:
			self.endOutput(header=['', 'macs in cluster', 'host names'])