summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2011-01-22 13:40:20 -0600
committerSol Jerome <sol.jerome@gmail.com>2011-01-22 13:40:20 -0600
commit2a0f4b824a104c97f3464d68d853720bb8bb06c2 (patch)
tree4e71560b8add111ffccd601b19aacbb868c82d36
parente8be69a17541d1973ebb446cfe5af308e39ac68b (diff)
parent7e88c5454e7cce16874b69e402779af9412fd055 (diff)
downloadbcfg2-2a0f4b824a104c97f3464d68d853720bb8bb06c2.tar.gz
bcfg2-2a0f4b824a104c97f3464d68d853720bb8bb06c2.tar.bz2
bcfg2-2a0f4b824a104c97f3464d68d853720bb8bb06c2.zip
Merge branch 'master' of https://github.com/jdigilio/bcfg2
-rw-r--r--doc/appendix/guides/ubuntu.txt16
-rw-r--r--doc/server/plugins/generators/rules.txt56
-rw-r--r--schemas/servicetype.xsd1
-rw-r--r--src/lib/Client/Tools/Upstart.py41
4 files changed, 71 insertions, 43 deletions
diff --git a/doc/appendix/guides/ubuntu.txt b/doc/appendix/guides/ubuntu.txt
index 54aa62cce..8ffda7166 100644
--- a/doc/appendix/guides/ubuntu.txt
+++ b/doc/appendix/guides/ubuntu.txt
@@ -477,3 +477,19 @@ Dynamic (web) reports
=====================
See installation instructions at :ref:`server-reports-install`
+
+Upstart
+=======
+
+Upstart services are defined like this:
+
+.. code-block:: xml
+
+ <Service name="cron" status="on" type="upstart"/>
+
+Some Upstart services require additional parameters, like network-interface and bridge-network-interface:
+
+.. code-block:: xml
+
+ <Service name="network-interface" status="on" type="upstart" parameters="INTERFACE=eth0"/>
+ <Service name="bridge-network-interface" status="on" type="upstart" parameters="INTERFACE=br0"/> \ No newline at end of file
diff --git a/doc/server/plugins/generators/rules.txt b/doc/server/plugins/generators/rules.txt
index 511cfbb47..fe60a24fd 100644
--- a/doc/server/plugins/generators/rules.txt
+++ b/doc/server/plugins/generators/rules.txt
@@ -116,32 +116,36 @@ See :ref:`client-tools-actions`
Service Tag
-----------
-+----------+--------------------------+---------------------------------------+
-| Name | Description | Values |
-+==========+==========================+=======================================+
-| mode | Per Service Mode (New in | (manual|default|supervised|custom) |
-| | 1.0) | |
-+----------+--------------------------+---------------------------------------+
-| name | Service Name | String |
-+----------+--------------------------+---------------------------------------+
-| status | Should the service be | (on|off) |
-| | on or off (default: | |
-| | off). | |
-+----------+--------------------------+---------------------------------------+
-| target | Service command for | String |
-| | restart, modified | |
-| | targets require | |
-| | mode="custom" | |
-| | (default: restart) | |
-+----------+--------------------------+---------------------------------------+
-| type | Driver to use on the | (chkconfig|deb|rc-update|smf|upstart) |
-| | client to manage this | |
-| | service. | |
-+----------+--------------------------+---------------------------------------+
-| sequence | Order for service | integer |
-| | startup (debian services | |
-| | only) | |
-+----------+--------------------------+---------------------------------------+
++------------+--------------------------+---------------------------------------+
+| Name | Description | Values |
++============+==========================+=======================================+
+| mode | Per Service Mode (New in | (manual|default|supervised|custom) |
+| | 1.0) | |
++------------+--------------------------+---------------------------------------+
+| name | Service Name | String |
++------------+--------------------------+---------------------------------------+
+| status | Should the service be | (on|off) |
+| | on or off (default: | |
+| | off). | |
++------------+--------------------------+---------------------------------------+
+| target | Service command for | String |
+| | restart, modified | |
+| | targets require | |
+| | mode="custom" | |
+| | (default: restart) | |
++------------+--------------------------+---------------------------------------+
+| type | Driver to use on the | (chkconfig|deb|rc-update|smf|upstart) |
+| | client to manage this | |
+| | service. | |
++------------+--------------------------+---------------------------------------+
+| sequence | Order for service | integer |
+| | startup (debian services | |
+| | only) | |
++------------+--------------------------+---------------------------------------+
+| parameters | Pass parameters to | String |
+| | service (Upstart | |
+| | services only) | |
++------------+--------------------------+---------------------------------------+
Service mode descriptions
^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/schemas/servicetype.xsd b/schemas/servicetype.xsd
index 8bc692ed2..a9cb40667 100644
--- a/schemas/servicetype.xsd
+++ b/schemas/servicetype.xsd
@@ -28,6 +28,7 @@
<xsd:attribute name='supervised' type='xsd:string'/>
<xsd:attribute name='sequence' type='xsd:string'/>
<xsd:attribute name='target' type='xsd:string'/>
+ <xsd:attribute name='parameters' type='xsd:string'/>
</xsd:complexType>
</xsd:schema>
diff --git a/src/lib/Client/Tools/Upstart.py b/src/lib/Client/Tools/Upstart.py
index 113f28d23..b75b0927e 100644
--- a/src/lib/Client/Tools/Upstart.py
+++ b/src/lib/Client/Tools/Upstart.py
@@ -29,31 +29,38 @@ class Upstart(Bcfg2.Client.Tools.SvcTool):
/etc/init/servicename.conf. All we need to do is make sure
the service is running when it should be.
"""
+ if entry.get('parameters'):
+ params = entry.get('parameters')
+ else:
+ params = ''
+
try:
- output = self.cmd.run('/usr/sbin/service %s status' % \
- entry.get('name'))[1][0]
+ output = self.cmd.run('/usr/sbin/service %s status %s' % \
+ ( entry.get('name'), params ))[1][0]
except IndexError:
self.logger.error("Service %s not an Upstart service" % \
entry.get('name'))
return False
- try:
- running = output.split(' ')[1].split('/')[1].startswith('running')
- if running:
- entry.set('current_status', 'on')
- if entry.get('status') == 'off':
- status = False
- else:
- status = True
- else:
- entry.set('current_status', 'off')
- if entry.get('status') == 'on':
- status = False
- else:
- status = True
- except IndexError:
+
+ match = re.compile("%s( \(.*\))? (start|stop)/(running|waiting)" %entry.get('name') ).match( output )
+ if match == None:
# service does not exist
entry.set('current_status', 'off')
status = False
+ elif match.group(3) == 'running':
+ # service is running
+ entry.set('current_status', 'on')
+ if entry.get('status') == 'off':
+ status = False
+ else:
+ status = True
+ else:
+ # service is not running
+ entry.set('current_status', 'off')
+ if entry.get('status') == 'on':
+ status = False
+ else:
+ status = True
return status