]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph-volume util.prepare separate filestore vs. bluestore prepare utils
authorAlfredo Deza <adeza@redhat.com>
Mon, 16 Oct 2017 10:51:05 +0000 (06:51 -0400)
committerAlfredo Deza <adeza@redhat.com>
Wed, 18 Oct 2017 16:46:29 +0000 (12:46 -0400)
Signed-off-by: Alfredo Deza <adeza@redhat.com>
src/ceph-volume/ceph_volume/util/prepare.py

index 58d43d9b22a3bcd0ed48c94bba366ef72b09ad62..ebec603b030c32c20599a34e6586525d86e13ca0 100644 (file)
@@ -57,8 +57,21 @@ def create_id(fsid, json_secrets):
     return ' '.join(stdout).strip()
 
 
-def create_path(osd_id):
+def mount_tmpfs(path):
+    process.run([
+        'sudo',
+        'mount',
+        '-t',
+        'tmpfs', 'tmpfs',
+        path
+    ])
+
+
+def create_osd_path(osd_id, tmpfs=False):
+    path = '/var/lib/ceph/osd/%s-%s' % (conf.cluster, osd_id)
     system.mkdir_p('/var/lib/ceph/osd/%s-%s' % (conf.cluster, osd_id))
+    if tmpfs:
+        mount_tmpfs(path)
 
 
 def format_device(device):
@@ -110,6 +123,8 @@ def _link_device(device, device_type, osd_id):
         device_type
     )
     command = ['sudo', 'ln', '-s', device, device_path]
+    system.chown(device)
+
     process.run(command)
 
 
@@ -122,11 +137,11 @@ def link_block(block_device, osd_id):
 
 
 def link_wal(wal_device, osd_id):
-    _link_device(wal_device, 'wal', osd_id)
+    _link_device(wal_device, 'block.wal', osd_id)
 
 
 def link_db(db_device, osd_id):
-    _link_device(db_device, 'db', osd_id)
+    _link_device(db_device, 'block.db', osd_id)
 
 
 def get_monmap(osd_id):
@@ -152,7 +167,64 @@ def get_monmap(osd_id):
     ])
 
 
-def osd_mkfs(osd_id, fsid):
+def osd_mkfs_bluestore(osd_id, fsid, keyring=None, wal=False, db=False):
+    """
+    Create the files for the OSD to function. A normal call will look like:
+
+          ceph-osd --cluster ceph --mkfs --mkkey -i 0 \
+                   --monmap /var/lib/ceph/osd/ceph-0/activate.monmap \
+                   --osd-data /var/lib/ceph/osd/ceph-0 \
+                   --osd-uuid 8d208665-89ae-4733-8888-5d3bfbeeec6c \
+                   --keyring /var/lib/ceph/osd/ceph-0/keyring \
+                   --setuser ceph --setgroup ceph
+
+    In some cases it is required to use the keyring, when it is passed in as
+    a keywork argument it is used as part of the ceph-osd command
+    """
+    path = '/var/lib/ceph/osd/%s-%s/' % (conf.cluster, osd_id)
+    monmap = os.path.join(path, 'activate.monmap')
+    wal_path = os.path.join(path, 'block.wal')
+    db_path = os.path.join(path, 'block.db')
+
+    system.chown(path)
+
+    base_command = [
+        'sudo',
+        'ceph-osd',
+        '--cluster', conf.cluster,
+        # undocumented flag, sets the `type` file to contain 'bluestore'
+        '--osd-objectstore', 'bluestore',
+        '--mkfs',
+        '-i', osd_id,
+        '--monmap', monmap,
+    ]
+
+    supplementary_command = [
+        '--osd-data', path,
+        '--osd-uuid', fsid,
+        '--setuser', 'ceph',
+        '--setgroup', 'ceph'
+    ]
+
+    if keyring is not None:
+        base_command.extend(['--key', keyring])
+
+    if wal:
+        base_command.extend(
+            ['--bluestore-block-wal-path', wal_path]
+        )
+
+    if db:
+        base_command.extend(
+            ['--bluestore-block-db-path', db_path]
+        )
+
+    command = base_command + supplementary_command
+
+    process.run(command, obfuscate='--key')
+
+
+def osd_mkfs_filestore(osd_id, fsid):
     """
     Create the files for the OSD to function. A normal call will look like:
 
@@ -176,6 +248,8 @@ def osd_mkfs(osd_id, fsid):
         'sudo',
         'ceph-osd',
         '--cluster', conf.cluster,
+        # undocumented flag, sets the `type` file to contain 'filestore'
+        '--osd-objectstore', 'filestore',
         '--mkfs',
         '-i', osd_id,
         '--monmap', monmap,