From 3be56c422627ccd1295929c325d2cb29731fbeaf Mon Sep 17 00:00:00 2001 From: Joe Digilio Date: Sat, 22 Jan 2011 10:35:06 -0800 Subject: Support ability to pass parameters to Upstart services --- schemas/servicetype.xsd | 1 + 1 file changed, 1 insertion(+) 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 @@ + -- cgit v1.2.3-1-g7c22 From c3fc934edbab4258467ee650d4775188cf41fd12 Mon Sep 17 00:00:00 2001 From: Joe Digilio Date: Sat, 22 Jan 2011 10:38:06 -0800 Subject: Support ability to pass parameters to Upstart services --- src/lib/Client/Tools/Upstart.py | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) 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 -- cgit v1.2.3-1-g7c22 From d0c45fb8abbb7f77b7d947587443240ccbf03d41 Mon Sep 17 00:00:00 2001 From: Joe Digilio Date: Sat, 22 Jan 2011 10:51:18 -0800 Subject: Support ability to pass parameters to Upstart services --- doc/server/plugins/generators/rules.txt | 56 ++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 26 deletions(-) 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 ^^^^^^^^^^^^^^^^^^^^^^^^^ -- cgit v1.2.3-1-g7c22 From 7e88c5454e7cce16874b69e402779af9412fd055 Mon Sep 17 00:00:00 2001 From: Joe Digilio Date: Sat, 22 Jan 2011 11:05:13 -0800 Subject: Support ability to pass parameters to Upstart services --- doc/appendix/guides/ubuntu.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 + + + +Some Upstart services require additional parameters, like network-interface and bridge-network-interface: + +.. code-block:: xml + + + \ No newline at end of file -- cgit v1.2.3-1-g7c22