Coverage for watcher/common/metal_helper/factory.py: 93%

11 statements  

« prev     ^ index     » next       coverage.py v7.8.2, created at 2025-06-17 12:22 +0000

1# Copyright 2023 Cloudbase Solutions 

2# All Rights Reserved. 

3# 

4# Licensed under the Apache License, Version 2.0 (the "License"); you may 

5# not use this file except in compliance with the License. You may obtain 

6# a copy of the License at 

7# 

8# http://www.apache.org/licenses/LICENSE-2.0 

9# 

10# Unless required by applicable law or agreed to in writing, software 

11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 

12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 

13# License for the specific language governing permissions and limitations 

14# under the License. 

15 

16from oslo_config import cfg 

17 

18from watcher.common import clients 

19from watcher.common.metal_helper import ironic 

20from watcher.common.metal_helper import maas 

21 

22CONF = cfg.CONF 

23 

24 

25def get_helper(osc=None): 

26 # TODO(lpetrut): consider caching this client. 

27 if not osc: 27 ↛ 30line 27 didn't jump to line 30 because the condition on line 27 was always true

28 osc = clients.OpenStackClients() 

29 

30 if CONF.maas_client.url: 

31 return maas.MaasHelper(osc) 

32 else: 

33 return ironic.IronicHelper(osc)