if "volume_id" in attachment and attachment["volume_id"] == self.id:
return attachment["device"]
return ""
After Change
attachment_list = json.loads(volume["attachments"])
if not attachment_list:
raise errors.Error("Cannot determine volume %s attachments" % self.name)
for attachment in attachment_list:
if "volume_id" in attachment and attachment["volume_id"] == self.id:
return attachment["device"]