Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Start and Stop options #360

Merged
merged 2 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions lib/muchos/ec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,30 @@ def print_nodes(nodes):
node.get("PublicIpAddress", ""),
)

def stop(self):
nodes = self.active_nodes()
print(
"The following {0} nodes in {1} cluster "
"will be stopped:".format(len(nodes), self.config.cluster_name)
)
ec2 = boto3.client("ec2")
for node in nodes:
ec2.stop_instances(InstanceIds=[node["InstanceId"]])
self.print_nodes(nodes)
print("Stopped nodes.")

def start(self):
nodes = self.active_nodes()
print(
"The following {0} nodes in {1} cluster "
"will be started:".format(len(nodes), self.config.cluster_name)
)
ec2 = boto3.client("ec2")
for node in nodes:
ec2.start_instances(InstanceIds=[node["InstanceId"]])
self.print_nodes(nodes)
print("Started nodes.")

def terminate(self):
nodes = self.active_nodes()
print(
Expand Down
18 changes: 18 additions & 0 deletions lib/muchos/existing.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,20 @@ def terminate():
"when cluster_type is set to 'existing'"
)

@staticmethod
def stop():
exit(
"ERROR - 'stop' command cannot be used "
"when cluster_type is set to 'existing'"
)

@staticmethod
def start():
exit(
"ERROR - 'start' command cannot be used "
"when cluster_type is set to 'existing'"
)

def ssh(self):
self.wait_until_proxy_ready()
fwd = ""
Expand Down Expand Up @@ -352,6 +366,10 @@ def perform(self, action):
self.sync()
elif action == "setup":
self.setup()
elif action == "start":
self.start()
elif action == "stop":
self.stop()
elif action == "ssh":
self.ssh()
elif action == "wipe":
Expand Down
2 changes: 2 additions & 0 deletions lib/muchos/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def parse_args(hosts_dir, input_args=None):
+ " sync Sync ansible directory on cluster proxy node\n"
+ " config Print configuration for that cluster. "
"Requires '-p'. Use '-p all' for all config.\n"
+ " stop Stops instance\n"
+ " start Starts instance\n"
+ " ssh SSH to cluster proxy node\n"
+ " kill Kills processes on cluster started by Muchos\n"
+ " wipe Wipes cluster data and kills processes\n"
Expand Down