Browse Source

Copy map-services script to tripleo elements

map-services will be removed on dib v2 branch, but
tripleo still relies heavily on it. To prevent breakage,
copy the script to the internal element using it.
In the future, all elements will need to be migrated
to new svc-map, but it is a massive change.

Change-Id: I9f450de66044123ab07fa498b68f744d1029089a
Yolanda Robla Mota 2 years ago
parent
commit
b9fb5326fd

+ 95
- 0
elements/os-svc-install/bin/map-services-tripleo View File

@@ -0,0 +1,95 @@
1
+#!/usr/bin/env python
2
+# dib-lint: disable=indent
3
+# Copyright 2012 Hewlett-Packard Development Company, L.P.
4
+# Copyright 2014 Red Hat, Inc.
5
+#
6
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+# not use this file except in compliance with the License. You may obtain
8
+# a copy of the License at
9
+#
10
+#     http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+# Unless required by applicable law or agreed to in writing, software
13
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+# License for the specific language governing permissions and limitations
16
+# under the License.
17
+
18
+from __future__ import print_function
19
+import os
20
+import sys
21
+
22
+# Manually maintained for brevity; consider making this compiled from
23
+# distromatch or other rich data sources.
24
+# TripleO service name on the left, Fedora/RHEL on the right.
25
+service_map = {
26
+    'apache2': 'httpd',
27
+    'ceilometer-api': 'openstack-ceilometer-api',
28
+    'ceilometer-agent-central': 'openstack-ceilometer-central',
29
+    'ceilometer-agent-compute': 'openstack-ceilometer-compute',
30
+    'ceilometer-agent-notification': 'openstack-ceilometer-notification',
31
+    'ceilometer-collector': 'openstack-ceilometer-collector',
32
+    'cinder-api': 'openstack-cinder-api',
33
+    'cinder-backup': 'openstack-cinder-backup',
34
+    'cinder-scheduler': 'openstack-cinder-scheduler',
35
+    'cinder-volume': 'openstack-cinder-volume',
36
+    'glance-api': 'openstack-glance-api',
37
+    'glance-reg': 'openstack-glance-registry',
38
+    'heat-api': 'openstack-heat-api',
39
+    'heat-api-cfn': 'openstack-heat-api-cfn',
40
+    'heat-api-cloudwatch': 'openstack-heat-api-cloudwatch',
41
+    'heat-engine': 'openstack-heat-engine',
42
+    'ironic-api': 'openstack-ironic-api',
43
+    'ironic-conductor': 'openstack-ironic-conductor',
44
+    'keystone': 'openstack-keystone',
45
+    'libvirt-bin': 'libvirtd',
46
+    'mysql': ['mysqld', 'mariadb'],
47
+    'nova-conductor': 'openstack-nova-conductor',
48
+    'nova-api': 'openstack-nova-api',
49
+    'nova-cert': 'openstack-nova-cert',
50
+    'nova-scheduler': 'openstack-nova-scheduler',
51
+    'nova-consoleauth': 'openstack-nova-consoleauth',
52
+    'nova-compute': 'openstack-nova-compute',
53
+    'nova-novncproxy': 'openstack-nova-novncproxy',
54
+    'openvswitch-switch': 'openvswitch',
55
+    'rsync': 'rsyncd',
56
+    'swift-proxy': 'openstack-swift-proxy',
57
+    'swift-account': 'openstack-swift-account',
58
+    'swift-account-auditor': 'openstack-swift-account-auditor',
59
+    'swift-account-reaper': 'openstack-swift-account-reaper',
60
+    'swift-account-replicator': 'openstack-swift-account-replicator',
61
+    'swift-container': 'openstack-swift-container',
62
+    'swift-container-auditor': 'openstack-swift-container-auditor',
63
+    'swift-container-replicator': 'openstack-swift-container-replicator',
64
+    'swift-container-updater': 'openstack-swift-container-updater',
65
+    'swift-object': 'openstack-swift-object',
66
+    'swift-object-auditor': 'openstack-swift-object-auditor',
67
+    'swift-object-replicator': 'openstack-swift-object-replicator',
68
+    'swift-object-updater': 'openstack-swift-object-updater',
69
+    'tgt': 'tgtd',
70
+}
71
+
72
+print("WARNING: map-services has been deprecated.  "
73
+      "Please use the svc-map element.", file=sys.stderr)
74
+
75
+for arg in sys.argv[1:]:
76
+    # We need to support the service name being different when installing from
77
+    # source vs. packages. So, if the requested service file already exists,
78
+    # just use that.
79
+    if os.path.exists('/lib/systemd/system/%s.service' % arg):
80
+        print(arg)
81
+    else:
82
+        mapping = service_map.get(arg, arg)
83
+        # Handle cases where a service may map to multiple names depending on
84
+        # which specific distribution we're using.
85
+        if isinstance(mapping, list):
86
+            for name in mapping:
87
+                if os.path.exists('/lib/systemd/system/%s.service' % name):
88
+                    print(name)
89
+                    break
90
+            else:
91
+                # We didn't find a match for any of the mappings.
92
+                print(arg)
93
+        else:
94
+            print(mapping)
95
+sys.exit(0)

+ 2
- 0
elements/os-svc-install/install.d/04-os-svc-install View File

@@ -5,6 +5,8 @@ install -m 0755 -o root -g root $(dirname $0)/../bin/os-svc-install /usr/local/b
5 5
 install -m 0755 -o root -g root $(dirname $0)/../bin/os-svc-daemon  /usr/local/bin/os-svc-daemon
6 6
 install -m 0755 -o root -g root $(dirname $0)/../bin/os-db-create   /usr/local/bin/os-db-create
7 7
 install -m 0755 -o root -g root $(dirname $0)/../bin/os-svc-enable  /usr/local/bin/os-svc-enable
8
+install -m 0755 -o root -g root $(dirname $0)/../bin/map-services-tripleo  /usr/local/bin/map-services
9
+
8 10
 if [ "$(dib-init-system)" = "upstart" ] ; then
9 11
     install -m 0755 -o root -g root $(dirname $0)/../bin/os-svc-enable-upstart /usr/local/bin/os-svc-enable-upstart
10 12
     install -m 0644 -o root -g root $(dirname $0)/../upstart/os-svc-enable.conf /etc/init/os-svc-enable.conf

Loading…
Cancel
Save