Implement configurable replcfg (client-side)
Implements administrator-selectable replication configurations for new pools in PVC clusters, overriding the default of copies=3,mincopies=2.
This commit is contained in:
parent
0bacae21d7
commit
3b7c1adf71
|
@ -870,12 +870,12 @@ def ceph_pool_list(limit=None):
|
|||
pvc_common.stopZKConnection(zk_conn)
|
||||
return flask.jsonify(retdata), retcode
|
||||
|
||||
def ceph_pool_add(name, pgs):
|
||||
def ceph_pool_add(name, pgs, replcfg):
|
||||
"""
|
||||
Add a Ceph RBD pool to the PVC Ceph storage cluster.
|
||||
"""
|
||||
zk_conn = pvc_common.startZKConnection(config['coordinators'])
|
||||
retflag, retdata = pvc_ceph.add_pool(zk_conn, name, pgs)
|
||||
retflag, retdata = pvc_ceph.add_pool(zk_conn, name, pgs, replcfg)
|
||||
if retflag:
|
||||
retcode = 200
|
||||
else:
|
||||
|
|
|
@ -755,6 +755,13 @@ def api_ceph_pool_root():
|
|||
# We default to a very small number; DOCUMENT THIS
|
||||
pgs = 128
|
||||
|
||||
# Get replication configuration
|
||||
if 'replcfg' in flask.request.values:
|
||||
replcfg = flask.request.values['replcfg']
|
||||
else:
|
||||
# We default to copies=3,mincopies=2
|
||||
replcfg = 'copies=3,mincopies=2'
|
||||
|
||||
return pvcapi.ceph_pool_add(pool, pgs)
|
||||
|
||||
@api.route('/api/v1/storage/ceph/pool/<pool>', methods=['GET', 'DELETE'])
|
||||
|
|
|
@ -1380,13 +1380,22 @@ def ceph_pool():
|
|||
@click.argument(
|
||||
'pgs'
|
||||
)
|
||||
def ceph_pool_add(name, pgs):
|
||||
@click.option(
|
||||
'--replcfg', 'replcfg',
|
||||
default='copies=3,mincopies=2', show_default=True, required=False,
|
||||
help="""
|
||||
The replication configuration, specifying both a "copies" and "mincopies" value, separated by a
|
||||
comma, e.g. "copies=3,mincopies=2". The "copies" value specifies the total number of replicas and should not exceed the total number of nodes; the "mincopies" value specifies the minimum number of available copies to allow writes. For additional details please see the Cluster Architecture documentation.
|
||||
"""
|
||||
)
|
||||
def ceph_pool_add(name, pgs, replcfg):
|
||||
"""
|
||||
Add a new Ceph RBD pool with name NAME and PGS placement groups.
|
||||
|
||||
"""
|
||||
|
||||
zk_conn = pvc_common.startZKConnection(zk_host)
|
||||
retcode, retmsg = pvc_ceph.add_pool(zk_conn, name, pgs)
|
||||
retcode, retmsg = pvc_ceph.add_pool(zk_conn, name, pgs, replcfg)
|
||||
cleanup(retcode, retmsg, zk_conn)
|
||||
|
||||
###############################################################################
|
||||
|
|
|
@ -658,9 +658,9 @@ def getPoolInformation(zk_conn, pool):
|
|||
}
|
||||
return pool_information
|
||||
|
||||
def add_pool(zk_conn, name, pgs):
|
||||
def add_pool(zk_conn, name, pgs, replcfg):
|
||||
# Tell the cluster to create a new pool
|
||||
add_pool_string = 'pool_add {},{}'.format(name, pgs)
|
||||
add_pool_string = 'pool_add {},{},{}'.format(name, pgs, replcfg)
|
||||
zkhandler.writedata(zk_conn, {'/cmd/ceph': add_pool_string})
|
||||
# Wait 1/2 second for the cluster to get the message and start working
|
||||
time.sleep(0.5)
|
||||
|
@ -670,7 +670,7 @@ def add_pool(zk_conn, name, pgs):
|
|||
try:
|
||||
result = zkhandler.readdata(zk_conn, '/cmd/ceph').split()[0]
|
||||
if result == 'success-pool_add':
|
||||
message = 'Created new RBD pool "{}" with "{}" PGs.'.format(name, pgs)
|
||||
message = 'Created new RBD pool "{}" with "{}" PGs and replication configuration {}.'.format(name, pgs, replcfg)
|
||||
success = True
|
||||
else:
|
||||
message = 'ERROR: Failed to create new pool; check node logs for details.'
|
||||
|
|
Loading…
Reference in New Issue