def cli_reset(): check_cli_ip("/api/cli/reset") return None for instanceid, instance in Instance.objects().items(): instance.cheapskate["grp"] = "1" Instance.save_all() return "Instances reset"
def cli_shutdown(): check_cli_ip("/api/cli/shutdown") result = {} instances = json.load(open("shutdown_due.json")) if len(instances) == 0: return "No shutdowns required" for instance in instances: result[instance["id"]] = Instance.objects()[instance["id"]].shutdown() return result
def ec2_instance_update(instance_id): instance = Instance.objects()[instance_id] hours = request.forms.get("hours") user = request.headers.get("Remote-User") instance.update(user=user, hours=int(hours)) return json.dumps(instance.as_dict())
def ec2_instance(instance_id): return Instance.objects()[instance_id].as_dict()
def ec2_tag_volumes(instance_id, tagname): check_cli_ip("/api/tag") Instance.objects()[instance_id].update_volume_tags(tagname) return "All instance voluems updated"
def ec2_tag_instance(instance_id, tag, name): check_cli_ip("/api/tag") return Instance.objects()[instance_id].tag_instance(tag, name)
def ec2_instance_update(instance_id): instance = Instance.objects()[instance_id] hours = request.forms.get("hours") user = request.headers.get("Remote-User") instance.update(user=user, hours=int(hours)) return json.dumps(instance.__dict__())
def ec2_instance(instance_id): return Instance.objects()[instance_id].__dict__()