diff --git a/src/cockpit/389-console/src/database.jsx b/src/cockpit/389-console/src/database.jsx index 5bfe983ea6..1d4a5b5516 100644 --- a/src/cockpit/389-console/src/database.jsx +++ b/src/cockpit/389-console/src/database.jsx @@ -809,6 +809,7 @@ export class Database extends React.Component { cachememsize: config.attrs['nsslapd-cachememsize'][0], cachesize: config.attrs['nsslapd-cachesize'][0], dncachememsize: config.attrs['nsslapd-dncachememsize'][0], + dbstate: config.attrs['nsslapd-state'][0], readOnly: readonly, requireIndex: requireindex, } @@ -977,6 +978,7 @@ export class Database extends React.Component { cachememsize: config.attrs['nsslapd-cachememsize'][0], cachesize: config.attrs['nsslapd-cachesize'][0], dncachememsize: config.attrs['nsslapd-dncachememsize'][0], + dbstate: config.attrs['nsslapd-state'][0], readOnly: readonly, requireIndex: requireindex, } diff --git a/src/cockpit/389-console/src/lib/database/chaining.jsx b/src/cockpit/389-console/src/lib/database/chaining.jsx index 3bae975577..1a13bdae89 100644 --- a/src/cockpit/389-console/src/lib/database/chaining.jsx +++ b/src/cockpit/389-console/src/lib/database/chaining.jsx @@ -565,7 +565,7 @@ export class ChainingDatabaseConfig extends React.Component { Default Creation Settings}> -
+
{saveBtnName} -
Controls & Components}> diff --git a/src/cockpit/389-console/src/lib/database/databaseConfig.jsx b/src/cockpit/389-console/src/lib/database/databaseConfig.jsx index 3729fe8a27..4766e0a9cf 100644 --- a/src/cockpit/389-console/src/lib/database/databaseConfig.jsx +++ b/src/cockpit/389-console/src/lib/database/databaseConfig.jsx @@ -458,7 +458,7 @@ export class GlobalDatabaseConfig extends React.Component { } return ( -
+
{spinner}
@@ -753,7 +753,6 @@ export class GlobalDatabaseConfig extends React.Component { > {saveBtnName} -
); diff --git a/src/cockpit/389-console/src/lib/database/globalPwp.jsx b/src/cockpit/389-console/src/lib/database/globalPwp.jsx index e87fbf4aa2..93fe5754a6 100644 --- a/src/cockpit/389-console/src/lib/database/globalPwp.jsx +++ b/src/cockpit/389-console/src/lib/database/globalPwp.jsx @@ -1149,7 +1149,7 @@ export class GlobalPwPolicy extends React.Component {
; } else { pwp_element = -
+
General Settings}>
@@ -1342,7 +1342,6 @@ export class GlobalPwPolicy extends React.Component { > {saveBtnName} -
Expiration}> diff --git a/src/cockpit/389-console/src/lib/database/indexes.jsx b/src/cockpit/389-console/src/lib/database/indexes.jsx index bdbde4c13d..2724df4463 100644 --- a/src/cockpit/389-console/src/lib/database/indexes.jsx +++ b/src/cockpit/389-console/src/lib/database/indexes.jsx @@ -780,7 +780,7 @@ export class SuffixIndexes extends React.Component {
Database Indexes ({this.props.indexRows.length})}> -
+
-
System Indexes ({this.props.systemIndexRows.length})}> diff --git a/src/cockpit/389-console/src/lib/database/localPwp.jsx b/src/cockpit/389-console/src/lib/database/localPwp.jsx index 5a8bde2859..1011b3faa4 100644 --- a/src/cockpit/389-console/src/lib/database/localPwp.jsx +++ b/src/cockpit/389-console/src/lib/database/localPwp.jsx @@ -120,7 +120,7 @@ class CreatePolicy extends React.Component { } return ( -
+
@@ -777,7 +777,6 @@ class CreatePolicy extends React.Component { > Create New Policy -
); } diff --git a/src/cockpit/389-console/src/lib/database/referrals.jsx b/src/cockpit/389-console/src/lib/database/referrals.jsx index 908d2c3bf0..fa6563bb59 100644 --- a/src/cockpit/389-console/src/lib/database/referrals.jsx +++ b/src/cockpit/389-console/src/lib/database/referrals.jsx @@ -255,13 +255,13 @@ export class SuffixReferrals extends React.Component { render() { return ( -
+
- {cacheInputs} - + + + Backend State + + + { + this.props.handleChange(e); + }} + aria-label="FormSelect Input" + > + + + + + + + + - + +
-
{_("Report Result")}}>
diff --git a/src/cockpit/389-console/src/lib/monitor/suffixMonitor.jsx b/src/cockpit/389-console/src/lib/monitor/suffixMonitor.jsx index b81478a358..c58c8525a9 100644 --- a/src/cockpit/389-console/src/lib/monitor/suffixMonitor.jsx +++ b/src/cockpit/389-console/src/lib/monitor/suffixMonitor.jsx @@ -27,7 +27,7 @@ import { faLeaf, faTree, } from '@fortawesome/free-solid-svg-icons'; -import { numToCommas, displayBytes } from '../tools.jsx'; +import { numToCommas, displayBytes, log_cmd } from '../tools.jsx'; export class SuffixMonitor extends React.Component { constructor (props) { @@ -135,6 +135,7 @@ export class SuffixMonitor extends React.Component { "dsconf", "-j", "ldapi://%2fvar%2frun%2fslapd-" + this.props.serverId + ".socket", "monitor", "backend", this.props.suffix ]; + log_cmd("refreshSuffixCache", "Get suffix monitor", cmd); cockpit .spawn(cmd, { superuser: true, err: "message" }) .done(content => { @@ -298,7 +299,7 @@ export class SuffixMonitor extends React.Component {
- +
@@ -344,7 +345,7 @@ export class SuffixMonitor extends React.Component { - +
@@ -402,43 +403,44 @@ export class SuffixMonitor extends React.Component { Entry Cache Hit Ratio: - {this.state.data.entrycachehitratio}% + {this.state.data.entrycachehitratio[0]}% - Entry Cache Tries: + Entry Cache Max Size: - {numToCommas(this.state.data.entrycachetries)} + {displayBytes(cachemax)} + Entry Cache Hits: - {numToCommas(this.state.data.entrycachehits)} + {numToCommas(this.state.data.entrycachehits[0])} - Entry Cache Max Size: + Entry Cache Current Size: - {displayBytes(this.state.data.maxentrycachesize)} + {displayBytes(cachecurr)} - Entry Cache Current Size: + Entry Cache Tries: - {displayBytes(this.state.data.currententrycachesize)} + {numToCommas(this.state.data.entrycachetries[0])} Entry Cache Max Entries: - {numToCommas(this.state.data.maxentrycachecount)} + {numToCommas(this.state.data.maxentrycachecount[0])} Entry Cache Count: - {numToCommas(this.state.data.currententrycachecount)} + {numToCommas(this.state.data.currententrycachecount[0])} @@ -446,7 +448,7 @@ export class SuffixMonitor extends React.Component {
- +
@@ -492,7 +494,7 @@ export class SuffixMonitor extends React.Component { - +
@@ -550,43 +552,43 @@ export class SuffixMonitor extends React.Component { DN Cache Hit Ratio: - {this.state.data.dncachehitratio}% + {this.state.data.dncachehitratio[0]}% - DN Cache Tries: + DN Cache Max Size: - {numToCommas(this.state.data.dncachetries)} + {displayBytes(dncachemax)} DN Cache Hits: - {numToCommas(this.state.data.dncachehits)} + {numToCommas(this.state.data.dncachehits[0])} - DN Cache Max Size: + DN Cache Current Size: - {displayBytes(this.state.data.maxdncachesize)} + {displayBytes(dncachecurr)} - DN Cache Current Size: + DN Cache Tries: - {displayBytes(this.state.data.currentdncachesize)} + {numToCommas(this.state.data.dncachetries[0])} DN Cache Max Count: - {numToCommas(this.state.data.maxdncachecount)} + {numToCommas(this.state.data.maxdncachecount[0])} DN Cache Current Count: - {numToCommas(this.state.data.currentdncachecount)} + {numToCommas(this.state.data.currentdncachecount[0])} diff --git a/src/cockpit/389-console/src/lib/replication/replAgmts.jsx b/src/cockpit/389-console/src/lib/replication/replAgmts.jsx index 8afaa2239b..d9686f5ab0 100644 --- a/src/cockpit/389-console/src/lib/replication/replAgmts.jsx +++ b/src/cockpit/389-console/src/lib/replication/replAgmts.jsx @@ -1538,7 +1538,7 @@ export class ReplAgmts extends React.Component { render() { return ( -
+
-
+
-
diff --git a/src/cockpit/389-console/src/lib/replication/winsyncAgmts.jsx b/src/cockpit/389-console/src/lib/replication/winsyncAgmts.jsx index 968804a393..eebd2a6005 100644 --- a/src/cockpit/389-console/src/lib/replication/winsyncAgmts.jsx +++ b/src/cockpit/389-console/src/lib/replication/winsyncAgmts.jsx @@ -1208,7 +1208,7 @@ export class WinsyncAgmts extends React.Component { search={this.onSearchChange} value={this.state.value} /> -
+
-
; } diff --git a/src/cockpit/389-console/src/lib/server/errorLog.jsx b/src/cockpit/389-console/src/lib/server/errorLog.jsx index 97a34fdf83..e728b813c2 100644 --- a/src/cockpit/389-console/src/lib/server/errorLog.jsx +++ b/src/cockpit/389-console/src/lib/server/errorLog.jsx @@ -745,7 +745,7 @@ export class ServerErrorLog extends React.Component { } return ( -
+
diff --git a/src/cockpit/389-console/src/lib/server/sasl.jsx b/src/cockpit/389-console/src/lib/server/sasl.jsx index 605f1dca40..c821e75760 100644 --- a/src/cockpit/389-console/src/lib/server/sasl.jsx +++ b/src/cockpit/389-console/src/lib/server/sasl.jsx @@ -661,7 +661,7 @@ export class ServerSASL extends React.Component {
; } else { body = -
+
@@ -771,7 +771,6 @@ export class ServerSASL extends React.Component { > Create New Mapping -
; } diff --git a/src/cockpit/389-console/src/lib/server/settings.jsx b/src/cockpit/389-console/src/lib/server/settings.jsx index a5d1117387..cf05a8e65d 100644 --- a/src/cockpit/389-console/src/lib/server/settings.jsx +++ b/src/cockpit/389-console/src/lib/server/settings.jsx @@ -832,7 +832,7 @@ export class ServerSettings extends React.Component { if (this.state['nsslapd-disk-monitoring']) { diskMonitor = -
+ @@ -901,7 +901,7 @@ export class ServerSettings extends React.Component {
; } else { body = -
+
@@ -1390,7 +1390,6 @@ export class ServerSettings extends React.Component { > {saveBtnName} -
diff --git a/src/cockpit/389-console/src/lib/server/tuning.jsx b/src/cockpit/389-console/src/lib/server/tuning.jsx index 9f24139d2b..7c651a9f0a 100644 --- a/src/cockpit/389-console/src/lib/server/tuning.jsx +++ b/src/cockpit/389-console/src/lib/server/tuning.jsx @@ -260,7 +260,7 @@ export class ServerTuning extends React.Component {
; } else { body = -
+
@@ -602,7 +602,6 @@ export class ServerTuning extends React.Component { > {saveBtnName} -
; } diff --git a/src/cockpit/389-console/src/monitor.jsx b/src/cockpit/389-console/src/monitor.jsx index ff5015b060..45d1c561af 100644 --- a/src/cockpit/389-console/src/monitor.jsx +++ b/src/cockpit/389-console/src/monitor.jsx @@ -944,6 +944,7 @@ export class Monitor extends React.Component { bename={this.state.bename} enableTree={this.enableTree} key={this.state.node_text} + addNotification={this.props.addNotification} />; } } diff --git a/src/cockpit/389-console/src/schema.jsx b/src/cockpit/389-console/src/schema.jsx index d920de85d9..7f4e898e54 100644 --- a/src/cockpit/389-console/src/schema.jsx +++ b/src/cockpit/389-console/src/schema.jsx @@ -1389,7 +1389,7 @@ export class Schema extends React.Component { ); } else { schemaPage = ( -
+
Objectclasses}>
@@ -1416,7 +1416,6 @@ export class Schema extends React.Component { > Add ObjectClass -
Add Attribute -
+
{saveBtnName} -
; } securityPage = -
+
diff --git a/src/lib389/lib389/backend.py b/src/lib389/lib389/backend.py index 4a69b5aa6a..072085f27e 100644 --- a/src/lib389/lib389/backend.py +++ b/src/lib389/lib389/backend.py @@ -865,6 +865,37 @@ def get_cos_classic_defs(self): def get_cos_templates(self): return CosTemplates(self._instance, self._dn).list() + def get_state(self): + suffix = self.get_attr_val_utf8('nsslapd-suffix') + try: + mt = self._mts.get(suffix) + except ldap.NO_SUCH_OBJECT: + raise ValueError("Backend missing mapping tree entry, unable to get state") + return mt.get_attr_val_utf8('nsslapd-state') + + def set_state(self, new_state): + new_state = new_state.lower() + suffix = self.get_attr_val_utf8('nsslapd-suffix') + try: + mt = self._mts.get(suffix) + except ldap.NO_SUCH_OBJECT: + raise ValueError("Backend missing mapping tree entry, unable to set configuration") + + if new_state not in ['backend', 'disabled', 'referral', 'referral on update']: + raise ValueError(f"Invalid backend state {new_state}, value must be one of the following: 'backend', 'disabled', 'referral', 'referral on update'") + + # Can not change state of replicated backend + replicas = Replicas(self._instance) + try: + # Check if replication is enabled + replicas.get(suffix) + raise ValueError("Can not change the backend state of a replicated suffix") + except ldap.NO_SUCH_OBJECT: + pass + + # Ok, change the state + mt.replace('nsslapd-state', new_state) + class Backends(DSLdapObjects): """DSLdapObjects that represents DN_LDBM base DN diff --git a/src/lib389/lib389/cli_conf/backend.py b/src/lib389/lib389/cli_conf/backend.py index ea418c2009..92b573200f 100644 --- a/src/lib389/lib389/cli_conf/backend.py +++ b/src/lib389/lib389/cli_conf/backend.py @@ -34,6 +34,7 @@ arg_to_attr = { 'lookthroughlimit': 'nsslapd-lookthroughlimit', 'mode': 'nsslapd-mode', + 'state': 'nsslapd-state', 'idlistscanlimit': 'nsslapd-idlistscanlimit', 'directory': 'nsslapd-directory', 'dbcachesize': 'nsslapd-dbcachesize', @@ -156,7 +157,18 @@ def backend_list(inst, basedn, log, args): def backend_get(inst, basedn, log, args): rdn = _get_arg(args.selector, msg="Enter %s to retrieve" % RDN) - _generic_get(inst, basedn, log.getChild('backend_get'), MANY, rdn, args) + be = _get_backend(inst, rdn) + be_state = be.get_state() + if args.json: + entry = be.get_all_attrs_json() + entry_dict = json.loads(entry) + entry_dict['attrs']['nsslapd-state'] = [be_state] + log.info(json.dumps(entry_dict, indent=4)) + else: + entry = be.display() + updated_entry = entry[:-1] # remove \n + updated_entry += "nsslapd-state: " + be_state + log.info(updated_entry) def backend_get_dn(inst, basedn, log, args): @@ -478,6 +490,8 @@ def backend_set(inst, basedn, log, args): be.set('nsslapd-require-index', 'on') if args.ignore_index: be.set('nsslapd-require-index', 'off') + if args.state: + be.set_state(args.state) if args.enable: be.enable() if args.disable: @@ -845,6 +859,7 @@ def create_parser(subparsers): set_backend_parser.add_argument('--cache-size', help='The maximum number of entries to keep in the entry cache') set_backend_parser.add_argument('--cache-memsize', help='The maximum size in bytes that the entry cache can grow to') set_backend_parser.add_argument('--dncache-memsize', help='The maximum size in bytes that the DN cache can grow to') + set_backend_parser.add_argument('--state', help='Change the backend state to: "database", "disabled", "referral", "referral on update"') set_backend_parser.add_argument('be_name', help='The backend name or suffix to delete') #########################################