Skip to content

Commit 0e68ded

Browse files
authored
adding ibm shut down scenario (#697)
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]>
1 parent 34a676a commit 0e68ded

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

docs/cluster_shut_down_scenarios.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Current accepted cloud types:
88
* [GCP](cloud_setup.md#gcp)
99
* [AWS](cloud_setup.md#aws)
1010
* [Openstack](cloud_setup.md#openstack)
11+
* [IBMCloud](cloud_setup.md#ibmcloud)
1112

1213

1314
```

krkn/scenario_plugins/native/node_scenarios/ibmcloud_plugin.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,16 @@ def __init__(self):
3434
self.service.set_service_url(service_url)
3535
except Exception as e:
3636
logging.error("error authenticating" + str(e))
37-
sys.exit(1)
37+
38+
39+
# Get the instance ID of the node
40+
def get_instance_id(self, node_name):
41+
node_list = self.list_instances()
42+
for node in node_list:
43+
if node_name == node["vpc_name"]:
44+
return node["vpc_id"]
45+
logging.error("Couldn't find node with name " + str(node_name) + ", you could try another region")
46+
sys.exit(1)
3847

3948
def delete_instance(self, instance_id):
4049
"""

krkn/scenario_plugins/node_actions/node_actions_scenario_plugin.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,31 +64,31 @@ def get_node_scenario_object(self, node_scenario, kubecli: KrknKubernetes):
6464
global node_general
6565
node_general = True
6666
return general_node_scenarios(kubecli)
67-
if node_scenario["cloud_type"] == "aws":
67+
if node_scenario["cloud_type"].lower() == "aws":
6868
return aws_node_scenarios(kubecli)
69-
elif node_scenario["cloud_type"] == "gcp":
69+
elif node_scenario["cloud_type"].lower() == "gcp":
7070
return gcp_node_scenarios(kubecli)
71-
elif node_scenario["cloud_type"] == "openstack":
71+
elif node_scenario["cloud_type"].lower() == "openstack":
7272
from krkn.scenario_plugins.node_actions.openstack_node_scenarios import (
7373
openstack_node_scenarios,
7474
)
7575

7676
return openstack_node_scenarios(kubecli)
7777
elif (
78-
node_scenario["cloud_type"] == "azure"
78+
node_scenario["cloud_type"].lower() == "azure"
7979
or node_scenario["cloud_type"] == "az"
8080
):
8181
return azure_node_scenarios(kubecli)
8282
elif (
83-
node_scenario["cloud_type"] == "alibaba"
83+
node_scenario["cloud_type"].lower() == "alibaba"
8484
or node_scenario["cloud_type"] == "alicloud"
8585
):
8686
from krkn.scenario_plugins.node_actions.alibaba_node_scenarios import (
8787
alibaba_node_scenarios,
8888
)
8989

9090
return alibaba_node_scenarios(kubecli)
91-
elif node_scenario["cloud_type"] == "bm":
91+
elif node_scenario["cloud_type"].lower() == "bm":
9292
from krkn.scenario_plugins.node_actions.bm_node_scenarios import (
9393
bm_node_scenarios,
9494
)
@@ -99,7 +99,7 @@ def get_node_scenario_object(self, node_scenario, kubecli: KrknKubernetes):
9999
node_scenario.get("bmc_password", None),
100100
kubecli,
101101
)
102-
elif node_scenario["cloud_type"] == "docker":
102+
elif node_scenario["cloud_type"].lower() == "docker":
103103
return docker_node_scenarios(kubecli)
104104
else:
105105
logging.error(

krkn/scenario_plugins/shut_down/shut_down_scenario_plugin.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from krkn.scenario_plugins.node_actions.az_node_scenarios import Azure
1414
from krkn.scenario_plugins.node_actions.gcp_node_scenarios import GCP
1515
from krkn.scenario_plugins.node_actions.openstack_node_scenarios import OPENSTACKCLOUD
16+
from krkn.scenario_plugins.native.node_scenarios.ibmcloud_plugin import IbmCloud
1617

1718

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

0 commit comments

Comments
 (0)