Permalink
Browse files

Fix a bug in the ag agent when trying to convert a drives while the V…

…M is not defined or does not have any drives attached.
  • Loading branch information...
primalmotion committed Mar 19, 2013
1 parent dd6e3e1 commit 25af056a5c6d6b6256dba1e8cdb0806a01cff697
@@ -291,15 +291,16 @@ def iq_convert(self, iq):
if not ret == 0:
raise Exception("DriveError", "Unable to convert drive. Error code is " + str(ret))
os.unlink(path)
- for drive in self.entity.definition.getTag("devices").getTags("disk"):
- if drive.getTag("source"):
- if drive.getTag("source").getAttr("file") == path:
- if drive.getTag("driver"):
- drive.getTag("driver").setAttr("type", format)
- if drive.getTag("source"):
- drive.getTag("source").setAttr("file", disk_path)
- self.entity.define(self.entity.definition)
- break
+ if self.entity.definition and self.entity.definition.getTag("devices"):
+ for drive in self.entity.definition.getTag("devices").getTags("disk"):
+ if drive.getTag("source"):
+ if drive.getTag("source").getAttr("file") == path:
+ if drive.getTag("driver"):
+ drive.getTag("driver").setAttr("type", format)
+ if drive.getTag("source"):
+ drive.getTag("source").setAttr("file", disk_path)
+ self.entity.define(self.entity.definition)
+ break
self.entity.change_presence(presence_show=old_show, presence_status=old_status)
reply = iq.buildReply("result")
self.entity.log.info("Disk as been converted from %s to %s" % (path, disk_path))

0 comments on commit 25af056

Please sign in to comment.