summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2008-04-17 16:42:50 -0400
committerMichael DeHaan <mdehaan@redhat.com>2008-04-17 16:42:50 -0400
commit71d051435420f49f915aab8895d3ca4396c8ccc8 (patch)
treeea15b4c5ca9c79124ec0eaa140d0ff9469e3443e
parent143f4e068dc1a7e2f5b7196bcfc9a7317bf11fcc (diff)
downloadthird_party-cobbler-71d051435420f49f915aab8895d3ca4396c8ccc8.tar.gz
third_party-cobbler-71d051435420f49f915aab8895d3ca4396c8ccc8.tar.xz
third_party-cobbler-71d051435420f49f915aab8895d3ca4396c8ccc8.zip
(A) The Python-yaml open source code that we had been using apparently didn't have copyright headers (not sure why, we absolutely positively want them there) so I'm adding them now. Similarly, I have included a copy of the license of the library in the docs directory.
(B) This checkin also includes some work on the status command.
-rw-r--r--cobbler/action_status.py85
-rw-r--r--cobbler/yaml/__init__.py6
-rw-r--r--cobbler/yaml/dump.py7
-rw-r--r--cobbler/yaml/implicit.py6
-rw-r--r--cobbler/yaml/inline.py6
-rw-r--r--cobbler/yaml/klass.py6
-rw-r--r--cobbler/yaml/load.py6
-rw-r--r--cobbler/yaml/ordered_dict.py7
-rw-r--r--cobbler/yaml/redump.py6
-rw-r--r--cobbler/yaml/stream.py6
-rw-r--r--cobbler/yaml/timestamp.py7
-rw-r--r--cobbler/yaml/ypath.py7
-rw-r--r--docs/pyyaml-license.htm78
-rw-r--r--scripts/install_trigger.cgi5
14 files changed, 198 insertions, 40 deletions
diff --git a/cobbler/action_status.py b/cobbler/action_status.py
index cd76a39..df5062e 100644
--- a/cobbler/action_status.py
+++ b/cobbler/action_status.py
@@ -21,9 +21,18 @@ import api as cobbler_api
#from utils import _
+# ARRAY INDEXES
+MOST_RECENT_START = 0
+MOST_RECENT_STOP = 1
+MOST_RECENT_TARGET = 2
+SEEN_START = 3
+SEEN_STOP = 4
+MAC = 5
+STATE = 6
class BootStatusReport:
+
def __init__(self,config,mode):
"""
Constructor
@@ -59,30 +68,17 @@ class BootStatusReport:
ip_data = self.ip_data
if not ip_data.has_key(ip):
- ip_data[ip] = {}
+ ip_data[ip] = [ -1, -1, "?", 0, 0, "?", "?" ]
elem = ip_data[ip]
ts = float(ts)
-
- if not elem.has_key("most_recent_start"):
- elem["most_recent_start"] = -1
- if not elem.has_key("most_recent_stop"):
- elem["most_recent_stop"] = -1
- if not elem.has_key("most_recent_target"):
- elem["most_recent_target"] = "?"
- if not elem.has_key("seen_start"):
- elem["seen_start"] = 0
- if not elem.has_key("seen_stop"):
- elem["seen_stop"] = 0
- if not elem.has_key("mac"):
- elem["mac"] = "?"
-
- mrstart = elem["most_recent_start"]
- mrstop = elem["most_recent_stop"]
- mrtarg = elem["most_recent_target"]
- snstart = elem["seen_start"]
- snstop = elem["seen_stop"]
- snmac = elem["mac"]
+
+ mrstart = elem[MOST_RECENT_START]
+ mrstop = elem[MOST_RECENT_STOP]
+ mrtarg = elem[MOST_RECENT_TARGET]
+ snstart = elem[SEEN_START]
+ snstop = elem[SEEN_STOP]
+ snmac = elem[MAC]
if start_or_stop == "start":
@@ -90,30 +86,47 @@ class BootStatusReport:
mrstart = ts
mrtarg = "%s:%s" % (profile_or_system, name)
snmac = mac
- elem["seen_start"] = elem["seen_start"] + 1
+ elem[SEEN_START] = elem[SEEN_START] + 1
if start_or_stop == "stop":
if mrstop < ts:
mrstop = ts
mrtarg = "%s:%s" % (profile_or_system, name)
snmac = mac
- elem["seen_stop"] = elem["seen_stop"] + 1
+ elem[SEEN_STOP] = elem[SEEN_STOP] + 1
- elem["most_recent_start"] = mrstart
- elem["most_recent_stop"] = mrstop
- elem["most_recent_target"] = mrtarg
- elem["mac"] = mac
+ elem[MOST_RECENT_START] = mrstart
+ elem[MOST_RECENT_STOP] = mrstop
+ elem[MOST_RECENT_TARGET] = mrtarg
+ elem[MAC] = mac
# -------------------------------------------------------
def process_results(self):
# FIXME: this should update the times here
- print "DEBUG: %s" % self.ip_data
+
+ tnow = int(time.time())
+ for ip in self.ip_data.keys():
+ elem = self.ip_data[ip]
+
+ start = int(elem[MOST_RECENT_START])
+ stop = int(elem[MOST_RECENT_STOP])
+ if (stop > start):
+ elem[STATE] = "finished"
+ else:
+ delta = tnow - start
+ min = delta / 60
+ sec = delta % 60
+ if min > 100:
+ elem[STATE] = "unknown/stalled"
+ else:
+ elem[STATE] = "installing (%sm %ss)" % (min,sec)
+
return self.ip_data
def get_printable_results(self):
# ip | last mac | last target | start | stop | count
- format = "%-15s %-17s %-20s %-17s %-17s %5s"
+ format = "%-15s|%-17s|%-20s|%-17s|%-17s"
ip_data = self.ip_data
ips = ip_data.keys()
ips.sort()
@@ -122,22 +135,18 @@ class BootStatusReport:
"mac",
"target",
"start",
- "stop",
- "count",
+ "state",
)
- print "DEBUG:", line
buf = format % line
for ip in ips:
elem = ip_data[ip]
line = (
ip,
- elem["mac"],
- elem["most_recent_target"],
- elem["most_recent_start"], # clean up
- elem["most_recent_stop"], # clean up
- elem["seen_stop"]
+ elem[MAC],
+ elem[MOST_RECENT_TARGET],
+ time.ctime(elem[MOST_RECENT_START]),
+ elem[STATE]
)
- print "DEBUG: ", line
buf = buf + "\n" + format % line
return buf
diff --git a/cobbler/yaml/__init__.py b/cobbler/yaml/__init__.py
index 419d1f3..bd21b40 100644
--- a/cobbler/yaml/__init__.py
+++ b/cobbler/yaml/__init__.py
@@ -1,3 +1,9 @@
+"""
+pyyaml legacy
+Copyright (c) 2001 Steve Howell and Friends; All Rights Reserved
+(see open source license information in docs/ directory)
+"""
+
__version__ = "0.32"
from load import loadFile, load, Parser, l
from dump import dump, dumpToFile, Dumper, d
diff --git a/cobbler/yaml/dump.py b/cobbler/yaml/dump.py
index b8e9d79..eb34955 100644
--- a/cobbler/yaml/dump.py
+++ b/cobbler/yaml/dump.py
@@ -1,3 +1,10 @@
+"""
+pyyaml legacy
+Copyright (c) 2001 Steve Howell and Friends; All Rights Reserved
+(see open source license information in docs/ directory)
+"""
+
+
import types
import string
from types import StringType, UnicodeType, IntType, FloatType
diff --git a/cobbler/yaml/implicit.py b/cobbler/yaml/implicit.py
index 6172564..49d65e0 100644
--- a/cobbler/yaml/implicit.py
+++ b/cobbler/yaml/implicit.py
@@ -1,3 +1,9 @@
+"""
+pyyaml legacy
+Copyright (c) 2001 Steve Howell and Friends; All Rights Reserved
+(see open source license information in docs/ directory)
+"""
+
import re
import string
from timestamp import timestamp, matchTime
diff --git a/cobbler/yaml/inline.py b/cobbler/yaml/inline.py
index 8e647de..d4f6439 100644
--- a/cobbler/yaml/inline.py
+++ b/cobbler/yaml/inline.py
@@ -1,3 +1,9 @@
+"""
+pyyaml legacy
+Copyright (c) 2001 Steve Howell and Friends; All Rights Reserved
+(see open source license information in docs/ directory)
+"""
+
import re
import string
diff --git a/cobbler/yaml/klass.py b/cobbler/yaml/klass.py
index edcf5a8..c182fcf 100644
--- a/cobbler/yaml/klass.py
+++ b/cobbler/yaml/klass.py
@@ -1,3 +1,9 @@
+"""
+pyyaml legacy
+Copyright (c) 2001 Steve Howell and Friends; All Rights Reserved
+(see open source license information in docs/ directory)
+"""
+
import new
import re
diff --git a/cobbler/yaml/load.py b/cobbler/yaml/load.py
index 259178d..54931d6 100644
--- a/cobbler/yaml/load.py
+++ b/cobbler/yaml/load.py
@@ -1,3 +1,9 @@
+"""
+pyyaml legacy
+Copyright (c) 2001 Steve Howell and Friends; All Rights Reserved
+(see open source license information in docs/ directory)
+"""
+
import re, string
from implicit import convertImplicit
from inline import InlineTokenizer
diff --git a/cobbler/yaml/ordered_dict.py b/cobbler/yaml/ordered_dict.py
index b3788b7..5bc2e3e 100644
--- a/cobbler/yaml/ordered_dict.py
+++ b/cobbler/yaml/ordered_dict.py
@@ -1,3 +1,10 @@
+"""
+pyyaml legacy
+Copyright (c) 2001 Steve Howell and Friends; All Rights Reserved
+(see open source license information in docs/ directory)
+"""
+
+
# This is extremely crude implementation of an OrderedDict.
# If you know of a better implementation, please send it to
# the author Steve Howell. You can find my email via
diff --git a/cobbler/yaml/redump.py b/cobbler/yaml/redump.py
index 56ea958..eefd68e 100644
--- a/cobbler/yaml/redump.py
+++ b/cobbler/yaml/redump.py
@@ -1,3 +1,9 @@
+"""
+pyyaml legacy
+Copyright (c) 2001 Steve Howell and Friends; All Rights Reserved
+(see open source license information in docs/ directory)
+"""
+
from ordered_dict import OrderedDict
from load import Parser
from dump import Dumper
diff --git a/cobbler/yaml/stream.py b/cobbler/yaml/stream.py
index cc78c4b..dcd65c3 100644
--- a/cobbler/yaml/stream.py
+++ b/cobbler/yaml/stream.py
@@ -1,3 +1,9 @@
+"""
+pyyaml legacy
+Copyright (c) 2001 Steve Howell and Friends; All Rights Reserved
+(see open source license information in docs/ directory)
+"""
+
import re
import string
diff --git a/cobbler/yaml/timestamp.py b/cobbler/yaml/timestamp.py
index abcb2e6..5c522f6 100644
--- a/cobbler/yaml/timestamp.py
+++ b/cobbler/yaml/timestamp.py
@@ -1,3 +1,10 @@
+"""
+pyyaml legacy
+Copyright (c) 2001 Steve Howell and Friends; All Rights Reserved
+(see open source license information in docs/ directory)
+"""
+
+
import time, re, string
from types import ListType, TupleType
diff --git a/cobbler/yaml/ypath.py b/cobbler/yaml/ypath.py
index 51d9d2f..b183a23 100644
--- a/cobbler/yaml/ypath.py
+++ b/cobbler/yaml/ypath.py
@@ -1,3 +1,10 @@
+"""
+pyyaml legacy
+Copyright (c) 2001 Steve Howell and Friends; All Rights Reserved
+(see open source license information in docs/ directory)
+"""
+
+
from types import ListType, StringType, IntType, DictType, InstanceType
import re
from urllib import quote
diff --git a/docs/pyyaml-license.htm b/docs/pyyaml-license.htm
new file mode 100644
index 0000000..6993ea9
--- /dev/null
+++ b/docs/pyyaml-license.htm
@@ -0,0 +1,78 @@
+NOTE: the directory ".../yaml" contains the a derivative
+of the PyYaml library. It follows the license below
+and has been modified to disable the YAML "anchor"
+behavior.
+
+========================================================
+
+A. HISTORY OF THE SOFTWARE
+==========================
+
+The Python library for YAML was started by Steve Howell in
+February 2002. Steve is the primary author of the project,
+but others have contributed. See the README for more on
+the project. The term "PyYaml" refers to the entire
+distribution of this library, including examples, documentation,
+and test files, as well as the core implementation.
+
+This library is intended for general use, and the license
+below protects the "open source" nature of the library. The
+license does, however, allow for use of the library in
+commercial applications as well, subject to the terms
+and conditions listed. The license below is a minor
+rewrite of the Python 2.2 license, with no substantive
+differences.
+
+
+B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PyYaml
+===============================================================
+
+LICENSE AGREEMENT FOR PyYaml
+----------------------------
+
+1. This LICENSE AGREEMENT is between Stephen S. Howell ("Author"),
+and the Individual or Organization ("Licensee") accessing and
+otherwise using PyYaml software in source or binary form and its
+associated documentation.
+
+2. Subject to the terms and conditions of this License Agreement, Author
+hereby grants Licensee a nonexclusive, royalty-free, world-wide
+license to reproduce, analyze, test, perform and/or display publicly,
+prepare derivative works, distribute, and otherwise use PyYaml
+alone or in any derivative version, provided, however, that Author's
+License Agreement and Author's notice of copyright, i.e., "Copyright (c)
+2001 Steve Howell and Friends; All Rights Reserved" are never removed
+from PyYaml, and are included in any derivative version prepared by Licensee.
+
+3. In the event Licensee prepares a derivative work that is based on
+or incorporates PyYaml or any part thereof, and wants to make
+the derivative work available to others as provided herein, then
+Licensee hereby agrees to include in any such work a brief summary of
+the changes made to PyYaml.
+
+4. Author is making PyYaml available to Licensee on an "AS IS"
+basis. Author MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
+IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, Author MAKES NO AND
+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PyYaml WILL NOT
+INFRINGE ANY THIRD PARTY RIGHTS.
+
+5. Author SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
+2.2 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 2.2,
+OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
+
+6. This License Agreement will automatically terminate upon a material
+breach of its terms and conditions.
+
+7. Nothing in this License Agreement shall be deemed to create any
+relationship of agency, partnership, or joint venture between Author and
+Licensee. This License Agreement does not grant permission to use Author
+trademarks or trade name in a trademark sense to endorse or promote
+products or services of Licensee, or any third party.
+
+8. By copying, installing or otherwise using PyYaml, Licensee
+agrees to be bound by the terms and conditions of this License
+Agreement.
+
+
diff --git a/scripts/install_trigger.cgi b/scripts/install_trigger.cgi
index 493591f..c8d065b 100644
--- a/scripts/install_trigger.cgi
+++ b/scripts/install_trigger.cgi
@@ -42,8 +42,9 @@ def parse_query():
form = cgi.parse()
mac = "?"
- if os.environ.has_key("HTTP_X_RHN_PROVISIONING_MAC_0"):
- devicepair = os.environ["HTTP_X_RHN_PROVISIONING_MAC_0"]
+
+ if os.environ.has_key("X-RHN-Provisioning-MAC-0"):
+ devicepair = os.environ["X-RHN-Provisioning-MAC-0"]
mac = devicepair.split()[1].strip()
ip = "?"