vitual_fuel: set_vm_nic() takes no parameters
[fuel.git] / deploy / dha_adapters / zte_adapter.py
1 ###############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 # szilard.cserey@ericsson.com
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ###############################################################################
9
10
11 import time
12 from ipmi_adapter import IpmiAdapter
13
14 from common import (
15     log,
16     exec_cmd,
17     err,
18 )
19
20
21 class ZteAdapter(IpmiAdapter):
22
23     def __init__(self, yaml_path):
24         super(ZteAdapter, self).__init__(yaml_path)
25
26     def node_reset(self, node_id):
27         WAIT_LOOP = 600
28         log('RESET Node %s' % node_id)
29         cmd_prefix = self.ipmi_cmd(node_id)
30         state = exec_cmd('%s chassis power status' % cmd_prefix, mask_args=[8,10])
31         if state == 'Chassis Power is on':
32             was_shut_off = False
33             done = False
34             exec_cmd('%s chassis power cycle' % cmd_prefix, mask_args=[8,10])
35             for i in range(WAIT_LOOP):
36                 state, _ = exec_cmd('%s chassis power status' % cmd_prefix,
37                                     check=False,
38                                     mask_args=[8,10])
39                 if state == 'Chassis Power is off':
40                     was_shut_off = True
41                 elif state == 'Chassis Power is on' and was_shut_off:
42                     done = True
43                     break
44                 time.sleep(1)
45             if not done:
46                 err('Could Not RESET Node %s' % node_id)
47         else:
48             err('Cannot RESET Node %s because it\'s not Active, state: %s'
49                 % (node_id, state))
50