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

IBM Cloud node stop and start added #10707

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
22 changes: 22 additions & 0 deletions ocs_ci/ocs/platform_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2744,6 +2744,28 @@ def __init__(self):
super(IBMCloud, self).__init__()
self.ibmcloud = ibmcloud.IBMCloud()

def stop_nodes(self, nodes, wait=True):
"""
Stop nodes on IBM Cloud

Args:
nodes (list): The OCS objects of the nodes
wait (bool): True for waiting the instances to stop, False otherwise

"""
self.ibmcloud.start_nodes(nodes, wait=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be stop_nodes ?

Suggested change
self.ibmcloud.start_nodes(nodes, wait=True)
self.ibmcloud.stop_nodes(nodes, wait=True)


def start_nodes(self, nodes, wait=True):
"""
Start nodes on IBM Cloud

Args:
nodes (list): The OCS objects of the nodes
wait (bool): True for waiting the instances to start, False otherwise

"""
self.ibmcloud.start_nodes(nodes, wait=True)

def restart_nodes(self, nodes, timeout=900, wait=True):
"""
Restart all the ibmcloud vm instances
Expand Down
47 changes: 47 additions & 0 deletions ocs_ci/utility/ibmcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
NodeHasNoAttachedVolume,
TimeoutExpiredError,
)
from ocs_ci.ocs.node import wait_for_nodes_status
from ocs_ci.ocs.resources.ocs import OCS
from ocs_ci.utility import version as util_version
from ocs_ci.utility.utils import get_infra_id, get_ocp_version, run_cmd, TimeoutSampler
Expand Down Expand Up @@ -337,6 +338,52 @@ class IBMCloud(object):
Wrapper for Ibm Cloud
"""

def start_nodes(self, nodes, wait=True):
"""
Start nodes on IBM Cloud.

Args:
nodes (list): The OCS objects of the nodes
wait (bool): True for waiting the instances to start, False otherwise
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add Raises section mention: ValueError there as this is one you raises in some cases ;)


"""
if not nodes:
raise ValueError("No nodes found to start")

node_names = [n.name for n in nodes]
self.ibmcloud.restart_nodes(nodes)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.ibmcloud.restart_nodes(nodes)
self.restart_nodes(nodes)

Did you forgot to remove ibmcloud here?


if wait:
# When the node is reachable then the node reaches status Ready.
logger.info(f"Waiting for nodes: {node_names} to reach ready state")
wait_for_nodes_status(
node_names=node_names, status=constants.NODE_READY, timeout=180, sleep=5
)

def stop_nodes(self, nodes, wait=True):
"""
Stop nodes on IBM Cloud

Args:
nodes (list): The OCS objects of the nodes
wait (bool): True for waiting the instances to stop, False otherwise

"""
if not nodes:
raise ValueError("No nodes found to stop")

cmd = "oc debug node/{} -- chroot /host shutdown"
node_names = [n.name for n in nodes]
for node in node_names:
run_cmd(cmd.format(node))

if wait:
# When the node is reachable then the node reaches status Ready.
logger.info(f"Waiting for nodes: {node_names} to reach not ready state")
wait_for_nodes_status(
node_names, constants.NODE_NOT_READY, timeout=180, sleep=5
)

def restart_nodes(self, nodes, timeout=900, wait=True):
"""
Reboot the nodes on IBM Cloud.
Expand Down
Loading