<s> import copy <EOL> import logging <EOL> from oslo_config import cfg <EOL> from cloudferry . lib . base . action import action <EOL> from cloudferry . lib . utils import utils <EOL> CONF = cfg . CONF <EOL> LOG = logging . getLogger ( __name__ ) <EOL> class DetachVolumesCompute ( action . Action ) : <EOL> def run ( self , info , ** kwargs ) : <EOL> info = copy . deepcopy ( info ) <EOL> compute_resource = self . cloud . resources [ utils . COMPUTE_RESOURCE ] <EOL> storage_resource = self . cloud . resources [ utils . STORAGE_RESOURCE ] <EOL> for instance in info [ utils . INSTANCES_TYPE ] . itervalues ( ) : <EOL> LOG . info ( "<STR_LIT>" , <EOL> instance [ '<STR_LIT>' ] [ '<STR_LIT:name>' ] , instance [ '<STR_LIT>' ] [ '<STR_LIT:id>' ] ) <EOL> if not instance [ '<STR_LIT>' ] [ utils . VOLUMES_TYPE ] : <EOL> continue <EOL> for vol in instance [ '<STR_LIT>' ] [ utils . VOLUMES_TYPE ] : <EOL> volume_status = storage_resource . get_status ( vol [ '<STR_LIT:id>' ] ) <EOL> LOG . debug ( "<STR_LIT>" , <EOL> vol [ '<STR_LIT:id>' ] , volume_status ) <EOL> if volume_status == '<STR_LIT>' : <EOL> compute_resource . detach_volume ( instance [ '<STR_LIT>' ] [ '<STR_LIT:id>' ] , <EOL> vol [ '<STR_LIT:id>' ] ) <EOL> LOG . debug ( "<STR_LIT>" , vol [ '<STR_LIT:id>' ] ) <EOL> timeout = CONF . migrate . storage_backend_timeout <EOL> storage_resource . wait_for_status ( <EOL> vol [ '<STR_LIT:id>' ] , storage_resource . get_status , '<STR_LIT>' , <EOL> timeout = timeout ) <EOL> return { } </s>
