Fix some bugs in client.py

Change-Id: I4024ea4b8aaf04e00c180fc2510c3f3fe12033b5
This commit is contained in:
Xicheng Chang 2015-04-15 16:35:43 -07:00
parent 79c84568c1
commit 625b8264a7

View File

@ -392,9 +392,14 @@ def _get_adapter(client):
flavor_id = flavor['id'] flavor_id = flavor['id']
break break
if adapter_name and adapter['name'] == adapter_name: if adapter_name:
adapter_id = adapter['id'] if adapter['name'] == adapter_name:
logging.info('adapter name %s matches: %s', adapter_name, adapter) adapter_id = adapter['id']
logging.info('adapter name %s matches: %s',
adapter_name, adapter)
else:
logging.info('adapter name %s does not match %s',
adapter_name, adapter)
elif ( elif (
'distributed_system_name' in item and 'distributed_system_name' in item and
adapter['distributed_system_name'] adapter['distributed_system_name']
@ -404,17 +409,30 @@ def _get_adapter(client):
target_system_re.match(adapter['distributed_system_name']) target_system_re.match(adapter['distributed_system_name'])
): ):
adapter_id = adapter['id'] adapter_id = adapter['id']
distributed_system_id = adapter['distributed_system_id']
logging.info( logging.info(
'distributed system name pattern %s matches: %s', 'distributed system name pattern %s matches: %s',
target_system_pattern, adapter target_system_pattern, adapter
) )
else:
logging.info(
'distributed system name pattern %s does not match: %s',
target_system_pattern, adapter
)
else: else:
if not target_system_re: if not target_system_re:
adapter_id = adapter['id'] adapter_id = adapter['id']
logging.info( logging.info(
'os only adapter matches no target_system_pattern' 'os only adapter matches no target_system_pattern'
) )
else:
logging.info(
'distributed system name pattern defined '
'but the adapter does not have '
'distributed_system_name attributes'
)
if adapter_id and target_system_re:
distributed_system_id = adapter['distributed_system_id']
if adapter_id: if adapter_id:
logging.info('adadpter matches: %s', adapter) logging.info('adadpter matches: %s', adapter)
@ -429,7 +447,7 @@ def _get_adapter(client):
raise Exception(msg) raise Exception(msg)
if target_system_re and not distributed_system_id: if target_system_re and not distributed_system_id:
msg = 'no distributed system found for' % target_system_pattern msg = 'no distributed system found for %s' % target_system_pattern
raise Exception(msg) raise Exception(msg)
if flavor_re and not flavor_id: if flavor_re and not flavor_id:
@ -1039,6 +1057,7 @@ def main():
machines = _poll_switches(client) machines = _poll_switches(client)
else: else:
machines = _get_machines(client) machines = _get_machines(client)
logging.info('machines are %s', machines)
subnet_mapping = _add_subnets(client) subnet_mapping = _add_subnets(client)
adapter_id, os_id, distributed_system_id, flavor_id = _get_adapter(client) adapter_id, os_id, distributed_system_id, flavor_id = _get_adapter(client)
cluster_id, host_mapping, role_mapping = _add_cluster( cluster_id, host_mapping, role_mapping = _add_cluster(