Skip to content

Commit

Permalink
adding ibm shut down scenario
Browse files Browse the repository at this point in the history
rh-pre-commit.version: 2.2.0
rh-pre-commit.check-secrets: ENABLED

Signed-off-by: Auto User <[email protected]>
Signed-off-by: Paige Patton <[email protected]>
  • Loading branch information
paigerube14 committed Oct 9, 2024
1 parent f8534d6 commit 6489f8c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions docs/cluster_shut_down_scenarios.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Current accepted cloud types:
* [GCP](cloud_setup.md#gcp)
* [AWS](cloud_setup.md#aws)
* [Openstack](cloud_setup.md#openstack)
* [IBMCloud](cloud_setup.md#ibmcloud)


```
Expand Down
11 changes: 10 additions & 1 deletion krkn/scenario_plugins/native/node_scenarios/ibmcloud_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,16 @@ def __init__(self):
self.service.set_service_url(service_url)
except Exception as e:
logging.error("error authenticating" + str(e))
sys.exit(1)


# Get the instance ID of the node
def get_instance_id(self, node_name):
node_list = self.list_instances()
for node in node_list:
if node_name == node["vpc_name"]:
return node["vpc_id"]
logging.error("Couldn't find node with name " + str(node_name) + ", you could try another region")
sys.exit(1)

def delete_instance(self, instance_id):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,31 @@ def get_node_scenario_object(self, node_scenario, kubecli: KrknKubernetes):
global node_general
node_general = True
return general_node_scenarios(kubecli)
if node_scenario["cloud_type"] == "aws":
if node_scenario["cloud_type"].lower() == "aws":
return aws_node_scenarios(kubecli)
elif node_scenario["cloud_type"] == "gcp":
elif node_scenario["cloud_type"].lower() == "gcp":
return gcp_node_scenarios(kubecli)
elif node_scenario["cloud_type"] == "openstack":
elif node_scenario["cloud_type"].lower() == "openstack":
from krkn.scenario_plugins.node_actions.openstack_node_scenarios import (
openstack_node_scenarios,
)

return openstack_node_scenarios(kubecli)
elif (
node_scenario["cloud_type"] == "azure"
node_scenario["cloud_type"].lower() == "azure"
or node_scenario["cloud_type"] == "az"
):
return azure_node_scenarios(kubecli)
elif (
node_scenario["cloud_type"] == "alibaba"
node_scenario["cloud_type"].lower() == "alibaba"
or node_scenario["cloud_type"] == "alicloud"
):
from krkn.scenario_plugins.node_actions.alibaba_node_scenarios import (
alibaba_node_scenarios,
)

return alibaba_node_scenarios(kubecli)
elif node_scenario["cloud_type"] == "bm":
elif node_scenario["cloud_type"].lower() == "bm":
from krkn.scenario_plugins.node_actions.bm_node_scenarios import (
bm_node_scenarios,
)
Expand All @@ -99,7 +99,7 @@ def get_node_scenario_object(self, node_scenario, kubecli: KrknKubernetes):
node_scenario.get("bmc_password", None),
kubecli,
)
elif node_scenario["cloud_type"] == "docker":
elif node_scenario["cloud_type"].lower() == "docker":
return docker_node_scenarios(kubecli)
else:
logging.error(
Expand Down
3 changes: 3 additions & 0 deletions krkn/scenario_plugins/shut_down/shut_down_scenario_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from krkn.scenario_plugins.node_actions.az_node_scenarios import Azure
from krkn.scenario_plugins.node_actions.gcp_node_scenarios import GCP
from krkn.scenario_plugins.node_actions.openstack_node_scenarios import OPENSTACKCLOUD
from krkn.scenario_plugins.native.node_scenarios.ibmcloud_plugin import IbmCloud


class ShutDownScenarioPlugin(AbstractScenarioPlugin):
Expand Down Expand Up @@ -86,6 +87,8 @@ def cluster_shut_down(self, shut_down_config, kubecli: KrknKubernetes):
cloud_object = OPENSTACKCLOUD()
elif cloud_type.lower() in ["azure", "az"]:
cloud_object = Azure()
elif cloud_type.lower() in ["ibm", "ibmcloud"]:
cloud_object = IbmCloud()
else:
logging.error(
"Cloud type %s is not currently supported for cluster shut down"
Expand Down

0 comments on commit 6489f8c

Please sign in to comment.