diff --git a/cf_remote/commands.py b/cf_remote/commands.py index b0336a5..60e76fc 100644 --- a/cf_remote/commands.py +++ b/cf_remote/commands.py @@ -1,4 +1,4 @@ -from datetime import datetime, timezone +from datetime import datetime import os import sys import time @@ -607,8 +607,8 @@ def save(name, hosts, role): if "@" + name in state: print("Group '{}' already exists".format(name)) return 1 - current_time = datetime.now(timezone.utc) - group = {"meta": {"saved": True, "date": current_time.strftime("%y-%m-%dT%H:%M:%S%z")}} + current_time = datetime.now().astimezone().replace(microsecond=0).isoformat() + group = {"meta": {"saved": True, "date": current_time}} for index, host in enumerate(hosts): split = host.split("@") if len(split) != 2: @@ -737,7 +737,8 @@ def show(ansible_inventory): if "region" in meta and "provider" in meta: extra = " in {}, {}".format(meta["region"], meta["provider"]) if "date" in meta : - extra += ", added {}".format(meta["date"]) + added = "saved" if "saved" in meta and meta["saved"] else "spawned" + extra += ", {} {}".format(added, meta["date"]) print( "{}: ({} host{}{})".format( group_name, len(group), "s" if len(group) > 1 else "", extra diff --git a/cf_remote/spawn.py b/cf_remote/spawn.py index e24e223..7de6d4a 100644 --- a/cf_remote/spawn.py +++ b/cf_remote/spawn.py @@ -1,3 +1,4 @@ +from datetime import datetime import string import random from collections import namedtuple @@ -587,7 +588,8 @@ def destroy_vms(vms): def dump_vms_info(vms): - ret = {"meta": {}} + current_time = datetime.now().astimezone().replace(microsecond=0).isoformat() + ret = {"meta": {"date": current_time}} duplicate_info_keys = [] providers = {vm.provider for vm in vms} if len(providers) == 1: