Skip to content

Commit

Permalink
nixops backup-status: Show snapshot IDs
Browse files Browse the repository at this point in the history
And some bugfixes.
  • Loading branch information
edolstra committed Nov 8, 2013
1 parent 44c3f39 commit b6b3955
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
16 changes: 8 additions & 8 deletions nixops/backends/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,21 +331,22 @@ def get_backups(self):
info = []
for k, v in self.block_device_mapping.items():
if not k in b.keys():
backup_complete = False
info.append("{0} - {1} - Not available in backup".format(self.name, k))
backup_status = "incomplete"
info.append("{0} - {1} - Not available in backup".format(self.name, _sd_to_xvd(k)))
else:
snapshot_id = b[k]
try:
snapshot = self._get_snapshot_by_id(snapshot_id)
snapshot_status = snapshot.update()
info.append("progress[{0},{1},{2}] = {3}".format(self.name, _sd_to_xvd(k), snapshot_id, snapshot_status))
if snapshot_status != '100%':
info.append("progress[{0},{1},{2}] = {3}%.".format(self.name, k, snapshot_id, snapshot_status))
backup_status = "running"
except:
info.append("{0} - {1} - {2} - Snapshot has disappeared".format(self.name, k, snapshot_id))
except boto.exception.EC2ResponseError as e:
if e.error_code != "InvalidSnapshot.NotFound": raise
info.append("{0} - {1} - {2} - Snapshot has disappeared".format(self.name, _sd_to_xvd(k), snapshot_id))
backup_status = "unavailable"
backups[b_id]['status'] = backup_status
backups[b_id]['info'] = info
backups[b_id]['status'] = backup_status
backups[b_id]['info'] = info
return backups


Expand Down Expand Up @@ -385,7 +386,6 @@ def backup(self, defn, backup_id):
snapshot = nixops.ec2_utils.retry(lambda: self._conn.create_snapshot(volume_id=v['volumeId']))
self.log("+ created snapshot of volume ‘{0}’: ‘{1}’".format(v['volumeId'], snapshot.id))


snapshot_tags = {}
snapshot_tags.update(defn.tags)
snapshot_tags.update(self.get_common_tags())
Expand Down
5 changes: 1 addition & 4 deletions scripts/nixops
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,7 @@ def op_check():
def print_backups(depl, backups):
tbl = prettytable.PrettyTable(["Backup ID", "Status", "Info"])
for k, v in sorted(backups.items(), reverse=True):
fst = v['info'][0] if len(v['info']) > 0 else ""
tbl.add_row([k,v['status'], fst])
for i in v['info'][1:]:
tbl.add_row(["", "", i])
tbl.add_row([k,v['status'], "\n".join(v['info'])])
print tbl


Expand Down

0 comments on commit b6b3955

Please sign in to comment.