3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 import hw_detector.hw_utils as hw_utils
17 def get_local_hw_type():
18 return hw_utils.get_type()
20 def get_hw_type(ipmi_addr, ipmi_user, ipmi_pass, detect_virtual=True):
21 return hw_utils.get_type(ipmi_addr, ipmi_user, ipmi_pass, detect_virtual)
23 def get_os_hd(hw_type):
24 return hw_utils.os_hd(hw_type)
26 def get_hd_with_usage(hw_type, hd_type):
27 return hw_utils.hd_with_type(hw_type, hd_type)
29 def get_local_os_hd():
30 return get_os_hd(get_local_hw_type())
32 def get_local_osd_hd():
33 return get_hd_with_usage(get_local_hw_type(), 'osd')
35 def get_remote_os_hd(ipmi_addr, ipmi_user, ipmi_pass, detect_virtual=True):
36 return get_os_hd(get_hw_type(ipmi_addr, ipmi_user, ipmi_pass, detect_virtual))
38 def get_vendor(hw_type):
39 return hw_utils.get_vendor(hw_type)
41 def get_product_family(hw_type):
42 return hw_utils.get_product_family(hw_type)
44 def _populate_data(hw_type, data_source, ipmi_addr=None, ipmi_user=None, ipmi_pass=None, detect_virtual=True):
46 data['hw_type'] = hw_type
47 data['os_hd'] = get_os_hd(hw_type)
48 data['osd_hd'] = get_hd_with_usage(hw_type, 'osd')
49 data['vendor'] = get_vendor(hw_type)
50 data['product_family'] = get_product_family(hw_type)
51 data['info'] = hw_utils.get_info(ipmi_addr, ipmi_user, ipmi_pass, detect_virtual)
52 data['data_source'] = data_source
53 if data_source == 'remote':
54 data['ipmi_addr'] = ipmi_addr
55 data['ipmi_user'] = ipmi_user
56 data['ipmi_pass'] = ipmi_pass
59 def get_local_hw_data():
60 hw_type = get_local_hw_type()
61 return _populate_data(hw_type, 'local')
63 def get_hw_data(ipmi_addr, ipmi_user, ipmi_pass, detect_virtual=True):
64 hw_type = get_hw_type(ipmi_addr, ipmi_user, ipmi_pass, detect_virtual)
65 return _populate_data(hw_type, 'remote', ipmi_addr, ipmi_user, ipmi_pass, detect_virtual)