begin integration of trigger handler
Signed-off-by: Nico Schottelius <nico@wurzel.schottelius.org>
This commit is contained in:
parent
42adef0a76
commit
7d027225bc
2 changed files with 72 additions and 2 deletions
55
cdist/trigger.py
Normal file
55
cdist/trigger.py
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# 2016 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist 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 General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import tempfile
|
||||||
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
|
|
||||||
|
|
||||||
|
import cdist
|
||||||
|
from cdist import core
|
||||||
|
|
||||||
|
class Trigger():
|
||||||
|
"""cdist trigger handling"""
|
||||||
|
|
||||||
|
def __init__(self, dry_run=False):
|
||||||
|
self.log = logging.getLogger("trigger")
|
||||||
|
self.dry_run = dry_run
|
||||||
|
|
||||||
|
def run_http(self):
|
||||||
|
server_address = ('0.0.0.0', 8000)
|
||||||
|
httpd = HTTPServer(server_address, testHTTPServer_RequestHandler)
|
||||||
|
print('running server...')
|
||||||
|
httpd.serve_forever()
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def commandline(args):
|
||||||
|
print("all good")
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TriggerHttp(BaseHTTPRequestHandler):
|
||||||
|
def do_GET(self):
|
||||||
|
pass
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# 2010-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2010-2016 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
# 2016 Darko Poljak (darko.poljak at gmail.com)
|
# 2016 Darko Poljak (darko.poljak at gmail.com)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
|
|
||||||
# list of beta sub-commands
|
# list of beta sub-commands
|
||||||
BETA_COMMANDS = ['install', ]
|
BETA_COMMANDS = ['install', 'trigger' ]
|
||||||
# list of beta arguments for sub-commands
|
# list of beta arguments for sub-commands
|
||||||
BETA_ARGS = {
|
BETA_ARGS = {
|
||||||
'config': ['jobs', ],
|
'config': ['jobs', ],
|
||||||
|
@ -69,6 +69,7 @@ def commandline():
|
||||||
import cdist.config
|
import cdist.config
|
||||||
import cdist.install
|
import cdist.install
|
||||||
import cdist.shell
|
import cdist.shell
|
||||||
|
import cdist.trigger
|
||||||
import shutil
|
import shutil
|
||||||
import os
|
import os
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
@ -84,6 +85,12 @@ def commandline():
|
||||||
'-v', '--verbose', help='Set log level to info, be more verbose',
|
'-v', '--verbose', help='Set log level to info, be more verbose',
|
||||||
action='store_true', default=False)
|
action='store_true', default=False)
|
||||||
|
|
||||||
|
parser['beta'] = argparse.ArgumentParser(add_help=False)
|
||||||
|
parser['beta'].add_argument(
|
||||||
|
'-b', '--enable-beta',
|
||||||
|
help=('Enable beta functionalities.'),
|
||||||
|
action='store_true', dest='beta', default=False)
|
||||||
|
|
||||||
# Main subcommand parser
|
# Main subcommand parser
|
||||||
parser['main'] = argparse.ArgumentParser(
|
parser['main'] = argparse.ArgumentParser(
|
||||||
description='cdist ' + cdist.VERSION, parents=[parser['loglevel']])
|
description='cdist ' + cdist.VERSION, parents=[parser['loglevel']])
|
||||||
|
@ -168,6 +175,14 @@ def commandline():
|
||||||
' should be POSIX compatible shell.'))
|
' should be POSIX compatible shell.'))
|
||||||
parser['shell'].set_defaults(func=cdist.shell.Shell.commandline)
|
parser['shell'].set_defaults(func=cdist.shell.Shell.commandline)
|
||||||
|
|
||||||
|
parser['trigger'] = parser['sub'].add_parser(
|
||||||
|
'trigger', parents=[parser['loglevel'], parser['beta']])
|
||||||
|
parser['trigger'].add_argument(
|
||||||
|
'-H', '--http-port',
|
||||||
|
help=('Create trigger listener via http on specified port'),
|
||||||
|
action='append')
|
||||||
|
parser['trigger'].set_defaults(func=cdist.trigger.Trigger.commandline)
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
parser['install'] = parser['sub'].add_parser('install', add_help=False,
|
parser['install'] = parser['sub'].add_parser('install', add_help=False,
|
||||||
parents=[parser['config']])
|
parents=[parser['config']])
|
||||||
|
|
Loading…
Reference in a new issue