Skip to content

Commit

Permalink
Merge pull request #94 from victormlg/CFE-4451
Browse files Browse the repository at this point in the history
Added date highlight in show command
  • Loading branch information
olehermanse authored Dec 9, 2024
2 parents dba4aee + 609bd9d commit 4abb7e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cf_remote/commands.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
import os
import sys
import time
Expand Down Expand Up @@ -606,7 +607,8 @@ def save(name, hosts, role):
if "@" + name in state:
print("Group '{}' already exists".format(name))
return 1
group = {"meta": {"saved": True}}
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:
Expand Down Expand Up @@ -734,6 +736,9 @@ def show(ansible_inventory):
del group["meta"]
if "region" in meta and "provider" in meta:
extra = " in {}, {}".format(meta["region"], meta["provider"])
if "date" in meta :
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
Expand Down
4 changes: 3 additions & 1 deletion cf_remote/spawn.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
import string
import random
from collections import namedtuple
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 4abb7e4

Please sign in to comment.