import jingrow


def execute():
	jingrow.reload_pg("jcloud", "pagetype", "virtual_machine_volume")
	jingrow.reload_pg("jcloud", "pagetype", "virtual_machine")

	for machine in jingrow.get_all("Virtual Machine", pluck="name"):
		machine = jingrow.get_pg("Virtual Machine", machine)
		for volume in machine.get_volumes():
			row = {
				"volume_id": volume["VolumeId"],
				"volume_type": volume["VolumeType"],
				"size": volume["Size"],
				"iops": volume["Iops"],
			}
			if "Throughput" in volume:
				row["throughput"] = volume["Throughput"]

			machine.append("volumes", row)
		machine.save()
