Removed extra work in case of no volumes

Before the change the following actions were performed even if there
are no volumes to attach:
1. thread spawn
2. roundtrip to instance to make sure that there are 0 volumes attached
3. roundtrip to nova to get assigned volumes

Change-Id: I3f120cb5e60b2c8b2439c7f4acc7b99ce4964895
This commit is contained in:
Andrew Lazarev 2014-07-25 18:23:59 -07:00
parent 37bfd3e996
commit c507ab55e0

View File

@ -40,7 +40,9 @@ CONF.register_opt(detach_timeout_opt)
def attach_to_instances(instances): def attach_to_instances(instances):
with context.ThreadGroup() as tg: with context.ThreadGroup() as tg:
for instance in instances: for instance in instances:
tg.spawn('attach-volumes-for-instance-%s' % instance.instance_name, if instance.node_group.volumes_per_node > 0:
tg.spawn(
'attach-volumes-for-instance-%s' % instance.instance_name,
_attach_volumes_to_node, instance.node_group, instance) _attach_volumes_to_node, instance.node_group, instance)