def cluster_status(**kwargs): """ Get the cluster status CLI Example: salt '*' sesceph.cluster_status \\ 'cluster_name'='ceph' \\ 'cluster_uuid'='cluster_uuid' Notes: Get the cluster status including health if in quorum. Scope: Cluster wide Arguments: cluster_uuid Set the cluster UUID. Defaults to value found in ceph config file. cluster_name Set the cluster name. Defaults to "ceph". """ m = model.model(**kwargs) u = mdl_updater.model_updater(m) u.hostname_refresh() u.defaults_refresh() u.load_confg(m.cluster_name) u.mon_members_refresh() mur = mdl_updater_remote.model_updater_remote(m) can_connect = mur.connect() if not can_connect: raise Error("Cant connect to cluster.") p = presenter.mdl_presentor(m) return p.cluster_status()
def pool_del(pool_name, **kwargs): """ List all cephx authorization keys CLI Example: salt '*' sesceph.pool_del pool_name \\ 'cluster_name'='ceph' \\ 'cluster_uuid'='cluster_uuid' Notes: cluster_name Set the cluster name. Defaults to "ceph". cluster_uuid Set the cluster UUID. Defaults to value found in ceph config file. """ m = model.model(**kwargs) u = mdl_updater.model_updater(m) u.hostname_refresh() u.defaults_refresh() u.load_confg(m.cluster_name) u.mon_members_refresh() mur = mdl_updater_remote.model_updater_remote(m) can_connect = mur.connect() if not can_connect: raise Error("Cant connect to cluster.") mur.pool_list() return mur.pool_del(pool_name)
def cluster_quorum(**kwargs): """ Get the cluster status CLI Example: salt '*' sesceph.cluster_status \\ 'cluster_name'='ceph' \\ 'cluster_uuid'='cluster_uuid' Notes: Get the cluster quorum status. Scope: Cluster wide Arguments: cluster_uuid Set the cluster UUID. Defaults to value found in ceph config file. cluster_name Set the cluster name. Defaults to "ceph". """ m = model.model(**kwargs) u = mdl_updater.model_updater(m) u.hostname_refresh() u.defaults_refresh() u.load_confg(m.cluster_name) u.mon_members_refresh() mur = mdl_updater_remote.model_updater_remote(m) can_connect = mur.connect() if not can_connect: return False q = mdl_query.mdl_query(m) return q.cluster_quorum()
def rgw_pools_create(self): rc = True mur = mdl_updater_remote.model_updater_remote(self.model) can_connect = mur.connect() if not can_connect: raise Error("Cant connect to cluster.") for name in self.rgw_pools_missing(): log.info("Adding missing pool:%s" % (name)) try: tmp_rc = mur.pool_add(name, pg_num=16) except mdl_updater_remote.Error, e: log.error(e) log.error("Failed to add pool '%s'" % (name)) rc = False
def pool_add(pool_name, **kwargs): """ List all cephx authorization keys CLI Example: salt '*' sesceph.pool_add pool_name \\ 'cluster_name'='ceph' \\ 'cluster_uuid'='cluster_uuid' Notes: cluster_name Set the cluster name. Defaults to "ceph". cluster_uuid Set the cluster UUID. Defaults to value found in ceph config file. pg_num Default to 8 pgp_num Default to pg_num pool_type can take values "replicated" or "erasure" erasure_code_profile Set the "erasure_code_profile" crush_ruleset Set the crush map rule set """ m = model.model(**kwargs) u = mdl_updater.model_updater(m) u.hostname_refresh() u.defaults_refresh() u.load_confg(m.cluster_name) u.mon_members_refresh() mur = mdl_updater_remote.model_updater_remote(m) can_connect = mur.connect() if not can_connect: raise Error("Cant connect to cluster.") mur.pool_list() return mur.pool_add(pool_name, **kwargs)
def keyring_auth_del_type(**kwargs): """ Write rgw keyring for cluster CLI Example: salt '*' sesceph.keyring_mds_auth_del \\ 'cluster_name'='ceph' \\ 'cluster_uuid'='cluster_uuid' Notes: cluster_uuid Set the cluster UUID. Defaults to value found in ceph config file. cluster_name Set the cluster name. Defaults to "ceph". """ keyring_type = kwargs.get("keyring_type") if (keyring_type is None): raise Error("keyring_type is None") if (keyring_type in set(["mon","admin"])): raise Error("keyring_type is %s" % (keyring_type)) m = model.model(**kwargs) u = mdl_updater.model_updater(m) u.hostname_refresh() u.defaults_refresh() u.load_confg(m.cluster_name) u.mon_members_refresh() q = mdl_query.mdl_query(m) if q.mon_is(): u.mon_status() keyobj = keyring.keyring_facard(m) keyobj.key_type = keyring_type if not keyobj.present(): raise Error("keyring not present") mur = mdl_updater_remote.model_updater_remote(m) can_connect = mur.connect() if not can_connect: raise Error("Cant connect to cluster.") return mur.auth_del(keyring_type)
def keyring_auth_del_type(**kwargs): """ Write rgw keyring for cluster CLI Example: salt '*' sesceph.keyring_mds_auth_del \\ 'cluster_name'='ceph' \\ 'cluster_uuid'='cluster_uuid' Notes: cluster_uuid Set the cluster UUID. Defaults to value found in ceph config file. cluster_name Set the cluster name. Defaults to "ceph". """ keyring_type = kwargs.get("keyring_type") if (keyring_type is None): raise Error("keyring_type is None") if (keyring_type in set(["mon", "admin"])): raise Error("keyring_type is %s" % (keyring_type)) m = model.model(**kwargs) u = mdl_updater.model_updater(m) u.hostname_refresh() u.defaults_refresh() u.load_confg(m.cluster_name) u.mon_members_refresh() q = mdl_query.mdl_query(m) if q.mon_is(): u.mon_status() keyobj = keyring.keyring_facard(m) keyobj.key_type = keyring_type if not keyobj.present(): raise Error("keyring not present") mur = mdl_updater_remote.model_updater_remote(m) can_connect = mur.connect() if not can_connect: raise Error("Cant connect to cluster.") return mur.auth_del(keyring_type)
def keyring_auth_add_type(**kwargs): keyring_type = kwargs.get("keyring_type") if (keyring_type is None): raise Error("keyring_type is None") if (keyring_type in set(["mon","admin"])): raise Error("keyring_type is %s" % (keyring_type)) m = model.model(**kwargs) u = mdl_updater.model_updater(m) u.hostname_refresh() u.defaults_refresh() u.load_confg(m.cluster_name) u.mon_members_refresh() q = mdl_query.mdl_query(m) if q.mon_is(): u.mon_status() keyobj = keyring.keyring_facard(m) keyobj.key_type = keyring_type if not keyobj.present(): raise Error("keyring not present") mur = mdl_updater_remote.model_updater_remote(m) can_connect = mur.connect() if not can_connect: raise Error("Cant connect to cluster.") return mur.auth_add(keyring_type)
def keyring_auth_add_type(**kwargs): keyring_type = kwargs.get("keyring_type") if (keyring_type is None): raise Error("keyring_type is None") if (keyring_type in set(["mon", "admin"])): raise Error("keyring_type is %s" % (keyring_type)) m = model.model(**kwargs) u = mdl_updater.model_updater(m) u.hostname_refresh() u.defaults_refresh() u.load_confg(m.cluster_name) u.mon_members_refresh() q = mdl_query.mdl_query(m) if q.mon_is(): u.mon_status() keyobj = keyring.keyring_facard(m) keyobj.key_type = keyring_type if not keyobj.present(): raise Error("keyring not present") mur = mdl_updater_remote.model_updater_remote(m) can_connect = mur.connect() if not can_connect: raise Error("Cant connect to cluster.") return mur.auth_add(keyring_type)
def rgw_pools_missing(self): requiredPools = set([".rgw", ".rgw.control", ".rgw.gc", ".log", ".intent-log", ".usage", ".users", ".users.email", ".users.swift", ".users.uid" ]) mur = mdl_updater_remote.model_updater_remote(self.model) can_connect = mur.connect() if not can_connect: raise Error("Cant connect to cluster.") mur.pool_list() if self.model.pool_list == None: LOG.error("Failed to list available pools") return False foundnames = set() for pool in self.model.pool_list: foundnames.add(pool) return list(requiredPools.difference(foundnames))