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 0b2b870237.

Change-Id: I7ef5c5511adc40d603374c4963ba22556f16252e
This commit is contained in:
Ben Nemec 2016-06-23 18:32:54 +00:00
parent ee9cbe632c
commit f2a14a4479
5 changed files with 5 additions and 69 deletions

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -77,4 +77,4 @@ def get_all(function, criterion=None, args=None):
else:
break
return returned_data
return returned_data