Merge "Add --edit-managed flag to cli"

This commit is contained in:
Jenkins 2015-05-11 21:11:30 +00:00 committed by Gerrit Code Review
commit af7bdadf43
3 changed files with 11 additions and 2 deletions

View File

@ -165,6 +165,10 @@ class DesignateShell(App):
parser.add_argument('--all-tenants', action='store_true', parser.add_argument('--all-tenants', action='store_true',
help="Allows to list all domains from all tenants") help="Allows to list all domains from all tenants")
parser.add_argument('--edit-managed', action='store_true',
help='Allows to edit records that are marked as '
'managed')
return parser return parser
def configure_logging(self): def configure_logging(self):
@ -232,6 +236,7 @@ class DesignateShell(App):
insecure=self.options.insecure, insecure=self.options.insecure,
cacert=self.options.os_cacert, cacert=self.options.os_cacert,
all_tenants=self.options.all_tenants, all_tenants=self.options.all_tenants,
edit_managed=self.options.edit_managed
) )
def run(self, argv): def run(self, argv):

View File

@ -101,7 +101,7 @@ def get_columns(data):
def get_session(auth_url, endpoint, domain_id, domain_name, project_id, def get_session(auth_url, endpoint, domain_id, domain_name, project_id,
project_name, project_domain_name, project_domain_id, username, project_name, project_domain_name, project_domain_id, username,
user_id, password, user_domain_id, user_domain_name, token, user_id, password, user_domain_id, user_domain_name, token,
insecure, cacert, all_tenants): insecure, cacert, all_tenants, edit_managed):
session = ks_session.Session() session = ks_session.Session()
# Build + Attach Authentication Plugin # Build + Attach Authentication Plugin
@ -140,6 +140,7 @@ def get_session(auth_url, endpoint, domain_id, domain_name, project_id,
else: else:
session.verify = cacert session.verify = cacert
session.all_tenants = all_tenants session.all_tenants = all_tenants
session.edit_managed = edit_managed
return session return session

View File

@ -32,7 +32,7 @@ class Client(object):
project_domain_id=None, auth_url=None, token=None, project_domain_id=None, auth_url=None, token=None,
endpoint_type='publicURL', region_name=None, endpoint_type='publicURL', region_name=None,
service_type='dns', insecure=False, session=None, service_type='dns', insecure=False, session=None,
cacert=None, all_tenants=False): cacert=None, all_tenants=False, edit_managed=False):
""" """
:param endpoint: Endpoint URL :param endpoint: Endpoint URL
:param token: A token instead of username / password :param token: A token instead of username / password
@ -64,6 +64,7 @@ class Client(object):
insecure=insecure, insecure=insecure,
cacert=cacert, cacert=cacert,
all_tenants=all_tenants, all_tenants=all_tenants,
edit_managed=edit_managed,
) )
# Since we have to behave nicely like a legacy client/bindings we use # Since we have to behave nicely like a legacy client/bindings we use
@ -100,6 +101,8 @@ class Client(object):
kw['headers'].setdefault('Content-Type', 'application/json') kw['headers'].setdefault('Content-Type', 'application/json')
if self.session.session.all_tenants: if self.session.session.all_tenants:
kw['headers'].update({'X-Auth-All-Projects': 'true'}) kw['headers'].update({'X-Auth-All-Projects': 'true'})
if self.session.session.edit_managed:
kw['headers'].update({'X-Designate-Edit-Managed-Records': 'true'})
# Trigger the request # Trigger the request
response = func(*args, **kw) response = func(*args, **kw)