From 669661b530d407a062a5df9e77758f552bafe09c Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 30 Jul 2015 17:08:52 -0400 Subject: [PATCH 1/5] Implement basic functionality under windows Windows support by removing pid file, daemonizing, locking, and other features. Goal is to have a freezeable payload. --- confluent_client/bin/confetty | 16 +++++++++----- confluent_client/confluent/__init__.py | 2 ++ confluent_server/bin/confluent | 1 + confluent_server/confluent/__init__.py | 2 ++ confluent_server/confluent/auth.py | 7 ++++++- confluent_server/confluent/core.py | 5 ++++- confluent_server/confluent/log.py | 26 +++++++++++++++-------- confluent_server/confluent/main.py | 29 ++++++++++++++++++++------ 8 files changed, 66 insertions(+), 22 deletions(-) diff --git a/confluent_client/bin/confetty b/confluent_client/bin/confetty index 8cbdaa29..7e79eb10 100755 --- a/confluent_client/bin/confetty +++ b/confluent_client/bin/confetty @@ -41,7 +41,6 @@ # esc-( would interfere with normal esc use too much # ~ I will not use for now... -import fcntl import math import getpass import optparse @@ -50,9 +49,13 @@ import select import shlex import socket import sys -import termios import time -import tty +try: + import fcntl + import termios + import tty +except ImportError: + pass exitcode = 0 consoleonly = False @@ -72,8 +75,11 @@ conserversequence = '\x05c' # ctrl-e, c oldtcattr = None fd = sys.stdin -if fd.isatty(): - oldtcattr = termios.tcgetattr(fd.fileno()) +try: + if fd.isatty(): + oldtcattr = termios.tcgetattr(fd.fileno()) +except NameError: + pass netserver = None laststate = {} diff --git a/confluent_client/confluent/__init__.py b/confluent_client/confluent/__init__.py index e69de29b..0bfb5a62 100644 --- a/confluent_client/confluent/__init__.py +++ b/confluent_client/confluent/__init__.py @@ -0,0 +1,2 @@ +from pkgutil import extend_path +__path__ = extend_path(__path__, __name__) \ No newline at end of file diff --git a/confluent_server/bin/confluent b/confluent_server/bin/confluent index 256fc097..b01940ea 100755 --- a/confluent_server/bin/confluent +++ b/confluent_server/bin/confluent @@ -19,6 +19,7 @@ import sys import os path = os.path.dirname(os.path.realpath(__file__)) path = os.path.realpath(os.path.join(path, '..', 'lib', 'python')) +print(path) if path.startswith('/opt'): # if installed into system path, do not muck with things sys.path.append(path) diff --git a/confluent_server/confluent/__init__.py b/confluent_server/confluent/__init__.py index e69de29b..0bfb5a62 100644 --- a/confluent_server/confluent/__init__.py +++ b/confluent_server/confluent/__init__.py @@ -0,0 +1,2 @@ +from pkgutil import extend_path +__path__ = extend_path(__path__, __name__) \ No newline at end of file diff --git a/confluent_server/confluent/auth.py b/confluent_server/confluent/auth.py index b04ddc63..709ac3ca 100644 --- a/confluent_server/confluent/auth.py +++ b/confluent_server/confluent/auth.py @@ -26,7 +26,10 @@ import Crypto.Protocol.KDF as KDF import hashlib import hmac import multiprocessing -import PAM +try: + import PAM +except ImportError: + pass import time _pamservice = 'confluent' @@ -161,6 +164,8 @@ def check_user_passphrase(name, passphrase, element=None, tenant=False): pammy.acct_mgmt() del pammy return authorize(user, element, tenant, skipuserobj=False) + except NameError: + pass except PAM.error: if credobj.haspam: return None diff --git a/confluent_server/confluent/core.py b/confluent_server/confluent/core.py index 9a43d16d..43ddce12 100644 --- a/confluent_server/confluent/core.py +++ b/confluent_server/confluent/core.py @@ -39,7 +39,10 @@ import confluent.interface.console as console import confluent.exceptions as exc import confluent.messages as msg import confluent.noderange as noderange -import confluent.shellmodule as shellmodule +try: + import confluent.shellmodule as shellmodule +except ImportError: + pass import itertools import os import sys diff --git a/confluent_server/confluent/log.py b/confluent_server/confluent/log.py index 5e15dd76..7d283883 100644 --- a/confluent_server/confluent/log.py +++ b/confluent_server/confluent/log.py @@ -62,13 +62,21 @@ import collections import confluent.config.configmanager import eventlet -import fcntl import json import os import struct import time import traceback +try: + from fcntl import flock, LOCK_EX, LOCK_UN, LOCK_SH +except ImportError: + flock = lambda file, flag: True + LOCK_EX = None + LOCK_UN = None + LOCK_SH = None + + # on conserving filehandles: # upon write, if file not open, open it for append # upon write, schedule/reschedule closing filehandle in 15 seconds @@ -156,7 +164,7 @@ class Logger(object): elif not self.isconsole: textdate = time.strftime( '%b %d %H:%M:%S ', time.localtime(tstamp)) - fcntl.flock(self.textfile, fcntl.LOCK_EX) + flock(self.textfile, LOCK_EX) offset = self.textfile.tell() + len(textdate) datalen = len(data) eventaux = entry[4] @@ -176,10 +184,10 @@ class Logger(object): if not textrecord.endswith('\n'): textrecord += '\n' self.textfile.write(textrecord) - fcntl.flock(self.textfile, fcntl.LOCK_UN) - fcntl.flock(self.binfile, fcntl.LOCK_EX) + flock(self.textfile, LOCK_UN) + flock(self.binfile, LOCK_EX) self.binfile.write(binrecord) - fcntl.flock(self.binfile, fcntl.LOCK_UN) + flock(self.binfile, LOCK_UN) self.textfile.flush() self.binfile.flush() if self.closer is None: @@ -192,7 +200,7 @@ class Logger(object): binfile = open(self.binpath, mode='r') except IOError: return '', 0, 0 - fcntl.flock(binfile, fcntl.LOCK_SH) + flock(binfile, LOCK_SH) binfile.seek(0, 2) binidx = binfile.tell() - 16 currsize = 0 @@ -213,15 +221,15 @@ class Logger(object): offsets.append((offset, datalen)) if termstate is None: termstate = eventaux - fcntl.flock(binfile, fcntl.LOCK_UN) + flock(binfile, LOCK_UN) binfile.close() textdata = '' - fcntl.flock(textfile, fcntl.LOCK_SH) + flock(textfile, LOCK_SH) while offsets: (offset, length) = offsets.pop() textfile.seek(offset, 0) textdata += textfile.read(length) - fcntl.flock(textfile, fcntl.LOCK_UN) + flock(textfile, LOCK_UN) textfile.close() if termstate is None: termstate = 0 diff --git a/confluent_server/confluent/main.py b/confluent_server/confluent/main.py index 8533d551..cb6dd925 100644 --- a/confluent_server/confluent/main.py +++ b/confluent_server/confluent/main.py @@ -32,10 +32,18 @@ import confluent.consoleserver as consoleserver import confluent.core as confluentcore import confluent.httpapi as httpapi import confluent.log as log -import confluent.sockapi as sockapi +try: + import confluent.sockapi as sockapi +except ImportError: + #On platforms without pwd, give up on the sockapi in general and be http + #only for now + pass import eventlet #import eventlet.backdoor as backdoor -import fcntl +try: + import fcntl +except ImportError: + pass #import multiprocessing import sys import os @@ -44,6 +52,8 @@ import ConfigParser def _daemonize(): + if not 'fork' in os.__dict__: + return thispid = os.fork() if thispid > 0: os.waitpid(thispid, 0) @@ -110,6 +120,8 @@ def terminate(signalname, frame): def doexit(): + if 'fcntl' not in locals(): + return pidfile = open('/var/run/confluent/pid') pid = pidfile.read() if pid == str(os.getpid()): @@ -125,7 +137,8 @@ def _initsecurity(config): def run(): - _checkpidfile() + if 'fcntl' in locals(): + _checkpidfile() configfile = "/etc/confluent/service.cfg" config = ConfigParser.ConfigParser() config.read(configfile) @@ -141,7 +154,8 @@ def run(): doexit() raise _daemonize() - _updatepidfile() + if 'fcntl' in locals(): + _updatepidfile() auth.init_auth() signal.signal(signal.SIGINT, terminate) signal.signal(signal.SIGTERM, terminate) @@ -155,8 +169,11 @@ def run(): consoleserver.start_console_sessions() webservice = httpapi.HttpApi(http_bind_host, http_bind_port) webservice.start() - sockservice = sockapi.SockApi(sock_bind_host, sock_bind_port) - sockservice.start() + try: + sockservice = sockapi.SockApi(sock_bind_host, sock_bind_port) + sockservice.start() + except NameError: + pass atexit.register(doexit) while 1: eventlet.sleep(100) From 90ad5829fc7587cd6c5f4527624b45df90b956f7 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 31 Jul 2015 17:07:40 -0400 Subject: [PATCH 2/5] Phase 2 of Windows compatibility More work to try to enable confluent to be frozen by pyinstaller --- confluent_client/confluent/__init__.py | 2 - confluent_server/bin/confluent | 5 ++- confluent_server/bin/confluentsrv.py | 41 +++++++++++++++++ confluent_server/confluent/__init__.py | 2 - .../config => confluentd}/__init__.py | 0 .../{confluent => confluentd}/alerts.py | 8 ++-- .../{confluent => confluentd}/auth.py | 2 +- .../config}/__init__.py | 0 .../config/attributes.py | 0 .../config/configmanager.py | 37 ++++++++------- .../consoleserver.py | 12 ++--- .../{confluent => confluentd}/core.py | 14 +++--- .../{confluent => confluentd}/exceptions.py | 0 .../{confluent => confluentd}/httpapi.py | 45 ++++++++++--------- .../interface}/__init__.py | 0 .../interface/console.py | 0 .../{confluent => confluentd}/log.py | 11 +++-- .../{confluent => confluentd}/lookuptools.py | 2 +- .../{confluent => confluentd}/main.py | 17 ++++--- .../{confluent => confluentd}/messages.py | 2 +- .../{confluent => confluentd}/noderange.py | 0 .../plugins}/__init__.py | 0 .../plugins/configuration}/__init__.py | 0 .../plugins/configuration/attributes.py | 6 +-- .../plugins/hardwaremanagement/__init__.py | 0 .../plugins/hardwaremanagement/ipmi.py | 6 +-- .../{confluent => confluentd}/shellmodule.py | 2 +- .../{confluent => confluentd}/sockapi.py | 12 ++--- .../{confluent => confluentd}/util.py | 0 29 files changed, 140 insertions(+), 86 deletions(-) create mode 100644 confluent_server/bin/confluentsrv.py delete mode 100644 confluent_server/confluent/__init__.py rename confluent_server/{confluent/config => confluentd}/__init__.py (100%) rename confluent_server/{confluent => confluentd}/alerts.py (93%) rename confluent_server/{confluent => confluentd}/auth.py (99%) rename confluent_server/{confluent/interface => confluentd/config}/__init__.py (100%) rename confluent_server/{confluent => confluentd}/config/attributes.py (100%) rename confluent_server/{confluent => confluentd}/config/configmanager.py (97%) rename confluent_server/{confluent => confluentd}/consoleserver.py (98%) rename confluent_server/{confluent => confluentd}/core.py (98%) rename confluent_server/{confluent => confluentd}/exceptions.py (100%) rename confluent_server/{confluent => confluentd}/httpapi.py (95%) rename confluent_server/{confluent/plugins => confluentd/interface}/__init__.py (100%) rename confluent_server/{confluent => confluentd}/interface/console.py (100%) rename confluent_server/{confluent => confluentd}/log.py (96%) rename confluent_server/{confluent => confluentd}/lookuptools.py (97%) rename confluent_server/{confluent => confluentd}/main.py (92%) rename confluent_server/{confluent => confluentd}/messages.py (99%) rename confluent_server/{confluent => confluentd}/noderange.py (100%) rename confluent_server/{confluent/plugins/configuration => confluentd/plugins}/__init__.py (100%) rename confluent_server/{confluent/plugins/hardwaremanagement => confluentd/plugins/configuration}/__init__.py (100%) rename confluent_server/{confluent => confluentd}/plugins/configuration/attributes.py (98%) create mode 100644 confluent_server/confluentd/plugins/hardwaremanagement/__init__.py rename confluent_server/{confluent => confluentd}/plugins/hardwaremanagement/ipmi.py (99%) rename confluent_server/{confluent => confluentd}/shellmodule.py (99%) rename confluent_server/{confluent => confluentd}/sockapi.py (97%) rename confluent_server/{confluent => confluentd}/util.py (100%) diff --git a/confluent_client/confluent/__init__.py b/confluent_client/confluent/__init__.py index 0bfb5a62..e69de29b 100644 --- a/confluent_client/confluent/__init__.py +++ b/confluent_client/confluent/__init__.py @@ -1,2 +0,0 @@ -from pkgutil import extend_path -__path__ = extend_path(__path__, __name__) \ No newline at end of file diff --git a/confluent_server/bin/confluent b/confluent_server/bin/confluent index b01940ea..adebd49b 100755 --- a/confluent_server/bin/confluent +++ b/confluent_server/bin/confluent @@ -30,7 +30,10 @@ from confluent import main #p = cProfile.Profile(time.clock) #p.enable() #try: -main.run() +if __name__ == '__main__': + import multiprocessing + multiprocessing.freeze_support() + main.run() #except: # pass #p.disable() diff --git a/confluent_server/bin/confluentsrv.py b/confluent_server/bin/confluentsrv.py new file mode 100644 index 00000000..fbc929ea --- /dev/null +++ b/confluent_server/bin/confluentsrv.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2014 IBM Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import sys +import os +path = os.path.dirname(os.path.realpath(__file__)) +path = os.path.realpath(os.path.join(path, '..', 'lib', 'python')) +print(path) +if path.startswith('/opt'): + # if installed into system path, do not muck with things + sys.path.append(path) +import confluentd.main + +#import cProfile +#import time +#p = cProfile.Profile(time.clock) +#p.enable() +#try: +import multiprocessing +if __name__ == '__main__': + multiprocessing.freeze_support() + confluentd.main.run() +#except: +# pass +#p.disable() +#p.print_stats(sort='cumulative') +#p.print_stats(sort='time') diff --git a/confluent_server/confluent/__init__.py b/confluent_server/confluent/__init__.py deleted file mode 100644 index 0bfb5a62..00000000 --- a/confluent_server/confluent/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from pkgutil import extend_path -__path__ = extend_path(__path__, __name__) \ No newline at end of file diff --git a/confluent_server/confluent/config/__init__.py b/confluent_server/confluentd/__init__.py similarity index 100% rename from confluent_server/confluent/config/__init__.py rename to confluent_server/confluentd/__init__.py diff --git a/confluent_server/confluent/alerts.py b/confluent_server/confluentd/alerts.py similarity index 93% rename from confluent_server/confluent/alerts.py rename to confluent_server/confluentd/alerts.py index 81328470..6acd3b62 100644 --- a/confluent_server/confluent/alerts.py +++ b/confluent_server/confluentd/alerts.py @@ -30,9 +30,9 @@ __author__ = 'jjohnson2' -import confluent.exceptions as exc -import confluent.lookuptools as lookuptools -import confluent.core +import confluentd.exceptions as exc +import confluentd.lookuptools as lookuptools +import confluentd.core def decode_alert(varbinds, configmanager): """Decode an SNMP alert for a server @@ -53,7 +53,7 @@ def decode_alert(varbinds, configmanager): if node is None: raise exc.InvalidArgumentException( 'Unable to find a node with specified manager') - return confluent.core.handle_path( + return confluentd.core.handle_path( '/nodes/{0}/events/hardware/decode'.format(node), 'update', configmanager, varbinds, autostrip=False) diff --git a/confluent_server/confluent/auth.py b/confluent_server/confluentd/auth.py similarity index 99% rename from confluent_server/confluent/auth.py rename to confluent_server/confluentd/auth.py index 709ac3ca..a06a59fe 100644 --- a/confluent_server/confluent/auth.py +++ b/confluent_server/confluentd/auth.py @@ -19,7 +19,7 @@ # the PBKDF2 transform is skipped unless a user has been idle for sufficient # time -import confluent.config.configmanager as configmanager +import confluentd.config.configmanager as configmanager import eventlet import eventlet.tpool import Crypto.Protocol.KDF as KDF diff --git a/confluent_server/confluent/interface/__init__.py b/confluent_server/confluentd/config/__init__.py similarity index 100% rename from confluent_server/confluent/interface/__init__.py rename to confluent_server/confluentd/config/__init__.py diff --git a/confluent_server/confluent/config/attributes.py b/confluent_server/confluentd/config/attributes.py similarity index 100% rename from confluent_server/confluent/config/attributes.py rename to confluent_server/confluentd/config/attributes.py diff --git a/confluent_server/confluent/config/configmanager.py b/confluent_server/confluentd/config/configmanager.py similarity index 97% rename from confluent_server/confluent/config/configmanager.py rename to confluent_server/confluentd/config/configmanager.py index 59878d57..65e933af 100644 --- a/confluent_server/confluent/config/configmanager.py +++ b/confluent_server/confluentd/config/configmanager.py @@ -64,10 +64,10 @@ from Crypto.Hash import SHA256 import anydbm as dbm import ast import base64 -import confluent.config.attributes as allattributes -import confluent.log -import confluent.util -import confluent.exceptions as exc +import confluentd.config.attributes as allattributes +import confluentd.log +import confluentd.util +import confluentd.exceptions as exc import copy import cPickle import errno @@ -276,11 +276,11 @@ def _generate_new_id(): # generate a random id outside the usual ranges used for normal users in # /etc/passwd. Leave an equivalent amount of space near the end disused, # just in case - uid = str(confluent.util.securerandomnumber(65537, 4294901759)) + uid = str(confluentd.util.securerandomnumber(65537, 4294901759)) if 'idmap' not in _cfgstore['main']: return uid while uid in _cfgstore['main']['idmap']: - uid = str(confluent.util.securerandomnumber(65537, 4294901759)) + uid = str(confluentd.util.securerandomnumber(65537, 4294901759)) return uid @@ -415,7 +415,11 @@ def hook_new_configmanagers(callback): class ConfigManager(object): - _cfgdir = "/etc/confluent/cfg/" + if os.name == 'nt': + _cfgdir = os.path.join( + os.getenv('SystemDrive'), '\\ProgramData', 'confluent', 'cfg') + else: + _cfgdir = "/etc/confluent/cfg" _cfgwriter = None _writepending = False _syncrunning = False @@ -1009,7 +1013,7 @@ class ConfigManager(object): except Exception: global tracelog if tracelog is None: - tracelog = confluent.log.Logger('trace') + tracelog = confluentd.log.Logger('trace') tracelog.log(traceback.format_exc(), ltype=log.DataTypes.event, event=log.Events.stacktrace) @@ -1207,15 +1211,15 @@ class ConfigManager(object): global _cfgstore _cfgstore = {} rootpath = cls._cfgdir - _load_dict_from_dbm(['globals'], rootpath + "/globals") + _load_dict_from_dbm(['globals'], os.path.join(rootpath, "globals")) for confarea in _config_areas: - _load_dict_from_dbm(['main', confarea], rootpath + "/" + confarea) + _load_dict_from_dbm(['main', confarea], os.path.join(rootpath, confarea)) try: - for tenant in os.listdir(rootpath + '/tenants/'): + for tenant in os.listdir(os.path.join(rootpath, 'tenants')): for confarea in _config_areas: _load_dict_from_dbm( ['main', tenant, confarea], - "%s/%s/%s" % (rootpath, tenant, confarea)) + os.path.join(rootpath, tenant, confarea)) except OSError: pass @@ -1246,7 +1250,7 @@ class ConfigManager(object): dirtyglobals = copy.deepcopy(_cfgstore['dirtyglobals']) del _cfgstore['dirtyglobals'] _mkpath(cls._cfgdir) - globalf = dbm.open(cls._cfgdir + "/globals", 'c', 384) # 0600 + globalf = dbm.open(os.path.join(cls._cfgdir, "globals"), 'c', 384) # 0600 try: for globalkey in dirtyglobals: if globalkey in _cfgstore['globals']: @@ -1267,11 +1271,11 @@ class ConfigManager(object): pathname = cls._cfgdir currdict = _cfgstore['main'] else: - pathname = cls._cfgdir + '/tenants/' + tenant + '/' + pathname = os.path.join(cls._cfgdir, 'tenants', tenant) currdict = _cfgstore['tenant'][tenant] for category in dkdict.iterkeys(): _mkpath(pathname) - dbf = dbm.open(pathname + category, 'c', 384) # 0600 + dbf = dbm.open(os.path.join(pathname, category), 'c', 384) # 0600 try: for ck in dkdict[category]: if ck not in currdict[category]: @@ -1325,7 +1329,8 @@ def dump_db_to_directory(location, password, redact=None): cfgfile.write(ConfigManager(tenant=None)._dump_to_json(redact=redact)) cfgfile.write('\n') try: - for tenant in os.listdir(ConfigManager._cfgdir + '/tenants/'): + for tenant in os.listdir( + os.path.join(ConfigManager._cfgdir, '/tenants/')): with open(os.path.join(location, tenant + '.json'), 'w') as cfgfile: cfgfile.write(ConfigManager(tenant=tenant)._dump_to_json( redact=redact)) diff --git a/confluent_server/confluent/consoleserver.py b/confluent_server/confluentd/consoleserver.py similarity index 98% rename from confluent_server/confluent/consoleserver.py rename to confluent_server/confluentd/consoleserver.py index 37a70161..25eb1287 100644 --- a/confluent_server/confluent/consoleserver.py +++ b/confluent_server/confluentd/consoleserver.py @@ -21,12 +21,12 @@ #we track nodes that are actively being logged, watched, or have attached #there should be no more than one handler per node import collections -import confluent.config.configmanager as configmodule -import confluent.exceptions as exc -import confluent.interface.console as conapi -import confluent.log as log -import confluent.core as plugin -import confluent.util as util +import confluentd.config.configmanager as configmodule +import confluentd.exceptions as exc +import confluentd.interface.console as conapi +import confluentd.log as log +import confluentd.core as plugin +import confluentd.util as util import eventlet import eventlet.event import random diff --git a/confluent_server/confluent/core.py b/confluent_server/confluentd/core.py similarity index 98% rename from confluent_server/confluent/core.py rename to confluent_server/confluentd/core.py index 43ddce12..4203e1b3 100644 --- a/confluent_server/confluent/core.py +++ b/confluent_server/confluentd/core.py @@ -33,14 +33,14 @@ # functions. Console is special and just get's passed through # see API.txt -import confluent.alerts as alerts -import confluent.config.attributes as attrscheme -import confluent.interface.console as console -import confluent.exceptions as exc -import confluent.messages as msg -import confluent.noderange as noderange +import confluentd.alerts as alerts +import confluentd.config.attributes as attrscheme +import confluentd.interface.console as console +import confluentd.exceptions as exc +import confluentd.messages as msg +import confluentd.noderange as noderange try: - import confluent.shellmodule as shellmodule + import confluentd.shellmodule as shellmodule except ImportError: pass import itertools diff --git a/confluent_server/confluent/exceptions.py b/confluent_server/confluentd/exceptions.py similarity index 100% rename from confluent_server/confluent/exceptions.py rename to confluent_server/confluentd/exceptions.py diff --git a/confluent_server/confluent/httpapi.py b/confluent_server/confluentd/httpapi.py similarity index 95% rename from confluent_server/confluent/httpapi.py rename to confluent_server/confluentd/httpapi.py index 4c53a39e..6901efed 100644 --- a/confluent_server/confluent/httpapi.py +++ b/confluent_server/confluentd/httpapi.py @@ -18,15 +18,15 @@ # It additionally manages httprequest console sessions import base64 import Cookie -import confluent.auth as auth -import confluent.config.attributes as attribs -import confluent.consoleserver as consoleserver -import confluent.exceptions as exc -import confluent.log as log -import confluent.messages -import confluent.core as pluginapi -import confluent.tlvdata as tlvdata -import confluent.util as util +import confluentd.auth as auth +import confluentd.config.attributes as attribs +import confluentd.consoleserver as consoleserver +import confluentd.exceptions as exc +import confluentd.log as log +import confluentd.messages +import confluentd.core as pluginapi +import confluent.tlvdata +import confluentd.util as util import copy import eventlet import json @@ -36,6 +36,7 @@ import time import urlparse import eventlet.wsgi #scgi = eventlet.import_patched('flup.server.scgi') +tlvdata = confluent.tlvdata auditlog = None @@ -61,44 +62,44 @@ class RobustCookie(Cookie.SimpleCookie): def group_creation_resources(): - yield confluent.messages.Attributes( + yield confluentd.messages.Attributes( kv={'name': None}, desc="Name of the group").html() + '
' - yield confluent.messages.ListAttributes(kv={'nodes': []}, + yield confluentd.messages.ListAttributes(kv={'nodes': []}, desc='Nodes to add to the group' ).html() + '
\n' for attr in sorted(attribs.node.iterkeys()): if attr == 'groups': continue if attr.startswith("secret."): - yield confluent.messages.CryptedAttributes( + yield confluentd.messages.CryptedAttributes( kv={attr: None}, desc=attribs.node[attr]['description']).html() + '
\n' elif ('type' in attribs.node[attr] and list == attribs.node[attr]['type']): - yield confluent.messages.ListAttributes( + yield confluentd.messages.ListAttributes( kv={attr: []}, desc=attribs.node[attr]['description']).html() + '
\n' else: - yield confluent.messages.Attributes( + yield confluentd.messages.Attributes( kv={attr: None}, desc=attribs.node[attr]['description']).html() + '
\n' def node_creation_resources(): - yield confluent.messages.Attributes( + yield confluentd.messages.Attributes( kv={'name': None}, desc="Name of the node").html() + '
' for attr in sorted(attribs.node.iterkeys()): if attr.startswith("secret."): - yield confluent.messages.CryptedAttributes( + yield confluentd.messages.CryptedAttributes( kv={attr: None}, desc=attribs.node[attr]['description']).html() + '
\n' elif ('type' in attribs.node[attr] and list == attribs.node[attr]['type']): - yield confluent.messages.ListAttributes( + yield confluentd.messages.ListAttributes( kv={attr: []}, desc=attribs.node[attr]['description']).html() + '
\n' else: - yield confluent.messages.Attributes( + yield confluentd.messages.Attributes( kv={attr: None}, desc=attribs.node[attr]['description']).html() + '
\n' @@ -120,11 +121,11 @@ def user_creation_resources(): } for attr in sorted(credential.iterkeys()): if attr == "password": - yield confluent.messages.CryptedAttributes( + yield confluentd.messages.CryptedAttributes( kv={attr: None}, desc=credential[attr]['description']).html() + '
\n' else: - yield confluent.messages.Attributes( + yield confluentd.messages.Attributes( kv={attr: None}, desc=credential[attr]['description']).html() + '
\n' @@ -465,7 +466,7 @@ def _assemble_html(responses, resource, querydict, url, extension): extension) pendingrsp = [] for rsp in responses: - if isinstance(rsp, confluent.messages.LinkRelation): + if isinstance(rsp, confluentd.messages.LinkRelation): yield rsp.html(extension) + "
" else: pendingrsp.append(rsp) @@ -511,7 +512,7 @@ def _assemble_json(responses, resource, url, extension): links['collection'] = {"href": "./" + extension} rspdata = {} for rsp in responses: - if isinstance(rsp, confluent.messages.LinkRelation): + if isinstance(rsp, confluentd.messages.LinkRelation): haldata = rsp.raw() for hk in haldata.iterkeys(): if 'href' in haldata[hk]: diff --git a/confluent_server/confluent/plugins/__init__.py b/confluent_server/confluentd/interface/__init__.py similarity index 100% rename from confluent_server/confluent/plugins/__init__.py rename to confluent_server/confluentd/interface/__init__.py diff --git a/confluent_server/confluent/interface/console.py b/confluent_server/confluentd/interface/console.py similarity index 100% rename from confluent_server/confluent/interface/console.py rename to confluent_server/confluentd/interface/console.py diff --git a/confluent_server/confluent/log.py b/confluent_server/confluentd/log.py similarity index 96% rename from confluent_server/confluent/log.py rename to confluent_server/confluentd/log.py index 7d283883..b95a2f75 100644 --- a/confluent_server/confluent/log.py +++ b/confluent_server/confluentd/log.py @@ -60,7 +60,7 @@ # or other fields) import collections -import confluent.config.configmanager +import confluentd.config.configmanager import eventlet import json import os @@ -128,9 +128,14 @@ class Logger(object): # we are just a copy of the same object return self.initialized = True - self.filepath = confluent.config.configmanager.get_global("logdirectory") + self.filepath = confluentd.config.configmanager.get_global("logdirectory") if self.filepath is None: - self.filepath = "/var/log/confluent/" + if os.name == 'nt': + self.filepath = os.path.join( + os.getenv('SystemDrive'), '\\ProgramData', 'confluent', + 'logs') + else: + self.filepath = "/var/log/confluent/" self.isconsole = console if console: self.filepath += "consoles/" diff --git a/confluent_server/confluent/lookuptools.py b/confluent_server/confluentd/lookuptools.py similarity index 97% rename from confluent_server/confluent/lookuptools.py rename to confluent_server/confluentd/lookuptools.py index 6dbde2b2..2da19e32 100644 --- a/confluent_server/confluent/lookuptools.py +++ b/confluent_server/confluentd/lookuptools.py @@ -25,7 +25,7 @@ # service should have a null tenant and a tenant entry that correlates) __author__ = 'jjohnson2' -import confluent.config.configmanager as configmanager +import confluentd.config.configmanager as configmanager import itertools import socket diff --git a/confluent_server/confluent/main.py b/confluent_server/confluentd/main.py similarity index 92% rename from confluent_server/confluent/main.py rename to confluent_server/confluentd/main.py index cb6dd925..1feb80eb 100644 --- a/confluent_server/confluent/main.py +++ b/confluent_server/confluentd/main.py @@ -26,14 +26,14 @@ # It also will optionally snoop SLP DA requests import atexit -import confluent.auth as auth -import confluent.config.configmanager as configmanager -import confluent.consoleserver as consoleserver -import confluent.core as confluentcore -import confluent.httpapi as httpapi -import confluent.log as log +import confluentd.auth as auth +import confluentd.config.configmanager as configmanager +import confluentd.consoleserver as consoleserver +import confluentd.core as confluentcore +import confluentd.httpapi as httpapi +import confluentd.log as log try: - import confluent.sockapi as sockapi + import confluentd.sockapi as sockapi except ImportError: #On platforms without pwd, give up on the sockapi in general and be http #only for now @@ -139,6 +139,9 @@ def _initsecurity(config): def run(): if 'fcntl' in locals(): _checkpidfile() + if os.name == 'nt': + configfile = os.path.join(os.getenv('SystemDrive'), '\\ProgramData', + 'confluent', 'cfg', 'service.cfg') configfile = "/etc/confluent/service.cfg" config = ConfigParser.ConfigParser() config.read(configfile) diff --git a/confluent_server/confluent/messages.py b/confluent_server/confluentd/messages.py similarity index 99% rename from confluent_server/confluent/messages.py rename to confluent_server/confluentd/messages.py index 08cad09c..eb9e93ff 100644 --- a/confluent_server/confluent/messages.py +++ b/confluent_server/confluentd/messages.py @@ -18,7 +18,7 @@ # This module implements client/server messages emitted from plugins. # Things are defined here to 'encourage' developers to coordinate information # format. This is also how different data formats are supported -import confluent.exceptions as exc +import confluentd.exceptions as exc import json valid_health_values = set([ diff --git a/confluent_server/confluent/noderange.py b/confluent_server/confluentd/noderange.py similarity index 100% rename from confluent_server/confluent/noderange.py rename to confluent_server/confluentd/noderange.py diff --git a/confluent_server/confluent/plugins/configuration/__init__.py b/confluent_server/confluentd/plugins/__init__.py similarity index 100% rename from confluent_server/confluent/plugins/configuration/__init__.py rename to confluent_server/confluentd/plugins/__init__.py diff --git a/confluent_server/confluent/plugins/hardwaremanagement/__init__.py b/confluent_server/confluentd/plugins/configuration/__init__.py similarity index 100% rename from confluent_server/confluent/plugins/hardwaremanagement/__init__.py rename to confluent_server/confluentd/plugins/configuration/__init__.py diff --git a/confluent_server/confluent/plugins/configuration/attributes.py b/confluent_server/confluentd/plugins/configuration/attributes.py similarity index 98% rename from confluent_server/confluent/plugins/configuration/attributes.py rename to confluent_server/confluentd/plugins/configuration/attributes.py index 9ee0f149..e05a824d 100644 --- a/confluent_server/confluent/plugins/configuration/attributes.py +++ b/confluent_server/confluentd/plugins/configuration/attributes.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import confluent.exceptions as exc -import confluent.messages as msg -import confluent.config.attributes as allattributes +import confluentd.exceptions as exc +import confluentd.messages as msg +import confluentd.config.attributes as allattributes def retrieve(nodes, element, configmanager, inputdata): diff --git a/confluent_server/confluentd/plugins/hardwaremanagement/__init__.py b/confluent_server/confluentd/plugins/hardwaremanagement/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluentd/plugins/hardwaremanagement/ipmi.py similarity index 99% rename from confluent_server/confluent/plugins/hardwaremanagement/ipmi.py rename to confluent_server/confluentd/plugins/hardwaremanagement/ipmi.py index a03e67b9..4140ef0c 100644 --- a/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluentd/plugins/hardwaremanagement/ipmi.py @@ -14,9 +14,9 @@ # limitations under the License. import atexit -import confluent.exceptions as exc -import confluent.interface.console as conapi -import confluent.messages as msg +import confluentd.exceptions as exc +import confluentd.interface.console as conapi +import confluentd.messages as msg import eventlet import eventlet.event import eventlet.green.threading as threading diff --git a/confluent_server/confluent/shellmodule.py b/confluent_server/confluentd/shellmodule.py similarity index 99% rename from confluent_server/confluent/shellmodule.py rename to confluent_server/confluentd/shellmodule.py index 08b6a8ef..811ea1ee 100644 --- a/confluent_server/confluent/shellmodule.py +++ b/confluent_server/confluentd/shellmodule.py @@ -22,7 +22,7 @@ # only by the process owner and such an owner would be able to read a file # anyway. Regardless, it is advisable to 'unset' -import confluent.interface.console as conapi +import confluentd.interface.console as conapi import eventlet import eventlet.green.select as select import eventlet.green.subprocess as subprocess diff --git a/confluent_server/confluent/sockapi.py b/confluent_server/confluentd/sockapi.py similarity index 97% rename from confluent_server/confluent/sockapi.py rename to confluent_server/confluentd/sockapi.py index 9a67c3ca..9cb9ba70 100644 --- a/confluent_server/confluent/sockapi.py +++ b/confluent_server/confluentd/sockapi.py @@ -32,13 +32,13 @@ import eventlet.green.socket as socket import eventlet.green.ssl as ssl import eventlet -import confluent.auth as auth +import confluentd.auth as auth import confluent.tlvdata as tlvdata -import confluent.consoleserver as consoleserver -import confluent.config.configmanager as configmanager -import confluent.exceptions as exc -import confluent.log as log -import confluent.core as pluginapi +import confluentd.consoleserver as consoleserver +import confluentd.config.configmanager as configmanager +import confluentd.exceptions as exc +import confluentd.log as log +import confluentd.core as pluginapi tracelog = None diff --git a/confluent_server/confluent/util.py b/confluent_server/confluentd/util.py similarity index 100% rename from confluent_server/confluent/util.py rename to confluent_server/confluentd/util.py From a0e3dca85685e09a11c156b70fc716dbcc6b00db Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Fri, 31 Jul 2015 18:22:05 -0400 Subject: [PATCH 3/5] Add PyInstaller spec file This facilitates a 'onedir' portable format for confluent server. The 'onefile' mode couldn't be made to work, but this should suffice. --- confluent_server/confluentsrv.spec | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 confluent_server/confluentsrv.spec diff --git a/confluent_server/confluentsrv.spec b/confluent_server/confluentsrv.spec new file mode 100644 index 00000000..0847860c --- /dev/null +++ b/confluent_server/confluentsrv.spec @@ -0,0 +1,30 @@ +# -*- mode: python -*- + +block_cipher = None + + +a = Analysis(['c:/Python27/Scripts/confluentsrv.py'], + pathex=['c:\\Users\\jjohnson2\\Development\\confluent\\confluent_server'], + hiddenimports=['pyghmi.constants', 'pyghmi.exceptions', 'pyghmi.ipmi.console', 'pyghmi.ipmi.private.constants', 'pyghmi.ipmi.private', 'pyghmi.ipmi.private.session', 'pyghmi.ipmi.command', 'pyghmi.ipmi.events', 'pyghmi.ipmi.fru', 'pyghmi.ipmi.private.spd', 'pyghmi.ipmi.oem.lookup', 'pyghmi.ipmi.oem.generic', 'pyghmi.ipmi.oem.lenovo', 'pyghmi.ipmi.private.util', 'pyghmi.ipmi.sdr'], + hookspath=None, + runtime_hooks=None, + excludes=None, + cipher=block_cipher) +pyz = PYZ(a.pure, + cipher=block_cipher) +exe = EXE(pyz, + a.scripts, + exclude_binaries=True, + name='confluentsrv.exe', + debug=False, + strip=None, + upx=True, + console=True ) +coll = COLLECT(exe, + a.binaries, + a.zipfiles, + a.datas, + Tree('confluentd/plugins', prefix='confluentd/plugins'), + strip=None, + upx=True, + name='confluentsrv') From f7b383b692bfac968964fa9b9dd82ec1b6fa7d38 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 12 Aug 2015 13:06:49 -0400 Subject: [PATCH 4/5] Revert 'confluentd' change After further investigation, the rename to confluentd was not needed (after massaging pathex and using pip to install rather than distutils). --- confluent_server/bin/confluentsrv.py | 4 +- .../{confluentd => confluent}/__init__.py | 0 .../{confluentd => confluent}/alerts.py | 8 ++-- .../{confluentd => confluent}/auth.py | 2 +- .../config/__init__.py | 0 .../config/attributes.py | 0 .../config/configmanager.py | 14 +++---- .../consoleserver.py | 12 +++--- .../{confluentd => confluent}/core.py | 14 +++---- .../{confluentd => confluent}/exceptions.py | 0 .../{confluentd => confluent}/httpapi.py | 42 +++++++++---------- .../interface/__init__.py | 0 .../interface/console.py | 0 .../{confluentd => confluent}/log.py | 4 +- .../{confluentd => confluent}/lookuptools.py | 2 +- .../{confluentd => confluent}/main.py | 14 +++---- .../{confluentd => confluent}/messages.py | 2 +- .../{confluentd => confluent}/noderange.py | 0 .../plugins/__init__.py | 0 .../plugins/configuration/__init__.py | 0 .../plugins/configuration/attributes.py | 6 +-- .../plugins/hardwaremanagement/__init__.py | 0 .../plugins/hardwaremanagement/ipmi.py | 6 +-- .../{confluentd => confluent}/shellmodule.py | 2 +- .../{confluentd => confluent}/sockapi.py | 12 +++--- .../{confluentd => confluent}/util.py | 0 confluent_server/confluentsrv.spec | 4 +- 27 files changed, 74 insertions(+), 74 deletions(-) rename confluent_server/{confluentd => confluent}/__init__.py (100%) rename confluent_server/{confluentd => confluent}/alerts.py (93%) rename confluent_server/{confluentd => confluent}/auth.py (99%) rename confluent_server/{confluentd => confluent}/config/__init__.py (100%) rename confluent_server/{confluentd => confluent}/config/attributes.py (100%) rename confluent_server/{confluentd => confluent}/config/configmanager.py (99%) rename confluent_server/{confluentd => confluent}/consoleserver.py (98%) rename confluent_server/{confluentd => confluent}/core.py (98%) rename confluent_server/{confluentd => confluent}/exceptions.py (100%) rename confluent_server/{confluentd => confluent}/httpapi.py (95%) rename confluent_server/{confluentd => confluent}/interface/__init__.py (100%) rename confluent_server/{confluentd => confluent}/interface/console.py (100%) rename confluent_server/{confluentd => confluent}/log.py (98%) rename confluent_server/{confluentd => confluent}/lookuptools.py (97%) rename confluent_server/{confluentd => confluent}/main.py (95%) rename confluent_server/{confluentd => confluent}/messages.py (99%) rename confluent_server/{confluentd => confluent}/noderange.py (100%) rename confluent_server/{confluentd => confluent}/plugins/__init__.py (100%) rename confluent_server/{confluentd => confluent}/plugins/configuration/__init__.py (100%) rename confluent_server/{confluentd => confluent}/plugins/configuration/attributes.py (98%) rename confluent_server/{confluentd => confluent}/plugins/hardwaremanagement/__init__.py (100%) rename confluent_server/{confluentd => confluent}/plugins/hardwaremanagement/ipmi.py (99%) rename confluent_server/{confluentd => confluent}/shellmodule.py (99%) rename confluent_server/{confluentd => confluent}/sockapi.py (97%) rename confluent_server/{confluentd => confluent}/util.py (100%) diff --git a/confluent_server/bin/confluentsrv.py b/confluent_server/bin/confluentsrv.py index fbc929ea..39920e53 100644 --- a/confluent_server/bin/confluentsrv.py +++ b/confluent_server/bin/confluentsrv.py @@ -23,7 +23,7 @@ print(path) if path.startswith('/opt'): # if installed into system path, do not muck with things sys.path.append(path) -import confluentd.main +import confluent.main #import cProfile #import time @@ -33,7 +33,7 @@ import confluentd.main import multiprocessing if __name__ == '__main__': multiprocessing.freeze_support() - confluentd.main.run() + confluent.main.run() #except: # pass #p.disable() diff --git a/confluent_server/confluentd/__init__.py b/confluent_server/confluent/__init__.py similarity index 100% rename from confluent_server/confluentd/__init__.py rename to confluent_server/confluent/__init__.py diff --git a/confluent_server/confluentd/alerts.py b/confluent_server/confluent/alerts.py similarity index 93% rename from confluent_server/confluentd/alerts.py rename to confluent_server/confluent/alerts.py index 6acd3b62..81328470 100644 --- a/confluent_server/confluentd/alerts.py +++ b/confluent_server/confluent/alerts.py @@ -30,9 +30,9 @@ __author__ = 'jjohnson2' -import confluentd.exceptions as exc -import confluentd.lookuptools as lookuptools -import confluentd.core +import confluent.exceptions as exc +import confluent.lookuptools as lookuptools +import confluent.core def decode_alert(varbinds, configmanager): """Decode an SNMP alert for a server @@ -53,7 +53,7 @@ def decode_alert(varbinds, configmanager): if node is None: raise exc.InvalidArgumentException( 'Unable to find a node with specified manager') - return confluentd.core.handle_path( + return confluent.core.handle_path( '/nodes/{0}/events/hardware/decode'.format(node), 'update', configmanager, varbinds, autostrip=False) diff --git a/confluent_server/confluentd/auth.py b/confluent_server/confluent/auth.py similarity index 99% rename from confluent_server/confluentd/auth.py rename to confluent_server/confluent/auth.py index a06a59fe..709ac3ca 100644 --- a/confluent_server/confluentd/auth.py +++ b/confluent_server/confluent/auth.py @@ -19,7 +19,7 @@ # the PBKDF2 transform is skipped unless a user has been idle for sufficient # time -import confluentd.config.configmanager as configmanager +import confluent.config.configmanager as configmanager import eventlet import eventlet.tpool import Crypto.Protocol.KDF as KDF diff --git a/confluent_server/confluentd/config/__init__.py b/confluent_server/confluent/config/__init__.py similarity index 100% rename from confluent_server/confluentd/config/__init__.py rename to confluent_server/confluent/config/__init__.py diff --git a/confluent_server/confluentd/config/attributes.py b/confluent_server/confluent/config/attributes.py similarity index 100% rename from confluent_server/confluentd/config/attributes.py rename to confluent_server/confluent/config/attributes.py diff --git a/confluent_server/confluentd/config/configmanager.py b/confluent_server/confluent/config/configmanager.py similarity index 99% rename from confluent_server/confluentd/config/configmanager.py rename to confluent_server/confluent/config/configmanager.py index 65e933af..97856739 100644 --- a/confluent_server/confluentd/config/configmanager.py +++ b/confluent_server/confluent/config/configmanager.py @@ -64,10 +64,10 @@ from Crypto.Hash import SHA256 import anydbm as dbm import ast import base64 -import confluentd.config.attributes as allattributes -import confluentd.log -import confluentd.util -import confluentd.exceptions as exc +import confluent.config.attributes as allattributes +import confluent.log +import confluent.util +import confluent.exceptions as exc import copy import cPickle import errno @@ -276,11 +276,11 @@ def _generate_new_id(): # generate a random id outside the usual ranges used for normal users in # /etc/passwd. Leave an equivalent amount of space near the end disused, # just in case - uid = str(confluentd.util.securerandomnumber(65537, 4294901759)) + uid = str(confluent.util.securerandomnumber(65537, 4294901759)) if 'idmap' not in _cfgstore['main']: return uid while uid in _cfgstore['main']['idmap']: - uid = str(confluentd.util.securerandomnumber(65537, 4294901759)) + uid = str(confluent.util.securerandomnumber(65537, 4294901759)) return uid @@ -1013,7 +1013,7 @@ class ConfigManager(object): except Exception: global tracelog if tracelog is None: - tracelog = confluentd.log.Logger('trace') + tracelog = confluent.log.Logger('trace') tracelog.log(traceback.format_exc(), ltype=log.DataTypes.event, event=log.Events.stacktrace) diff --git a/confluent_server/confluentd/consoleserver.py b/confluent_server/confluent/consoleserver.py similarity index 98% rename from confluent_server/confluentd/consoleserver.py rename to confluent_server/confluent/consoleserver.py index 25eb1287..37a70161 100644 --- a/confluent_server/confluentd/consoleserver.py +++ b/confluent_server/confluent/consoleserver.py @@ -21,12 +21,12 @@ #we track nodes that are actively being logged, watched, or have attached #there should be no more than one handler per node import collections -import confluentd.config.configmanager as configmodule -import confluentd.exceptions as exc -import confluentd.interface.console as conapi -import confluentd.log as log -import confluentd.core as plugin -import confluentd.util as util +import confluent.config.configmanager as configmodule +import confluent.exceptions as exc +import confluent.interface.console as conapi +import confluent.log as log +import confluent.core as plugin +import confluent.util as util import eventlet import eventlet.event import random diff --git a/confluent_server/confluentd/core.py b/confluent_server/confluent/core.py similarity index 98% rename from confluent_server/confluentd/core.py rename to confluent_server/confluent/core.py index 4203e1b3..43ddce12 100644 --- a/confluent_server/confluentd/core.py +++ b/confluent_server/confluent/core.py @@ -33,14 +33,14 @@ # functions. Console is special and just get's passed through # see API.txt -import confluentd.alerts as alerts -import confluentd.config.attributes as attrscheme -import confluentd.interface.console as console -import confluentd.exceptions as exc -import confluentd.messages as msg -import confluentd.noderange as noderange +import confluent.alerts as alerts +import confluent.config.attributes as attrscheme +import confluent.interface.console as console +import confluent.exceptions as exc +import confluent.messages as msg +import confluent.noderange as noderange try: - import confluentd.shellmodule as shellmodule + import confluent.shellmodule as shellmodule except ImportError: pass import itertools diff --git a/confluent_server/confluentd/exceptions.py b/confluent_server/confluent/exceptions.py similarity index 100% rename from confluent_server/confluentd/exceptions.py rename to confluent_server/confluent/exceptions.py diff --git a/confluent_server/confluentd/httpapi.py b/confluent_server/confluent/httpapi.py similarity index 95% rename from confluent_server/confluentd/httpapi.py rename to confluent_server/confluent/httpapi.py index 6901efed..ba818a53 100644 --- a/confluent_server/confluentd/httpapi.py +++ b/confluent_server/confluent/httpapi.py @@ -18,15 +18,15 @@ # It additionally manages httprequest console sessions import base64 import Cookie -import confluentd.auth as auth -import confluentd.config.attributes as attribs -import confluentd.consoleserver as consoleserver -import confluentd.exceptions as exc -import confluentd.log as log -import confluentd.messages -import confluentd.core as pluginapi +import confluent.auth as auth +import confluent.config.attributes as attribs +import confluent.consoleserver as consoleserver +import confluent.exceptions as exc +import confluent.log as log +import confluent.messages +import confluent.core as pluginapi import confluent.tlvdata -import confluentd.util as util +import confluent.util as util import copy import eventlet import json @@ -62,44 +62,44 @@ class RobustCookie(Cookie.SimpleCookie): def group_creation_resources(): - yield confluentd.messages.Attributes( + yield confluent.messages.Attributes( kv={'name': None}, desc="Name of the group").html() + '
' - yield confluentd.messages.ListAttributes(kv={'nodes': []}, + yield confluent.messages.ListAttributes(kv={'nodes': []}, desc='Nodes to add to the group' ).html() + '
\n' for attr in sorted(attribs.node.iterkeys()): if attr == 'groups': continue if attr.startswith("secret."): - yield confluentd.messages.CryptedAttributes( + yield confluent.messages.CryptedAttributes( kv={attr: None}, desc=attribs.node[attr]['description']).html() + '
\n' elif ('type' in attribs.node[attr] and list == attribs.node[attr]['type']): - yield confluentd.messages.ListAttributes( + yield confluent.messages.ListAttributes( kv={attr: []}, desc=attribs.node[attr]['description']).html() + '
\n' else: - yield confluentd.messages.Attributes( + yield confluent.messages.Attributes( kv={attr: None}, desc=attribs.node[attr]['description']).html() + '
\n' def node_creation_resources(): - yield confluentd.messages.Attributes( + yield confluent.messages.Attributes( kv={'name': None}, desc="Name of the node").html() + '
' for attr in sorted(attribs.node.iterkeys()): if attr.startswith("secret."): - yield confluentd.messages.CryptedAttributes( + yield confluent.messages.CryptedAttributes( kv={attr: None}, desc=attribs.node[attr]['description']).html() + '
\n' elif ('type' in attribs.node[attr] and list == attribs.node[attr]['type']): - yield confluentd.messages.ListAttributes( + yield confluent.messages.ListAttributes( kv={attr: []}, desc=attribs.node[attr]['description']).html() + '
\n' else: - yield confluentd.messages.Attributes( + yield confluent.messages.Attributes( kv={attr: None}, desc=attribs.node[attr]['description']).html() + '
\n' @@ -121,11 +121,11 @@ def user_creation_resources(): } for attr in sorted(credential.iterkeys()): if attr == "password": - yield confluentd.messages.CryptedAttributes( + yield confluent.messages.CryptedAttributes( kv={attr: None}, desc=credential[attr]['description']).html() + '
\n' else: - yield confluentd.messages.Attributes( + yield confluent.messages.Attributes( kv={attr: None}, desc=credential[attr]['description']).html() + '
\n' @@ -466,7 +466,7 @@ def _assemble_html(responses, resource, querydict, url, extension): extension) pendingrsp = [] for rsp in responses: - if isinstance(rsp, confluentd.messages.LinkRelation): + if isinstance(rsp, confluent.messages.LinkRelation): yield rsp.html(extension) + "
" else: pendingrsp.append(rsp) @@ -512,7 +512,7 @@ def _assemble_json(responses, resource, url, extension): links['collection'] = {"href": "./" + extension} rspdata = {} for rsp in responses: - if isinstance(rsp, confluentd.messages.LinkRelation): + if isinstance(rsp, confluent.messages.LinkRelation): haldata = rsp.raw() for hk in haldata.iterkeys(): if 'href' in haldata[hk]: diff --git a/confluent_server/confluentd/interface/__init__.py b/confluent_server/confluent/interface/__init__.py similarity index 100% rename from confluent_server/confluentd/interface/__init__.py rename to confluent_server/confluent/interface/__init__.py diff --git a/confluent_server/confluentd/interface/console.py b/confluent_server/confluent/interface/console.py similarity index 100% rename from confluent_server/confluentd/interface/console.py rename to confluent_server/confluent/interface/console.py diff --git a/confluent_server/confluentd/log.py b/confluent_server/confluent/log.py similarity index 98% rename from confluent_server/confluentd/log.py rename to confluent_server/confluent/log.py index b95a2f75..f6aea0bd 100644 --- a/confluent_server/confluentd/log.py +++ b/confluent_server/confluent/log.py @@ -60,7 +60,7 @@ # or other fields) import collections -import confluentd.config.configmanager +import confluent.config.configmanager import eventlet import json import os @@ -128,7 +128,7 @@ class Logger(object): # we are just a copy of the same object return self.initialized = True - self.filepath = confluentd.config.configmanager.get_global("logdirectory") + self.filepath = confluent.config.configmanager.get_global("logdirectory") if self.filepath is None: if os.name == 'nt': self.filepath = os.path.join( diff --git a/confluent_server/confluentd/lookuptools.py b/confluent_server/confluent/lookuptools.py similarity index 97% rename from confluent_server/confluentd/lookuptools.py rename to confluent_server/confluent/lookuptools.py index 2da19e32..6dbde2b2 100644 --- a/confluent_server/confluentd/lookuptools.py +++ b/confluent_server/confluent/lookuptools.py @@ -25,7 +25,7 @@ # service should have a null tenant and a tenant entry that correlates) __author__ = 'jjohnson2' -import confluentd.config.configmanager as configmanager +import confluent.config.configmanager as configmanager import itertools import socket diff --git a/confluent_server/confluentd/main.py b/confluent_server/confluent/main.py similarity index 95% rename from confluent_server/confluentd/main.py rename to confluent_server/confluent/main.py index 1feb80eb..230a404e 100644 --- a/confluent_server/confluentd/main.py +++ b/confluent_server/confluent/main.py @@ -26,14 +26,14 @@ # It also will optionally snoop SLP DA requests import atexit -import confluentd.auth as auth -import confluentd.config.configmanager as configmanager -import confluentd.consoleserver as consoleserver -import confluentd.core as confluentcore -import confluentd.httpapi as httpapi -import confluentd.log as log +import confluent.auth as auth +import confluent.config.configmanager as configmanager +import confluent.consoleserver as consoleserver +import confluent.core as confluentcore +import confluent.httpapi as httpapi +import confluent.log as log try: - import confluentd.sockapi as sockapi + import confluent.sockapi as sockapi except ImportError: #On platforms without pwd, give up on the sockapi in general and be http #only for now diff --git a/confluent_server/confluentd/messages.py b/confluent_server/confluent/messages.py similarity index 99% rename from confluent_server/confluentd/messages.py rename to confluent_server/confluent/messages.py index eb9e93ff..08cad09c 100644 --- a/confluent_server/confluentd/messages.py +++ b/confluent_server/confluent/messages.py @@ -18,7 +18,7 @@ # This module implements client/server messages emitted from plugins. # Things are defined here to 'encourage' developers to coordinate information # format. This is also how different data formats are supported -import confluentd.exceptions as exc +import confluent.exceptions as exc import json valid_health_values = set([ diff --git a/confluent_server/confluentd/noderange.py b/confluent_server/confluent/noderange.py similarity index 100% rename from confluent_server/confluentd/noderange.py rename to confluent_server/confluent/noderange.py diff --git a/confluent_server/confluentd/plugins/__init__.py b/confluent_server/confluent/plugins/__init__.py similarity index 100% rename from confluent_server/confluentd/plugins/__init__.py rename to confluent_server/confluent/plugins/__init__.py diff --git a/confluent_server/confluentd/plugins/configuration/__init__.py b/confluent_server/confluent/plugins/configuration/__init__.py similarity index 100% rename from confluent_server/confluentd/plugins/configuration/__init__.py rename to confluent_server/confluent/plugins/configuration/__init__.py diff --git a/confluent_server/confluentd/plugins/configuration/attributes.py b/confluent_server/confluent/plugins/configuration/attributes.py similarity index 98% rename from confluent_server/confluentd/plugins/configuration/attributes.py rename to confluent_server/confluent/plugins/configuration/attributes.py index e05a824d..9ee0f149 100644 --- a/confluent_server/confluentd/plugins/configuration/attributes.py +++ b/confluent_server/confluent/plugins/configuration/attributes.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import confluentd.exceptions as exc -import confluentd.messages as msg -import confluentd.config.attributes as allattributes +import confluent.exceptions as exc +import confluent.messages as msg +import confluent.config.attributes as allattributes def retrieve(nodes, element, configmanager, inputdata): diff --git a/confluent_server/confluentd/plugins/hardwaremanagement/__init__.py b/confluent_server/confluent/plugins/hardwaremanagement/__init__.py similarity index 100% rename from confluent_server/confluentd/plugins/hardwaremanagement/__init__.py rename to confluent_server/confluent/plugins/hardwaremanagement/__init__.py diff --git a/confluent_server/confluentd/plugins/hardwaremanagement/ipmi.py b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py similarity index 99% rename from confluent_server/confluentd/plugins/hardwaremanagement/ipmi.py rename to confluent_server/confluent/plugins/hardwaremanagement/ipmi.py index 4140ef0c..a03e67b9 100644 --- a/confluent_server/confluentd/plugins/hardwaremanagement/ipmi.py +++ b/confluent_server/confluent/plugins/hardwaremanagement/ipmi.py @@ -14,9 +14,9 @@ # limitations under the License. import atexit -import confluentd.exceptions as exc -import confluentd.interface.console as conapi -import confluentd.messages as msg +import confluent.exceptions as exc +import confluent.interface.console as conapi +import confluent.messages as msg import eventlet import eventlet.event import eventlet.green.threading as threading diff --git a/confluent_server/confluentd/shellmodule.py b/confluent_server/confluent/shellmodule.py similarity index 99% rename from confluent_server/confluentd/shellmodule.py rename to confluent_server/confluent/shellmodule.py index 811ea1ee..08b6a8ef 100644 --- a/confluent_server/confluentd/shellmodule.py +++ b/confluent_server/confluent/shellmodule.py @@ -22,7 +22,7 @@ # only by the process owner and such an owner would be able to read a file # anyway. Regardless, it is advisable to 'unset' -import confluentd.interface.console as conapi +import confluent.interface.console as conapi import eventlet import eventlet.green.select as select import eventlet.green.subprocess as subprocess diff --git a/confluent_server/confluentd/sockapi.py b/confluent_server/confluent/sockapi.py similarity index 97% rename from confluent_server/confluentd/sockapi.py rename to confluent_server/confluent/sockapi.py index 9cb9ba70..9a67c3ca 100644 --- a/confluent_server/confluentd/sockapi.py +++ b/confluent_server/confluent/sockapi.py @@ -32,13 +32,13 @@ import eventlet.green.socket as socket import eventlet.green.ssl as ssl import eventlet -import confluentd.auth as auth +import confluent.auth as auth import confluent.tlvdata as tlvdata -import confluentd.consoleserver as consoleserver -import confluentd.config.configmanager as configmanager -import confluentd.exceptions as exc -import confluentd.log as log -import confluentd.core as pluginapi +import confluent.consoleserver as consoleserver +import confluent.config.configmanager as configmanager +import confluent.exceptions as exc +import confluent.log as log +import confluent.core as pluginapi tracelog = None diff --git a/confluent_server/confluentd/util.py b/confluent_server/confluent/util.py similarity index 100% rename from confluent_server/confluentd/util.py rename to confluent_server/confluent/util.py diff --git a/confluent_server/confluentsrv.spec b/confluent_server/confluentsrv.spec index 0847860c..0d558ad2 100644 --- a/confluent_server/confluentsrv.spec +++ b/confluent_server/confluentsrv.spec @@ -4,7 +4,7 @@ block_cipher = None a = Analysis(['c:/Python27/Scripts/confluentsrv.py'], - pathex=['c:\\Users\\jjohnson2\\Development\\confluent\\confluent_server'], + pathex=[], hiddenimports=['pyghmi.constants', 'pyghmi.exceptions', 'pyghmi.ipmi.console', 'pyghmi.ipmi.private.constants', 'pyghmi.ipmi.private', 'pyghmi.ipmi.private.session', 'pyghmi.ipmi.command', 'pyghmi.ipmi.events', 'pyghmi.ipmi.fru', 'pyghmi.ipmi.private.spd', 'pyghmi.ipmi.oem.lookup', 'pyghmi.ipmi.oem.generic', 'pyghmi.ipmi.oem.lenovo', 'pyghmi.ipmi.private.util', 'pyghmi.ipmi.sdr'], hookspath=None, runtime_hooks=None, @@ -24,7 +24,7 @@ coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, - Tree('confluentd/plugins', prefix='confluentd/plugins'), + Tree('confluent/plugins', prefix='confluent/plugins'), strip=None, upx=True, name='confluentsrv') From 6ba7072aed526a4027dda4698ba62b46cc60c482 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 13 Aug 2015 13:46:48 -0400 Subject: [PATCH 5/5] Fix log path for windows Under windows, the log files were not being written as expected. --- confluent_server/confluent/log.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/confluent_server/confluent/log.py b/confluent_server/confluent/log.py index f6aea0bd..5b85ee54 100644 --- a/confluent_server/confluent/log.py +++ b/confluent_server/confluent/log.py @@ -135,14 +135,14 @@ class Logger(object): os.getenv('SystemDrive'), '\\ProgramData', 'confluent', 'logs') else: - self.filepath = "/var/log/confluent/" + self.filepath = "/var/log/confluent" self.isconsole = console if console: - self.filepath += "consoles/" + self.filepath = os.path.join(self.filepath, "consoles") if not os.path.isdir(self.filepath): os.makedirs(self.filepath, 448) - self.textpath = self.filepath + logname - self.binpath = self.filepath + logname + ".cbl" + self.textpath = os.path.join(self.filepath, logname) + self.binpath = os.path.join(self.filepath, logname + ".cbl") self.writer = None self.closer = None self.textfile = None