Function get_service_files() now can get files for all data_type-s.

This is required for implementing FixedFilterAction in dashboard.

Change-Id: Ia53e3336a759e6ecd8e8ee0d1736fb4f825ccf48
This commit is contained in:
Timur Sufiev 2013-11-18 18:28:39 +04:00
parent 95a95d9e41
commit f7bf8a15c9
1 changed files with 26 additions and 12 deletions

View File

@ -38,21 +38,35 @@ class Controller(object):
else:
raise exc.HTTPInternalServerError()
def get_service_files(self, data_type, service=None):
included_files = {}
if service:
def get_service_files(self, data_type=None, service=None):
all_files = []
def get_files(_data_type):
included_files = {}
if service:
resp, body = self.http_client.json_request(
'GET',
'/v1/admin/services/{service}'.format(service=service))
for path in body.get('service_files', {}).get(_data_type, []):
included_files[path] = True
resp, body = self.http_client.json_request(
'GET', '/v1/admin/services/{service}'.format(service=service))
for path in body.get('service_files', {}).get(data_type, []):
included_files[path] = True
'GET', '/v1/admin/{data_type}'.format(data_type=_data_type))
files = body.get(_data_type, [])
resp, body = self.http_client.json_request(
'GET', '/v1/admin/{data_type}'.format(data_type=data_type))
all_files = body.get(data_type, [])
return [Wrapper(path, path=dirname(path), filename=basename(path),
selected=included_files.get(path, False),
data_type=_data_type)
for path in files]
return [Wrapper(path, path=dirname(path), filename=basename(path),
selected=included_files.get(path, False))
for path in all_files]
if data_type:
all_files.extend(get_files(data_type))
else:
# FixME: need to get list of data types directly from server
for data_type in ('ui', 'workflows', 'heat', 'agent', 'scripts'):
all_files.extend(get_files(data_type))
return all_files
def download_service(self, service):
resp, body = self.http_client.raw_request(