Skip to content

Commit

Permalink
Added dato highlight for spawn and fixed code
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Moene <[email protected]>
  • Loading branch information
victormlg committed Dec 9, 2024
1 parent b1c1561 commit 609bd9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions cf_remote/commands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime, timezone
from datetime import datetime
import os
import sys
import time
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
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 609bd9d

Please sign in to comment.