cas-admin lib/cas
by Adam Stokes
cas-admin | 28 ++++++++++++++--------------
lib/cas/network.py | 25 -------------------------
2 files changed, 14 insertions(+), 39 deletions(-)
New commits:
commit a7bfb11cc06a4e97e599b8aa3cbda3ac5fa5d745
Author: adam stokes <uzr(a)jak.rebo>
Date: Mon Oct 12 12:00:56 2009 -0400
- update paramiko transaction
diff --git a/cas-admin b/cas-admin
index ab9aac8..628ce89 100755
--- a/cas-admin
+++ b/cas-admin
@@ -21,6 +21,7 @@ import sys
import urlparse
import datetime
import calendar
+import paramiko
from cas.core import CoreBase
from cas.util import UtilBase, Logging
@@ -28,8 +29,6 @@ from cas.rpmutils import RPMBase
from cas.db import CasStorage, CasStorageException
from cas.cas_subprocess import Popen, PIPE
from cas.cas_shutil import rmtree
-from cas.network import Executor
-from paramiko import SSHClient
if sys.version_info[:2] < (2,3):
raise SystemExit("Python >= 2.3 required")
@@ -113,7 +112,8 @@ class CasServerHandler(object):
host = None
port = 22
hostname_count = 0
- ssh_obj = SSHClient()
+ ssh_obj = paramiko.SSHClient()
+ ssh_obj.load_host_keys(os.path.expanduser("~/.ssh/known_hosts"))
for server in ssh_obj.get_host_keys().keys():
server = server.strip()
# here we test for ports and apply accordingly
@@ -121,11 +121,15 @@ class CasServerHandler(object):
server, port = server.split(':')
# ssh keys place [host] when defining servers with ports
server = server[1:-1]
- results, err = Executor(server, port, settings["CASUSER"], "/bin/uname -m").run()
- if err:
- self.casLog.debug(err)
+ try:
+ ssh_obj.connect(server, port=port, username=settings["CASUSER"])
+ except paramiko.AuthenticationException, e:
+ self.casLog.debug("Failed to connect to %s: %s" % (server,e))
+ stdin, stdout, stderr = ssh_obj.exec_command("/bin/uname -m")
+ if stderr:
+ self.casLog.debug(stderr)
# clean up arch string
- for i in results:
+ for i in stdout.readlines():
arch = i.strip()
self.db.addServer(server, arch)
hostname_count = hostname_count + 1
@@ -173,8 +177,6 @@ class CasAdminApplication(object):
parser.add_option("-s","--server", dest="server_init",
help="Build SERVER DB", action="store_true",
default=False)
- parser.add_option("-f", "--hostkeys", dest="ssh_hosts",
- help="Read in line delimeted server list for cas to propagate")
parser.add_option("-p","--purge", dest="purgeData",
help="Purge files default 90 days, customize with -d",
action="store_true", default=False)
@@ -183,7 +185,6 @@ class CasAdminApplication(object):
(self.opts, args) = parser.parse_args()
self.buildDB = self.opts.buildDB
self.server_init = self.opts.server_init
- self.ssh_hosts = self.opts.ssh_hosts
self.purgeData = self.opts.purgeData
self.purgeDataDays = self.opts.purgeDataDays
@@ -220,10 +221,9 @@ class CasAdminApplication(object):
dbHandler = CasDatabaseHandler(self.casLog).run()
elif self.server_init:
self.casLog.info("Building CAS Server DB instance.")
- if not self.ssh_hosts:
- self.ssh_hosts = os.path.expanduser("~/.ssh/known_hosts")
- if not os.path.isfile(self.ssh_hosts):
- raise SystemExit(self.casLog.info("Unable to read ssh hosts keys, please provide a proper keys file"))
+ if not os.path.isfile(os.path.expanduser("~/.ssh/known_hosts")):
+ raise SystemExit(self.casLog.info("Unable to read ssh hosts keys, " \
+ "please make sure ssh client is configured properly"))
else:
serverHandler = CasServerHandler(self.casLog).run()
else:
diff --git a/lib/cas/network.py b/lib/cas/network.py
index 4cf5c15..1371730 100644
--- a/lib/cas/network.py
+++ b/lib/cas/network.py
@@ -66,28 +66,3 @@ class Download(object):
url.close()
return self.output
-class Executor(object):
- """ using paramiko to perform common tasks over
- ssh
- return : tuple of results, err
- """
- def __init__(self, remote_host, user, cmd):
- self.user = user
- self.host = remote_host
- self.cmd = cmd
- self.client = paramiko.SSHClient()
- self.client.load_system_host_keys()
-
- def go(self):
- try:
- self.client.connect(self.host, username=self.user)
- except paramiko.AuthenticationException:
- return False
-
- def run(self):
- if not self.go():
- return (None, 'Unable to authenticate to server' % (self.host,))
- stdin, stdout, stderr = self.client.exec_command(self.cmd)
- results = stdout.readlines()
- err = stderr.readlines()
- return (results, err)
14 years, 7 months
cas-admin cas.conf doc/index.rst lib/cas
by Adam Stokes
cas-admin | 46 ++++++++++++++++++++++++++--------------------
cas.conf | 2 +-
doc/index.rst | 26 +++++++++++++++-----------
lib/cas/network.py | 3 +++
4 files changed, 45 insertions(+), 32 deletions(-)
New commits:
commit a039ade1f4a091b9e76b99da635d4827e754565d
Author: adam stokes <uzr(a)jak.rebo>
Date: Mon Oct 12 11:08:08 2009 -0400
- read local ssh host keys, doc updates
diff --git a/cas-admin b/cas-admin
index 42274ec..ab9aac8 100755
--- a/cas-admin
+++ b/cas-admin
@@ -29,6 +29,7 @@ from cas.db import CasStorage, CasStorageException
from cas.cas_subprocess import Popen, PIPE
from cas.cas_shutil import rmtree
from cas.network import Executor
+from paramiko import SSHClient
if sys.version_info[:2] < (2,3):
raise SystemExit("Python >= 2.3 required")
@@ -96,9 +97,8 @@ class CasDatabaseHandler(object):
return
class CasServerHandler(object):
- def __init__(self, server_list, logger):
+ def __init__(self, logger):
self.casLog = logger
- self.server_list = server_list
self.util = UtilBase()
# setup database connection
self.first_run = False
@@ -110,21 +110,25 @@ class CasServerHandler(object):
self.db.buildTable()
def run(self):
+ host = None
+ port = 22
hostname_count = 0
- if self.server_list and os.path.isfile(self.server_list):
- fd = open(self.server_list, 'r')
- for server in fd.readlines():
- server = server.strip()
- server_connect = Executor(server, settings["CASUSER"], "/bin/uname -m").run()
- if not server_connect:
- self.casLog.debug("Unable to authenticate %s" % (server,))
- else:
- results = server_connect[0]
- # clean up arch string
- for i in results:
- arch = i.strip()
- self.db.addServer(server, arch)
- hostname_count = hostname_count + 1
+ ssh_obj = SSHClient()
+ for server in ssh_obj.get_host_keys().keys():
+ server = server.strip()
+ # here we test for ports and apply accordingly
+ if ':' in server:
+ server, port = server.split(':')
+ # ssh keys place [host] when defining servers with ports
+ server = server[1:-1]
+ results, err = Executor(server, port, settings["CASUSER"], "/bin/uname -m").run()
+ if err:
+ self.casLog.debug(err)
+ # clean up arch string
+ for i in results:
+ arch = i.strip()
+ self.db.addServer(server, arch)
+ hostname_count = hostname_count + 1
self.casLog.info("Server database built with %d server(s) added." % (hostname_count,))
return
@@ -169,7 +173,7 @@ class CasAdminApplication(object):
parser.add_option("-s","--server", dest="server_init",
help="Build SERVER DB", action="store_true",
default=False)
- parser.add_option("-f", "--serverlist", dest="server_list",
+ parser.add_option("-f", "--hostkeys", dest="ssh_hosts",
help="Read in line delimeted server list for cas to propagate")
parser.add_option("-p","--purge", dest="purgeData",
help="Purge files default 90 days, customize with -d",
@@ -179,7 +183,7 @@ class CasAdminApplication(object):
(self.opts, args) = parser.parse_args()
self.buildDB = self.opts.buildDB
self.server_init = self.opts.server_init
- self.server_list = self.opts.server_list
+ self.ssh_hosts = self.opts.ssh_hosts
self.purgeData = self.opts.purgeData
self.purgeDataDays = self.opts.purgeDataDays
@@ -216,8 +220,10 @@ class CasAdminApplication(object):
dbHandler = CasDatabaseHandler(self.casLog).run()
elif self.server_init:
self.casLog.info("Building CAS Server DB instance.")
- if self.server_list:
- serverHandler = CasServerHandler(self.server_list, self.casLog).run()
+ if not self.ssh_hosts:
+ self.ssh_hosts = os.path.expanduser("~/.ssh/known_hosts")
+ if not os.path.isfile(self.ssh_hosts):
+ raise SystemExit(self.casLog.info("Unable to read ssh hosts keys, please provide a proper keys file"))
else:
serverHandler = CasServerHandler(self.casLog).run()
else:
diff --git a/cas.conf b/cas.conf
index f3498d6..880a2db 100644
--- a/cas.conf
+++ b/cas.conf
@@ -61,4 +61,4 @@ autoPurge=no
# Define a buffersize to be set when reading a core file
# Valid options are {number, None, or blank}
# If set to None or blank default will be ~515M
-# buffersize = None
+# buffersize=None
diff --git a/doc/index.rst b/doc/index.rst
index 332f761..f81ca75 100644
--- a/doc/index.rst
+++ b/doc/index.rst
@@ -30,12 +30,6 @@ Fedora 9 or later (this would include RHEL 4/5) the EPEL repo needs to be
installed. Visit `EPEL <https://fedoraproject.org/wiki/EPEL>`_ to enable
this repository.
-Optionally install `Func <http://fedorahosted.org/func>`_
-for automatic processing on other architecture specific systems. This
-can easily be installed via `yum`::
-
- $ yum install func
-
The amount of storage needed can be determined base on the following
information:
@@ -57,18 +51,22 @@ The overall contents of this file is shown below, further down we will break up
each section and describe its meaning::
[settings]
+ casuser=root
kernels=/mnt/kernels
rpmFilter=.*kerne.+-debuginfo-[0-9].*\.rpm
debugs=/cores/debugs
debugLevel=DEBUG
workDirectory=/cores/processed
- mailServer=mail.example.com
+ smtphost=mail.example.com
database=/var/db/cas/cas.db
[maintenance]
purgeLimit=90
autoPurge=Yes
[advanced]
# crash_32=/usr/local/i386/crash
+ # buffersize=None
+
+``casuser``: (**Required**) User to run cas, recommended to run as someone other than root.
``kernels``: (**Required**) Describes the location of where kernel-debuginfo packages are to be
stored. This can range anywhere from an nfs mount, samba share, local disk or
@@ -89,7 +87,7 @@ Currently the only accepted values are ``DEBUG|INFO``.
point will need to have the most storage assigned to it. Depending on how many
cores are processed in a given timeframe this area will fill up quickly.
-``mailServer``: If wanting output of CAS processing email to a certain address
+``smtphost``: If wanting output of CAS processing email to a certain address
this directive needs to be set. ``Note`` that the mail server should not
require smtp authentication.
@@ -106,6 +104,10 @@ version of crash is installed this directive can be set to the crash binary
and CAS will automatically process x86 cores on a x86_64 machine. ``Note`` this
is only available if the CAS server is a x86_64 machine.
+``buffersize``: Extend the read buffer when analyzing a core for a timestamp.
+``Note`` this is normally needed for itanium cores, otherwise, the default is
+fine.
+
Setup & Execution
-----------------
@@ -134,18 +136,20 @@ Altering the configuration to reflect the above assumptions would show the
following::
[settings]
+ casuser=cas
kernels=/mnt/kernels
rpmFilter=.*kerne.+-debuginfo-[0-9].*\.rpm
debugs=/tmp
debugLevel=DEBUG
workDirectory=/cores
- mailServer=mail.cas-server.com
+ smtphost=mail.cas-server.com
database=/var/db/cas/cas.db
[maintenance]
purgeLimit=90
autoPurge=Yes
[advanced]
crash_32=/usr/local/i386/crash
+ #buffer=None
Now that the configuration file is altered and ``/mnt/kernels`` should be populated
with kernel-debuginfo rpm's the next section will describe running CAS.
@@ -158,9 +162,9 @@ a database for all the data gathered from the kernel-debuginfo packages.::
$ cas-admin -b
-If ``Func`` is installed and several systems are deployed for CAS to use run::
+If several systems are deployed for CAS to use run::
- $ cas-admin -s
+ $ cas-admin -s -f line_delimited_server_list.txt
At this point CAS is configured and looking at the output of CAS help there are
a few options to pass::
diff --git a/lib/cas/network.py b/lib/cas/network.py
index 50b4b30..4cf5c15 100644
--- a/lib/cas/network.py
+++ b/lib/cas/network.py
@@ -69,6 +69,7 @@ class Download(object):
class Executor(object):
""" using paramiko to perform common tasks over
ssh
+ return : tuple of results, err
"""
def __init__(self, remote_host, user, cmd):
self.user = user
@@ -84,6 +85,8 @@ class Executor(object):
return False
def run(self):
+ if not self.go():
+ return (None, 'Unable to authenticate to server' % (self.host,))
stdin, stdout, stderr = self.client.exec_command(self.cmd)
results = stdout.readlines()
err = stderr.readlines()
14 years, 7 months
cas-admin lib/cas
by Adam Stokes
cas-admin | 8 +++++---
lib/cas/network.py | 7 ++++++-
2 files changed, 11 insertions(+), 4 deletions(-)
New commits:
commit 35f8db21b3d67488b95a967aaa676d3c60683b67
Author: uzr <uzr(a)riddick.localdomain>
Date: Sat Oct 10 20:26:23 2009 -0400
- start of safeguard against invalid ssh connections
diff --git a/cas-admin b/cas-admin
index f7aead9..42274ec 100755
--- a/cas-admin
+++ b/cas-admin
@@ -115,9 +115,11 @@ class CasServerHandler(object):
fd = open(self.server_list, 'r')
for server in fd.readlines():
server = server.strip()
- results, err = Executor(server, settings["CASUSER"], "/bin/uname -m").run()
- if err:
- self.casLog.debug(err)
+ server_connect = Executor(server, settings["CASUSER"], "/bin/uname -m").run()
+ if not server_connect:
+ self.casLog.debug("Unable to authenticate %s" % (server,))
+ else:
+ results = server_connect[0]
# clean up arch string
for i in results:
arch = i.strip()
diff --git a/lib/cas/network.py b/lib/cas/network.py
index 842863c..50b4b30 100644
--- a/lib/cas/network.py
+++ b/lib/cas/network.py
@@ -76,7 +76,12 @@ class Executor(object):
self.cmd = cmd
self.client = paramiko.SSHClient()
self.client.load_system_host_keys()
- self.client.connect(self.host, username=self.user)
+
+ def go(self):
+ try:
+ self.client.connect(self.host, username=self.user)
+ except paramiko.AuthenticationException:
+ return False
def run(self):
stdin, stdout, stderr = self.client.exec_command(self.cmd)
14 years, 7 months
cas-admin
by Adam Stokes
cas-admin | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
New commits:
commit b4a8013f1e4f767bf69e6a6efcf9e7f77d05344a
Author: uzr <uzr(a)riddick.localdomain>
Date: Sat Oct 10 20:19:49 2009 -0400
- working on cas-admin to read server lists properly
diff --git a/cas-admin b/cas-admin
index 63d434d..f7aead9 100755
--- a/cas-admin
+++ b/cas-admin
@@ -96,8 +96,9 @@ class CasDatabaseHandler(object):
return
class CasServerHandler(object):
- def __init__(self, logger):
+ def __init__(self, server_list, logger):
self.casLog = logger
+ self.server_list = server_list
self.util = UtilBase()
# setup database connection
self.first_run = False
@@ -213,7 +214,10 @@ class CasAdminApplication(object):
dbHandler = CasDatabaseHandler(self.casLog).run()
elif self.server_init:
self.casLog.info("Building CAS Server DB instance.")
- serverHandler = CasServerHandler(self.casLog).run()
+ if self.server_list:
+ serverHandler = CasServerHandler(self.server_list, self.casLog).run()
+ else:
+ serverHandler = CasServerHandler(self.casLog).run()
else:
raise SystemExit(self.casLog.info("Missing options, please run with --help."))
14 years, 7 months