summaryrefslogtreecommitdiff
path: root/python/samba/netcmd/drs.py
AgeCommit message (Collapse)AuthorFilesLines
2023-12-15python: pep257: docstring should use double quotesRob van der Linde1-6/+6
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-23python:samba:netcmd: Fix code spellingAndreas Schneider1-2/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-09-16samba-tool drs showrepl: use global --color optionDouglas Bagnall1-5/+1
This changes the default from --color=no to --color=auto. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-09-16samba-tool: make --color a general optionDouglas Bagnall1-0/+1
We don't put --color into options.SambaOptions because we can't handle the 'auto' case in the options module without knowing whether or not self.outf is a tty, and a) this might not be resolved and b) is fiddly to pass through. The .use_colour class flag allows samba-tool subcommands to avoid having --color, and is *also* useful in the short term for visualise and drs commands to avoid having this --color clobber their own bespoke versions (temporarily, during the transition). Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-04-28python: remove all 'from __future__ import print_function'Douglas Bagnall1-1/+0
This made Python 2's print behave like Python 3's print(). In some cases, where we had: from __future__ import print_function """Intended module documentation...""" this will have the side effect of making the intended module documentation work as the actual module documentation (i.e. becoming __doc__), because it is once again the first statement in the module. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-12-09samba-tool drs: move attr_default to commonDouglas Bagnall1-7/+1
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2020-10-02python2 reduction: Merge remaining compat code into commonDavid Mulder1-1/+1
The remaining compat code (get_string, get_bytes, cmp) are useful helper routines which we should simply merge into common (especially since there is some duplication here). Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): David Mulder <dmulder@samba.org> Autobuild-Date(master): Fri Oct 2 14:49:36 UTC 2020 on sn-devel-184
2020-02-07python: use raw string for regex with escapeDouglas Bagnall1-1/+1
Python regards 'GPT\.INI$' as a string containing an invalid escape sequence '\.', which is ignored (i.e. treated as the literal sequence of those 2 characters), but only after Python has grumbled to itself, and to you if you enabled DeprecationWarnings. The proper thing to do here is use r-strings, like r'GPT\.INI$', which tell Python that all backslashes are literal. Alternatively (as we do once in this patch), the backslash can itself be escaped ('\\'). There are more problems of this nature in the build scripts. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2019-07-31netcmd: Allow drs replicate --local to create partitionsGarming Sam1-1/+3
Currently, neither the offline (--local) or online (normal replica sync) methods allow partition creation post-join. This overrides the Python default to not create the DB, which allows TDB + MDB to work. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14051 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-07-02samba-tool clone-dc-database: Add --backend-store-size optionGary Lockyer1-3/+13
Add a new "samba-tool drs clone-dc-database" option "backend-store-size". This allows the lmdb map size to be set during a clone, instead of hard-wiring it to 8Gb. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>' Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-10python/samba/netcmd: PY3 port for samba4.drs.samba_tool_drs_showreplNoel Power1-10/+10
Fix various ldb.bytes that need to be stringified in order to get tests to pass Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-10-25samba-tool drs: remove duplicate and unused importsDouglas Bagnall1-2/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2018-10-18netcmd/drs: add cmd_drs_uptodateness with json supportJoe Guo1-0/+93
Add cmd to print uptodateness summary with json support. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> BUG: https://bugzilla.samba.org/show_bug.cgi?id=13658
2018-10-12samba-tool drs showrepl: do not crash if no dnsHostName foundDouglas Bagnall1-2/+2
This should not happen, but it does sometimes in an autobuild environment. Rather than reporting this by crashing, we report it by showing there is no DNS name. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Fri Oct 12 15:27:07 CEST 2018 on sn-devel-144
2018-10-10netcmd: apply the new get_logger to cmdsJoe Guo1-8/+1
This is an example of how to use the new logger. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-08-24PEP8: fix E303: too many blank lines (2)Joe Guo1-6/+0
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E302: expected 2 blank lines, found 1Joe Guo1-0/+3
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E265: block comment should start with '# 'Joe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E241: multiple spaces after ','Joe Guo1-32/+32
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E231: missing whitespace after ','Joe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E225: missing whitespace around operatorJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E202: whitespace before ')'Joe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E123: closing bracket does not match indentation of opening ↵Joe Guo1-5/+5
bracket's line Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-24PEP8: fix E121: continuation line under-indented for hanging indentJoe Guo1-1/+1
Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-08-15samba-tool/drs: set dns_backend to SAMBA_INTERNAL in cmd_drs_clone_dc_databaseJoe Guo1-2/+2
The default value is "NONE", need to specify it to use SAMBA_INTERNAL so that the DNS partitions are replicated. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-07-13python/samba/netcmd: Fix relative module importNoel Power1-1/+1
Part of future changes needed to enable samba4.drs.replica_sync_rodc for PY3. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-07-04samba-tool drs showrepl: correctly report failing repsFromAndrew Bartlett1-1/+1
Hopefully this fixes the flapping test. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Wed Jul 4 04:43:39 CEST 2018 on sn-devel-144
2018-06-28samba-tool drs showrepl: add --pull-summary and --notify-summaryAndrew Bartlett1-13/+36
These separate the two halves of --summary (which is still there), allowing the repsto and repsfrom to be separately queried. One motivation for this is testing: it is difficult to assert the success of repsfrom (--notify-summary) in the test framework, because we can't rely on the other end behaving properly and promptly. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-06-28samba-tool drs showrepl: Skip deleted DSAs when checking for successAndrew Bartlett1-2/+18
The deleted DSAs are ignored by the server replication code, so ignore past failures here also. The repsFrom and repsTo entries will eventually be removed by the KCC. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-06-28samba-tool drs show_repl: simplify the collection of DC listsDouglas Bagnall1-11/+6
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-06-28samba-tool drs showrepl --summary for a quick local checkDouglas Bagnall1-0/+34
The default output ("classic") gives you a lot of very uninteresting detail when everything is fine. --summary shuts up about things that are fine but shouts a little bit when things are broken. It doesn't provide any new information, just tries to present it in a more useful format. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-06-28samba-tool drs showrepl: add a --color flagDouglas Bagnall1-1/+6
Nothing is using it yet, but the next commit will Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-06-20python/samba/netcmd: Fix NameError exceptionNoel Power1-0/+1
Running make test TEST=samba4.drs.samba_tool_drs.python results in BlackboxProcessError: Command '/tmp/samba-testbase/b12/samba/bin/samba-tool drs clone-dc-database samba.example.com --server=localdc -USAMBADOMAIN/Administrator%locDCpass1 --targetdir=/tmp/samba-testbase/b12/samba/bin/ab/tmp/tmpWPo8r3'; exit status 255; stdout: ''; stderr: 'ERROR(<type 'exceptions.NameError'>): uncaught exception - global name 'logging' is not defined File "bin/python/samba/netcmd/__init__.py", line 177, in _run return self.run(*args, **kwargs) File "bin/python/samba/netcmd/drs.py", line 697, in run logger.setLevel(logging.INFO) ' Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Jun 20 04:08:53 CEST 2018 on sn-devel-144
2018-06-10samba-tool drs showrepl: add a --verbose flagDouglas Bagnall1-1/+4
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-06-10samba-tool drs showrepl: generalise the way output mode is chosenDouglas Bagnall1-15/+42
We have a couple more output modes coming along, so it makes senses to untangle .run() into a number of independent sub-methods. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-31samba-tool drs: remove 'server' arg from commands without --serverDouglas Bagnall1-4/+4
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-31samba-tool drs showrepl: remove unused searchDouglas Bagnall1-1/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-31samba-tool: be consistent in accepting -q for --quietDouglas Bagnall1-1/+1
Not all commands accept --quiet, and not all of those that do use it. Some already accept -q, and it is not used anywhere for anything else. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-31samba-tool: add -v to drs --verboseDouglas Bagnall1-1/+1
Sometimes we accept -v for --verbose, sometimes we don't. Let's be a bit more consistent. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-31samba-tool drs replicate: reformat drs_local_replicate methodDouglas Bagnall1-11/+23
line length. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-31samba-tool drs replicate: make pseudo-method a real methodDouglas Bagnall1-61/+59
This function can't function without a cmd_drs_replicate class, so it might as well be inside Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-02-28samba-tool: convert 'except X, (tuple)' to 'except X as e'Noel Power1-1/+2
In addition to converting the except line another line is also added for each except to extract the tuple contents. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-02-15samba-tool: convert 'except X, e' to 'except X as e' for all XDouglas Bagnall1-7/+7
This is needed for Python 3 and is compatible with python 2.6 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-02-15samba-tool drs showrepl: add --json option for JSON outputDouglas Bagnall1-1/+16
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-02-15samba-tool drs showrepl: restructure in preparation for --jsonDouglas Bagnall1-45/+94
Basically we just separate data extraction from printing. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-02-09sambatool drs showrepl: prefer self over ctx in python classesDouglas Bagnall1-2/+3
and the line length too. (Now only python/samba/join.py uses ctx for self, but at least it does it consistently. This was the only ctx function in the class). Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Feb 9 12:34:06 CET 2018 on sn-devel-144
2017-07-28drs: support sync-forced for 'samba-tool drs replicate --local'Tim Beale1-3/+6
The sync-forced option wasn't being passed into the replication request when the --local option was used. This meant if outbound replication were disabled on the target DC, then the replicate --local command would fail. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-02-23samba-tool drs replicate: Add --single-objectAndrew Bartlett1-4/+12
This may help when an object has been incorrectly locally removed from the NC or there is an urgent need to replicate a specific object (say when full replication is inoperable). Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-02-23python: Move partial replication logic into drs_utils.pyAndrew Bartlett1-34/+1
This allows us to use this easily from join.py soon Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-02-14samba-tool/drs: do partial replication when --local is given by defaultBob Campbell1-9/+52
The samba-tool drs replicate --local command would previously always do a full replication. This changes it to only replicate changes it doesn't have according to appropriate highwatermark if the appropriate repsFrom attribute exists in the local database, or an uptodateness_vector if one exists. Signed-off-by: Bob Campbell <bobcampbell@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Pair-programmed-with: Andrew Bartlett <abartlet@samba.org>