From f2a14a4479dca314d8b75234a0b3061acb577983 Mon Sep 17 00:00:00 2001 From: Ben Nemec Date: Thu, 23 Jun 2016 18:32:54 +0000 Subject: [PATCH] Revert "Add Global Flags for filtering results" Registering these options as global flags pollutes the global opt namespace and is masking plugin-specific options in other plugins. Partial-Bug: 1595616 This reverts commit 0b2b870237b6a332239dcad73cd9cab2634cb44f. Change-Id: I7ef5c5511adc40d603374c4963ba22556f16252e --- designateclient/osc/plugin.py | 26 +--------------------- designateclient/v2/cli/recordsets.py | 11 ---------- designateclient/v2/cli/zones.py | 2 -- designateclient/v2/client.py | 33 +++------------------------- designateclient/v2/utils.py | 2 +- 5 files changed, 5 insertions(+), 69 deletions(-) diff --git a/designateclient/osc/plugin.py b/designateclient/osc/plugin.py index 90fded4..d57c54d 100644 --- a/designateclient/osc/plugin.py +++ b/designateclient/osc/plugin.py @@ -32,15 +32,8 @@ def make_client(instance): API_NAME, instance._api_version[API_NAME], API_VERSIONS) kwargs = oscutils.build_kwargs_dict('endpoint_type', instance._interface) - - parsed_args = instance.get_configuration() - return cls(session=instance.session, - region_name=instance._region_name, - all_projects=parsed_args.get('all_projects', False), - edit_managed=parsed_args.get('edit_managed', False), - sudo_project_id=parsed_args.get('sudo_project_id', None), - **kwargs) + region_name=instance._region_name, **kwargs) def build_option_parser(parser): @@ -53,21 +46,4 @@ def build_option_parser(parser): DEFAULT_API_VERSION + ' (Env: OS_DNS_API_VERSION)') - parser.add_argument( - '--all-projects', - default=False, - action='store_true', - help='Show results from all projects. Default=False') - - parser.add_argument( - '--edit-managed', - default=False, - action='store_true', - help='Edit resources marked as managed. Default=False') - - parser.add_argument( - '--sudo-project-id', - default=None, - help='Project ID to impersonate for this command. Default=None') - return parser diff --git a/designateclient/v2/cli/recordsets.py b/designateclient/v2/cli/recordsets.py index 281c03a..00d9348 100644 --- a/designateclient/v2/cli/recordsets.py +++ b/designateclient/v2/cli/recordsets.py @@ -33,14 +33,6 @@ def _format_recordset(recordset): return recordset -def _has_project_id(data): - if len(data) < 1: - return False - if 'project_id' in data[0]: - return True - return False - - class ListRecordSetsCommand(lister.Lister): """List recordsets""" @@ -96,9 +88,6 @@ class ListRecordSetsCommand(lister.Lister): data = get_all(client.recordsets.list, args=[parsed_args.zone_id], criterion=criterion) - if client.session.all_projects and _has_project_id(data): - cols.insert(1, 'project_id') - for i, rs in enumerate(data): data[i] = _format_recordset(rs) diff --git a/designateclient/v2/cli/zones.py b/designateclient/v2/cli/zones.py index 87940c6..7035e56 100644 --- a/designateclient/v2/cli/zones.py +++ b/designateclient/v2/cli/zones.py @@ -85,8 +85,6 @@ class ListZonesCommand(lister.Lister): data = get_all(client.zones.list, criterion) cols = self.columns - if client.session.all_projects: - cols.insert(1, 'project_id') return cols, (utils.get_item_properties(s, cols) for s in data) diff --git a/designateclient/v2/client.py b/designateclient/v2/client.py index e7eba3b..e000fd3 100644 --- a/designateclient/v2/client.py +++ b/designateclient/v2/client.py @@ -41,9 +41,6 @@ class DesignateAdapter(adapter.LegacyJsonAdapter): """ def __init__(self, *args, **kwargs): self.timeout = kwargs.pop('timeout', None) - self.all_projects = kwargs.pop('all_projects', False) - self.edit_managed = kwargs.pop('edit_managed', False) - self.sudo_project_id = kwargs.pop('sudo_project_id', None) super(self.__class__, self).__init__(*args, **kwargs) def request(self, *args, **kwargs): @@ -52,27 +49,7 @@ class DesignateAdapter(adapter.LegacyJsonAdapter): if self.timeout is not None: kwargs.setdefault('timeout', self.timeout) - kwargs.setdefault('headers', {}) - - if self.all_projects: - kwargs['headers'].setdefault( - 'X-Auth-All-Projects', - self.all_projects - ) - - if self.edit_managed: - kwargs['headers'].setdefault( - 'X-Designate-Edit-Managed-Records', - self.edit_managed - ) - - if self.sudo_project_id is not None: - kwargs['headers'].setdefault( - 'X-Auth-Sudo-Project-ID', - self.sudo_project_id - ) - - kwargs['headers'].setdefault( + kwargs.setdefault('headers', {}).setdefault( 'Content-Type', 'application/json') response, body = super(self.__class__, self).request(*args, **kwargs) @@ -101,8 +78,7 @@ class Client(object): def __init__(self, region_name=None, endpoint_type='publicURL', extensions=None, service_type='dns', service_name=None, http_log_debug=False, session=None, auth=None, timeout=None, - endpoint_override=None, all_projects=False, - edit_managed=False, sudo_project_id=None): + endpoint_override=None): if session is None: raise ValueError("A session instance is required") @@ -115,10 +91,7 @@ class Client(object): user_agent='python-designateclient-%s' % version.version_info, version=('2'), endpoint_override=endpoint_override, - timeout=timeout, - all_projects=all_projects, - edit_managed=edit_managed, - sudo_project_id=sudo_project_id + timeout=timeout ) self.blacklists = BlacklistController(self) diff --git a/designateclient/v2/utils.py b/designateclient/v2/utils.py index b56b4ce..4a69a55 100644 --- a/designateclient/v2/utils.py +++ b/designateclient/v2/utils.py @@ -77,4 +77,4 @@ def get_all(function, criterion=None, args=None): else: break - return returned_data + return returned_data \ No newline at end of file