Skip to content

Commit 998cf76

Browse files
committed
ideas: Started implementing
Signed-off-by: Victor Moene <victor.moene@northern.tech>
1 parent a0c3ce7 commit 998cf76

File tree

5 files changed

+525
-0
lines changed

5 files changed

+525
-0
lines changed

cf_remote/commands.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,3 +1054,34 @@ def connect_cmd(hosts):
10541054
print("")
10551055
log.error("The ssh command exited with error code " + str(r.returncode))
10561056
return r.returncode
1057+
1058+
1059+
import yaml
1060+
from cf_remote.config import validate_config, generate_tasks, schedule_tasks
1061+
1062+
1063+
def up_command(config_path):
1064+
content = None
1065+
try:
1066+
with open(config_path, "r") as f:
1067+
content = yaml.safe_load(f)
1068+
except yaml.YAMLError:
1069+
raise CFRUserError("'%s' is not a valid YAML file" % config_path)
1070+
except FileNotFoundError as e:
1071+
raise CFRUserError("'%s' doesn't exist" % config_path)
1072+
1073+
print("Loading '%s'..." % config_path)
1074+
# 1. Validate config
1075+
new_state = validate_config(content)
1076+
1077+
# 2. Compare old config to new config
1078+
print("Checking current state...")
1079+
current_state = read_json(CLOUD_STATE_FPATH)
1080+
current_state = {}
1081+
tasks = generate_tasks(current_state, new_state)
1082+
1083+
# 3. apply changes
1084+
schedule_tasks(current_state, tasks)
1085+
1086+
print("Details about the spawned VMs can be found in %s" % CLOUD_STATE_FPATH)
1087+
return 0

0 commit comments

Comments
 (0)