]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
[RM-17567] Start mon by systemd/sysvint/upstart after adding mon 422/head
authoradshao <guojian@xsky.com>
Thu, 13 Oct 2016 16:44:13 +0000 (00:44 +0800)
committerguojian <guojian@xsky.com>
Fri, 14 Oct 2016 15:56:31 +0000 (23:56 +0800)
Signed-off-by: guojian <guojian@xsky.com>
ceph_deploy/hosts/centos/mon/__init__.py
ceph_deploy/hosts/centos/mon/create.py [deleted file]
ceph_deploy/hosts/common.py
ceph_deploy/hosts/debian/mon/__init__.py
ceph_deploy/hosts/debian/mon/create.py [deleted file]
ceph_deploy/hosts/fedora/mon/__init__.py
ceph_deploy/hosts/fedora/mon/create.py [deleted file]
ceph_deploy/hosts/rhel/mon/__init__.py
ceph_deploy/hosts/rhel/mon/create.py [deleted file]
ceph_deploy/hosts/suse/mon/__init__.py
ceph_deploy/hosts/suse/mon/create.py [deleted file]

index ea0fbf0dc4d1bcbcba804b5d3d24fa89e65175a4..f266fb0a51204941e8a427fe4e124aeb17f02f45 100644 (file)
@@ -1,2 +1,2 @@
 from ceph_deploy.hosts.common import mon_add as add  # noqa
-from .create import create  # noqa
+from ceph_deploy.hosts.common import mon_create as create  # noqa
diff --git a/ceph_deploy/hosts/centos/mon/create.py b/ceph_deploy/hosts/centos/mon/create.py
deleted file mode 100644 (file)
index 7579aa7..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-from ceph_deploy.hosts import common
-from ceph_deploy.util import system
-from ceph_deploy.lib import remoto
-
-
-def create(distro, args, monitor_keyring):
-    hostname = distro.conn.remote_module.shortname()
-    common.mon_create(distro, args, monitor_keyring, hostname)
-
-    if distro.init == 'sysvinit':
-        service = distro.conn.remote_module.which_service()
-        remoto.process.run(
-            distro.conn,
-            [
-                service,
-                'ceph',
-                '-c',
-                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
-                'start',
-                'mon.{hostname}'.format(hostname=hostname)
-            ],
-            timeout=7,
-        )
-
-        system.enable_service(distro.conn)
-    elif distro.init == 'systemd':
-       # enable ceph target for this host (in case it isn't already enabled)
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'enable',
-                'ceph.target'
-            ],
-            timeout=7,
-        )
-
-        # enable and start this mon instance
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'enable',
-                'ceph-mon@{hostname}'.format(hostname=hostname),
-            ],
-            timeout=7,
-        )
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'start',
-                'ceph-mon@{hostname}'.format(hostname=hostname),
-            ],
-            timeout=7,
-        )
index a7ab434d03862b3246eb5835c3a3515e2478234e..70345dc978f024a7ab28224bb74caf1173b98b88 100644 (file)
@@ -2,6 +2,7 @@ from ceph_deploy.util import paths
 from ceph_deploy import conf
 from ceph_deploy.lib import remoto
 from ceph_deploy.util import constants
+from ceph_deploy.util import system
 
 
 def ceph_version(conn):
@@ -11,7 +12,8 @@ def ceph_version(conn):
     return remoto.process.run(conn, ['ceph', '--version'])
 
 
-def mon_create(distro, args, monitor_keyring, hostname):
+def mon_create(distro, args, monitor_keyring):
+    hostname = distro.conn.remote_module.shortname()
     logger = distro.conn.logger
     logger.debug('remote hostname: %s' % hostname)
     path = paths.mon.path(args.cluster, hostname)
@@ -73,6 +75,9 @@ def mon_create(distro, args, monitor_keyring, hostname):
     # create init path
     distro.conn.remote_module.create_init_path(init_path, uid, gid)
 
+    # start mon service
+    start_mon_service(distro, args.cluster, hostname)
+
 
 def mon_add(distro, args, monitor_keyring):
     hostname = distro.conn.remote_module.shortname()
@@ -153,20 +158,8 @@ def mon_add(distro, args, monitor_keyring):
     # create init path
     distro.conn.remote_module.create_init_path(init_path, uid, gid)
 
-    # start the mon using the address
-    pid_location = "/var/run/ceph/mon.%s.pid" % hostname
-    remoto.process.run(
-        distro.conn,
-        [
-            'ceph-mon',
-            '--cluster', args.cluster,
-            '-i',
-            hostname,
-            '--pid-file', pid_location,
-            '--public-addr',
-            args.address,
-        ],
-    )
+    # start mon service
+    start_mon_service(distro, args.cluster, hostname)
 
 
 def map_components(notsplit_packages, components):
@@ -187,3 +180,69 @@ def map_components(notsplit_packages, components):
             packages.add(c)
 
     return list(packages)
+
+
+def start_mon_service(distro, cluster, hostname):
+    """
+    start mon service depending on distro init
+    """
+    if distro.init == 'sysvinit':
+        service = distro.conn.remote_module.which_service()
+        remoto.process.run(
+            distro.conn,
+            [
+                service,
+                'ceph',
+                '-c',
+                '/etc/ceph/{cluster}.conf'.format(cluster=cluster),
+                'start',
+                'mon.{hostname}'.format(hostname=hostname)
+            ],
+            timeout=7,
+        )
+        system.enable_service(distro.conn)
+
+    elif distro.init == 'upstart':
+        remoto.process.run(
+             distro.conn,
+             [
+                 'initctl',
+                 'emit',
+                 'ceph-mon',
+                 'cluster={cluster}'.format(cluster=cluster),
+                 'id={hostname}'.format(hostname=hostname),
+             ],
+             timeout=7,
+         )
+
+    elif distro.init == 'systemd':
+       # enable ceph target for this host (in case it isn't already enabled)
+        remoto.process.run(
+            distro.conn,
+            [
+                'systemctl',
+                'enable',
+                'ceph.target'
+            ],
+            timeout=7,
+        )
+
+        # enable and start this mon instance
+        remoto.process.run(
+            distro.conn,
+            [
+                'systemctl',
+                'enable',
+                'ceph-mon@{hostname}'.format(hostname=hostname),
+            ],
+            timeout=7,
+        )
+        remoto.process.run(
+            distro.conn,
+            [
+                'systemctl',
+                'start',
+                'ceph-mon@{hostname}'.format(hostname=hostname),
+            ],
+            timeout=7,
+        )
index ea0fbf0dc4d1bcbcba804b5d3d24fa89e65175a4..f266fb0a51204941e8a427fe4e124aeb17f02f45 100644 (file)
@@ -1,2 +1,2 @@
 from ceph_deploy.hosts.common import mon_add as add  # noqa
-from .create import create  # noqa
+from ceph_deploy.hosts.common import mon_create as create  # noqa
diff --git a/ceph_deploy/hosts/debian/mon/create.py b/ceph_deploy/hosts/debian/mon/create.py
deleted file mode 100644 (file)
index 2a4d41d..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-from ceph_deploy.hosts import common
-from ceph_deploy.util import system
-from ceph_deploy.lib import remoto
-
-
-def create(distro, args, monitor_keyring):
-    hostname = distro.conn.remote_module.shortname()
-    common.mon_create(distro, args, monitor_keyring, hostname)
-
-    if distro.init == 'sysvinit':
-        service = distro.conn.remote_module.which_service()
-        remoto.process.run(
-            distro.conn,
-            [
-                service,
-                'ceph',
-                '-c',
-                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
-                'start',
-                'mon.{hostname}'.format(hostname=hostname)
-            ],
-            timeout=7,
-        )
-
-        system.enable_service(distro.conn)
-    elif distro.init == 'upstart':
-        remoto.process.run(
-             distro.conn,
-             [
-                 'initctl',
-                 'emit',
-                 'ceph-mon',
-                 'cluster={cluster}'.format(cluster=args.cluster),
-                 'id={hostname}'.format(hostname=hostname),
-             ],
-             timeout=7,
-         )
-
-    elif distro.init == 'systemd':
-       # enable ceph target for this host (in case it isn't already enabled)
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'enable',
-                'ceph.target'
-            ],
-            timeout=7,
-        )
-
-        # enable and start this mon instance
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'enable',
-                'ceph-mon@{hostname}'.format(hostname=hostname),
-            ],
-            timeout=7,
-        )
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'start',
-                'ceph-mon@{hostname}'.format(hostname=hostname),
-            ],
-            timeout=7,
-        )
index ea0fbf0dc4d1bcbcba804b5d3d24fa89e65175a4..f266fb0a51204941e8a427fe4e124aeb17f02f45 100644 (file)
@@ -1,2 +1,2 @@
 from ceph_deploy.hosts.common import mon_add as add  # noqa
-from .create import create  # noqa
+from ceph_deploy.hosts.common import mon_create as create  # noqa
diff --git a/ceph_deploy/hosts/fedora/mon/create.py b/ceph_deploy/hosts/fedora/mon/create.py
deleted file mode 100644 (file)
index 7579aa7..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-from ceph_deploy.hosts import common
-from ceph_deploy.util import system
-from ceph_deploy.lib import remoto
-
-
-def create(distro, args, monitor_keyring):
-    hostname = distro.conn.remote_module.shortname()
-    common.mon_create(distro, args, monitor_keyring, hostname)
-
-    if distro.init == 'sysvinit':
-        service = distro.conn.remote_module.which_service()
-        remoto.process.run(
-            distro.conn,
-            [
-                service,
-                'ceph',
-                '-c',
-                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
-                'start',
-                'mon.{hostname}'.format(hostname=hostname)
-            ],
-            timeout=7,
-        )
-
-        system.enable_service(distro.conn)
-    elif distro.init == 'systemd':
-       # enable ceph target for this host (in case it isn't already enabled)
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'enable',
-                'ceph.target'
-            ],
-            timeout=7,
-        )
-
-        # enable and start this mon instance
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'enable',
-                'ceph-mon@{hostname}'.format(hostname=hostname),
-            ],
-            timeout=7,
-        )
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'start',
-                'ceph-mon@{hostname}'.format(hostname=hostname),
-            ],
-            timeout=7,
-        )
index ea0fbf0dc4d1bcbcba804b5d3d24fa89e65175a4..f266fb0a51204941e8a427fe4e124aeb17f02f45 100644 (file)
@@ -1,2 +1,2 @@
 from ceph_deploy.hosts.common import mon_add as add  # noqa
-from .create import create  # noqa
+from ceph_deploy.hosts.common import mon_create as create  # noqa
diff --git a/ceph_deploy/hosts/rhel/mon/create.py b/ceph_deploy/hosts/rhel/mon/create.py
deleted file mode 100644 (file)
index 7579aa7..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-from ceph_deploy.hosts import common
-from ceph_deploy.util import system
-from ceph_deploy.lib import remoto
-
-
-def create(distro, args, monitor_keyring):
-    hostname = distro.conn.remote_module.shortname()
-    common.mon_create(distro, args, monitor_keyring, hostname)
-
-    if distro.init == 'sysvinit':
-        service = distro.conn.remote_module.which_service()
-        remoto.process.run(
-            distro.conn,
-            [
-                service,
-                'ceph',
-                '-c',
-                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
-                'start',
-                'mon.{hostname}'.format(hostname=hostname)
-            ],
-            timeout=7,
-        )
-
-        system.enable_service(distro.conn)
-    elif distro.init == 'systemd':
-       # enable ceph target for this host (in case it isn't already enabled)
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'enable',
-                'ceph.target'
-            ],
-            timeout=7,
-        )
-
-        # enable and start this mon instance
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'enable',
-                'ceph-mon@{hostname}'.format(hostname=hostname),
-            ],
-            timeout=7,
-        )
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'start',
-                'ceph-mon@{hostname}'.format(hostname=hostname),
-            ],
-            timeout=7,
-        )
index ea0fbf0dc4d1bcbcba804b5d3d24fa89e65175a4..f266fb0a51204941e8a427fe4e124aeb17f02f45 100644 (file)
@@ -1,2 +1,2 @@
 from ceph_deploy.hosts.common import mon_add as add  # noqa
-from .create import create  # noqa
+from ceph_deploy.hosts.common import mon_create as create  # noqa
diff --git a/ceph_deploy/hosts/suse/mon/create.py b/ceph_deploy/hosts/suse/mon/create.py
deleted file mode 100644 (file)
index 7579aa7..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-from ceph_deploy.hosts import common
-from ceph_deploy.util import system
-from ceph_deploy.lib import remoto
-
-
-def create(distro, args, monitor_keyring):
-    hostname = distro.conn.remote_module.shortname()
-    common.mon_create(distro, args, monitor_keyring, hostname)
-
-    if distro.init == 'sysvinit':
-        service = distro.conn.remote_module.which_service()
-        remoto.process.run(
-            distro.conn,
-            [
-                service,
-                'ceph',
-                '-c',
-                '/etc/ceph/{cluster}.conf'.format(cluster=args.cluster),
-                'start',
-                'mon.{hostname}'.format(hostname=hostname)
-            ],
-            timeout=7,
-        )
-
-        system.enable_service(distro.conn)
-    elif distro.init == 'systemd':
-       # enable ceph target for this host (in case it isn't already enabled)
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'enable',
-                'ceph.target'
-            ],
-            timeout=7,
-        )
-
-        # enable and start this mon instance
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'enable',
-                'ceph-mon@{hostname}'.format(hostname=hostname),
-            ],
-            timeout=7,
-        )
-        remoto.process.run(
-            distro.conn,
-            [
-                'systemctl',
-                'start',
-                'ceph-mon@{hostname}'.format(hostname=hostname),
-            ],
-            timeout=7,
-        )