Merge "Revert "Add Global Flags for filtering results""

This commit is contained in:
Jenkins 2016-06-24 14:39:07 +00:00 committed by Gerrit Code Review
commit e5f652c630
5 changed files with 5 additions and 69 deletions

View File

@ -33,15 +33,8 @@ def make_client(instance):
API_NAME, instance._api_version[API_NAME], API_NAME, instance._api_version[API_NAME],
API_VERSIONS) API_VERSIONS)
kwargs = oscutils.build_kwargs_dict('endpoint_type', instance._interface) kwargs = oscutils.build_kwargs_dict('endpoint_type', instance._interface)
parsed_args = instance.get_configuration()
return cls(session=instance.session, return cls(session=instance.session,
region_name=instance._region_name, region_name=instance._region_name, **kwargs)
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)
def build_option_parser(parser): def build_option_parser(parser):
@ -54,21 +47,4 @@ def build_option_parser(parser):
DEFAULT_API_VERSION + DEFAULT_API_VERSION +
' (Env: OS_DNS_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 return parser

View File

@ -33,14 +33,6 @@ def _format_recordset(recordset):
return 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): class ListRecordSetsCommand(lister.Lister):
"""List recordsets""" """List recordsets"""
@ -96,9 +88,6 @@ class ListRecordSetsCommand(lister.Lister):
data = get_all(client.recordsets.list, args=[parsed_args.zone_id], data = get_all(client.recordsets.list, args=[parsed_args.zone_id],
criterion=criterion) criterion=criterion)
if client.session.all_projects and _has_project_id(data):
cols.insert(1, 'project_id')
for i, rs in enumerate(data): for i, rs in enumerate(data):
data[i] = _format_recordset(rs) data[i] = _format_recordset(rs)

View File

@ -85,8 +85,6 @@ class ListZonesCommand(lister.Lister):
data = get_all(client.zones.list, criterion) data = get_all(client.zones.list, criterion)
cols = self.columns 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) 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): def __init__(self, *args, **kwargs):
self.timeout = kwargs.pop('timeout', None) 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) super(self.__class__, self).__init__(*args, **kwargs)
def request(self, *args, **kwargs): def request(self, *args, **kwargs):
@ -52,27 +49,7 @@ class DesignateAdapter(adapter.LegacyJsonAdapter):
if self.timeout is not None: if self.timeout is not None:
kwargs.setdefault('timeout', self.timeout) kwargs.setdefault('timeout', self.timeout)
kwargs.setdefault('headers', {}) kwargs.setdefault('headers', {}).setdefault(
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(
'Content-Type', 'application/json') 'Content-Type', 'application/json')
response, body = super(self.__class__, self).request(*args, **kwargs) 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', def __init__(self, region_name=None, endpoint_type='publicURL',
extensions=None, service_type='dns', service_name=None, extensions=None, service_type='dns', service_name=None,
http_log_debug=False, session=None, auth=None, timeout=None, http_log_debug=False, session=None, auth=None, timeout=None,
endpoint_override=None, all_projects=False, endpoint_override=None):
edit_managed=False, sudo_project_id=None):
if session is None: if session is None:
raise ValueError("A session instance is required") raise ValueError("A session instance is required")
@ -115,10 +91,7 @@ class Client(object):
user_agent='python-designateclient-%s' % version.version_info, user_agent='python-designateclient-%s' % version.version_info,
version=('2'), version=('2'),
endpoint_override=endpoint_override, endpoint_override=endpoint_override,
timeout=timeout, timeout=timeout
all_projects=all_projects,
edit_managed=edit_managed,
sudo_project_id=sudo_project_id
) )
self.blacklists = BlacklistController(self) self.blacklists = BlacklistController(self)

View File

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