aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/dha_adapters
diff options
context:
space:
mode:
authorJonas Bjurel <jonas.bjurel@ericsson.com>2016-04-29 17:01:32 +0000
committerGerrit Code Review <gerrit@172.30.200.206>2016-04-29 17:01:32 +0000
commitd4db56bdb5f8ecd604d3a9c6bcf91b8968ed2ff7 (patch)
treefa4503c23f20f82e6d8773d32ada321330797ec5 /deploy/dha_adapters
parentb238e8ad78b2bcc98489e1ce79741d0a635e736d (diff)
parent1fbdece8ecca78f8caea3f994307efbbe20a98ab (diff)
Merge "Add a dha adapter python file for ZTE hardware."
Diffstat (limited to 'deploy/dha_adapters')
-rw-r--r--deploy/dha_adapters/zte_adapter.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/deploy/dha_adapters/zte_adapter.py b/deploy/dha_adapters/zte_adapter.py
new file mode 100644
index 000000000..f6279fbf0
--- /dev/null
+++ b/deploy/dha_adapters/zte_adapter.py
@@ -0,0 +1,49 @@
+###############################################################################
+# Copyright (c) 2015 Ericsson AB and others.
+# szilard.cserey@ericsson.com
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+###############################################################################
+
+
+import time
+from ipmi_adapter import IpmiAdapter
+
+from common import (
+ log,
+ exec_cmd,
+ err,
+)
+
+
+class ZteAdapter(IpmiAdapter):
+
+ def __init__(self, yaml_path):
+ super(ZteAdapter, self).__init__(yaml_path)
+
+ def node_reset(self, node_id):
+ WAIT_LOOP = 600
+ log('RESET Node %s' % node_id)
+ cmd_prefix = self.ipmi_cmd(node_id)
+ state = exec_cmd('%s chassis power status' % cmd_prefix)
+ if state == 'Chassis Power is on':
+ was_shut_off = False
+ done = False
+ exec_cmd('%s chassis power cycle' % cmd_prefix)
+ for i in range(WAIT_LOOP):
+ state, _ = exec_cmd('%s chassis power status' % cmd_prefix,
+ False)
+ if state == 'Chassis Power is off':
+ was_shut_off = True
+ elif state == 'Chassis Power is on' and was_shut_off:
+ done = True
+ break
+ time.sleep(1)
+ if not done:
+ err('Could Not RESET Node %s' % node_id)
+ else:
+ err('Cannot RESET Node %s because it\'s not Active, state: %s'
+ % (node_id, state))
+