Commit f7a242c5 authored by Luis Araujo's avatar Luis Araujo

Add command to put device in maintenance mode

The command is named 'maint' and will put the specified device
in maintenance mode (offline). It can be passed an optional email
address to be notified once the current job has finished running.

Reviewed By: Héctor Orón Martínez <hector.oron@collabora.co.uk>
Reviewed By: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
Differential Revision: https://phabricator.collabora.co.uk/D996Signed-off-by: Luis Araujo's avatarLuis Araujo <luis.araujo@collabora.co.uk>
parent 11affc5b
......@@ -270,6 +270,17 @@ class Cli(object):
"than YYYYMMDD")
cleanqueue_parser.set_defaults(func=cleanqueue)
# Maintenance
maint_parser = subparsers.add_parser('maint', help="Put the given "
"device in maintenance mode")
maint_parser.add_argument('HOSTNAME', type=str, help="Name of the device")
maint_parser.add_argument('REASON', type=str, help="Reason to put the "
"device in maintenance mode.")
maint_parser.add_argument('--email', type=str, default='',
help="Email address of the user to notify "
"when the job has finished")
maint_parser.set_defaults(func=maint)
# Show devices
devices_parser = subparsers.add_parser('devices', help="Show status of all"
" available devices")
......@@ -369,6 +380,10 @@ def cleanqueue(args):
from lqa_tool.commands.cleanqueue import CleanQueueCmd
CleanQueueCmd(args).run()
def maint(args):
from lqa_tool.commands.maint import MaintCmd
MaintCmd(args).run()
def devices(args):
from lqa_tool.commands.devices import DevicesCmd
DevicesCmd(args).run()
......
###################################################################################
# LAVA QA Tool - Command to put devices into maintenance mode.
# Copyright (C) 2016 Luis Araujo <luis.araujo@collabora.co.uk>
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 US
###################################################################################
from lqa_tool.commands import Command
class MaintCmd(Command):
def __init__(self, args):
Command.__init__(self, args)
def run(self):
self.server.put_into_maintenance_mode(self.args.HOSTNAME,
self.args.REASON,
self.args.email)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment