]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume simple.activate allow a --no-systemd flag to skip systemctl actions
authorAlfredo Deza <alfredo@deza.pe>
Thu, 8 Nov 2018 14:13:31 +0000 (09:13 -0500)
committerAlfredo Deza <adeza@redhat.com>
Fri, 9 Nov 2018 19:58:32 +0000 (14:58 -0500)
Signed-off-by: Alfredo Deza <alfredo@deza.pe>
(cherry picked from commit 4d9ad0d3d4bedd5efa95653fbb86607f0b469174)

src/ceph-volume/ceph_volume/devices/simple/activate.py

index a429018bfc0c50929427fff32c201926ede79d8e..b3e781f165353780221da095c0f55761c227e553 100644 (file)
@@ -19,9 +19,10 @@ class Activate(object):
 
     help = 'Enable systemd units to mount configured devices and start a Ceph OSD'
 
-    def __init__(self, argv, systemd=False):
+    def __init__(self, argv, from_trigger=False):
         self.argv = argv
-        self.systemd = systemd
+        self.from_trigger = from_trigger
+        self.skip_systemd = False
 
     def validate_devices(self, json_config):
         """
@@ -148,24 +149,33 @@ class Activate(object):
             # make sure that the journal has proper permissions
             system.chown(device)
 
-        if not self.systemd:
+        if not self.from_trigger and not self.skip_systemd:
+            # means it was scanned and now activated directly, so ensure that
+            # ceph-disk units are disabled, and that the `simple` systemd unit
+            # is created and enabled
+
             # enable the ceph-volume unit for this OSD
             systemctl.enable_volume(osd_id, osd_fsid, 'simple')
 
             # disable any/all ceph-disk units
             systemctl.mask_ceph_disk()
+            terminal.warning(
+                ('All ceph-disk systemd units have been disabled to '
+                 'prevent OSDs getting triggered by UDEV events')
+            )
 
-        # enable the OSD
-        systemctl.enable_osd(osd_id)
+        if not self.skip_systemd:
+            # enable the OSD
+            systemctl.enable_osd(osd_id)
 
-        # start the OSD
-        systemctl.start_osd(osd_id)
+            # start the OSD
+            systemctl.start_osd(osd_id)
+        else:
+            terminal.info(
+                'Skipping enabling and starting OSD simple systemd unit because --no-systemd was used'
+            )
 
         terminal.success('Successfully activated OSD %s with FSID %s' % (osd_id, osd_fsid))
-        terminal.warning(
-            ('All ceph-disk systemd units have been disabled to '
-             'prevent OSDs getting triggered by UDEV events')
-        )
 
     def main(self):
         sub_command_help = dedent("""
@@ -211,6 +221,12 @@ class Activate(object):
             '--file',
             help='The path to a JSON file, from a scanned OSD'
         )
+        parser.add_argument(
+            '--no-systemd',
+            dest='skip_systemd',
+            action='store_true',
+            help='Skip creating and enabling systemd units and starting OSD services',
+        )
         if len(self.argv) == 0:
             print(sub_command_help)
             return
@@ -232,4 +248,5 @@ class Activate(object):
         if not os.path.exists(json_config):
             raise RuntimeError('Expected JSON config path not found: %s' % json_config)
         args.json_config = json_config
+        self.skip_systemd = args.skip_systemd
         self.activate(args)