On 31.05.2016 13:04, Martin Babinsky wrote:
On 05/26/2016 04:52 PM, Martin Basti wrote:
https://fedorahosted.org/freeipa/ticket/5915
Patches attached
ACK.
Even better patches attached.
From 1918df3017504354834c9175faf8d09108feb07a Mon Sep 17 00:00:00 2001
From: Martin Basti
Date: Fri, 13 May 2016 18:39:47 +0200
Subject: [PATCH 1/2] DNS Locations: prevent to remove used locations
User should be notified that location is used by IPA server(s) and
deletion should be aborted without --force option.
Referint plugin is configured to remove references of deleted locations.
https://fedorahosted.org/freeipa/ticket/2008
---
API.txt| 3 ++-
VERSION| 4 ++--
install/updates/25-referint.update | 1 +
ipalib/plugins/location.py | 27 ++-
4 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/API.txt b/API.txt
index 608f1083faf2b03214432c134f403c40ccdb6700..10a2d9f076391f1a9133cf0899dd07d81043b0a3 100644
--- a/API.txt
+++ b/API.txt
@@ -2772,9 +2772,10 @@ output: Entry('result')
output: Output('summary', type=[, ])
output: PrimaryKey('value')
command: location_del
-args: 1,2,3
+args: 1,3,3
arg: DNSNameParam('idnsname+', cli_name='name')
option: Flag('continue', autofill=True, cli_name='continue', default=False)
+option: Flag('force', autofill=True, default=False)
option: Str('version?')
output: Output('result', type=[])
output: Output('summary', type=[, ])
diff --git a/VERSION b/VERSION
index 93ea86438d56f6206b28decbf95d2e7ccd57f8ed..90b240383a95bdc1783de99f416df1551641bfba 100644
--- a/VERSION
+++ b/VERSION
@@ -90,5 +90,5 @@ IPA_DATA_VERSION=2010061412
# #
IPA_API_VERSION_MAJOR=2
-IPA_API_VERSION_MINOR=172
-# Last change: mbasti - location-show: list servers in the location
+IPA_API_VERSION_MINOR=173
+# Last change: mbasti - server-del: prevent to remove used locations
diff --git a/install/updates/25-referint.update b/install/updates/25-referint.update
index 3f78ee9755823fb3d5838d3069f4506c57a69d05..b887ede9c98f100709d24aae26b75d501f581016 100644
--- a/install/updates/25-referint.update
+++ b/install/updates/25-referint.update
@@ -19,3 +19,4 @@ add: referint-membership-attr: ipaassignedidview
add: referint-membership-attr: ipaallowedtarget
add: referint-membership-attr: ipamemberca
add: referint-membership-attr: ipamembercertprofile
+add: referint-membership-attr: ipalocation
diff --git a/ipalib/plugins/location.py b/ipalib/plugins/location.py
index 6d876d51204f9957a091c12d89414fead0fc95c6..c38ff580964f314675dc0743a52dca27638a1f06 100644
--- a/ipalib/plugins/location.py
+++ b/ipalib/plugins/location.py
@@ -9,8 +9,10 @@ from ipalib import (
ngettext,
api,
Str,
-DNSNameParam
+DNSNameParam,
+Flag,
)
+from ipalib.errors import DependentEntry
from ipalib.plugable import Registry
from ipalib.plugins.baseldap import (
LDAPCreate,
@@ -134,6 +136,29 @@ class location_del(LDAPDelete):
msg_summary = _('Deleted IPA location "%(value)s"')
+takes_options = LDAPDelete.takes_options + (
+Flag(
+'force',
+label=_('Force'),
+doc=_('force location removal'),
+),
+)
+
+def pre_callback(self, ldap, dn, *keys, **options):
+assert isinstance(dn, DN)
+if not options.get('force'):
+servers = self.api.Command.server_find(
+in_location=keys[-1])['result']
+location_members = u', '.join(
+server['cn'][0] for server in servers)
+if location_members:
+raise DependentEntry(
+label=_('IPA Server(s)'),
+key=keys[-1],
+dependent=location_members
+)
+return dn
+
@register()
class location_mod(LDAPUpdate):
--
2.5.5
From bdd9280996de8d28dfb8b74fe07dd597eeb13bc5 Mon Sep 17 00:00:00 2001
From: Martin Basti
Date: Tue, 17 May 2016 13:08:59 +0200
Subject: [PATCH 2/2] DNS Locations: extend tests with server-* commands
https://fedorahosted.org/freeipa/ticket/2008
---
ipatests/test_xmlrpc/test_location_plugin.py| 101 +-
ipatests/test_xmlrpc/tracker/location_plugin.py | 29 +--
ipatests/test_xmlrpc/tracker/server_plugin.py | 107
3 files changed, 230 insertions(+), 7 deletions(-)
create mode 100644 ipatests/test_xmlrpc/tracker/server_plugin.py
diff --git a/ipatests/test_xmlrpc/test_location_plugin.py b/ipatests/test_xmlrpc/test_location_plugin.py
index 1ca3eac7c72e0662034cb67039e1d0925bd1acca..a5d0797958b62e72714ac0f3e1e8c50dd5836d6b 100644
--- a/ipatests/test_xmlrpc/test_location_plugin.py
+++ b/ipatests/test_xmlrpc/test_location_plugin.py
@@ -5,12 +5,14 @@ from __future__ import absolute_import
import pytest
-from ipalib