Coverage for manila/tests/fake_compute.py: 73%

48 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2026-02-18 22:19 +0000

1# Copyright 2013 OpenStack Foundation 

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 

16 

17from oslo_config import cfg 

18 

19CONF = cfg.CONF 

20 

21 

22class FakeServer(object): 

23 def __init__(self, **kwargs): 

24 self.id = kwargs.pop('id', 'fake_id') 

25 self.status = kwargs.pop('status', 'ACTIVE') 

26 self.networks = kwargs.pop('networks', {'fake_net': 'fake_net_value'}) 

27 for key, value in kwargs.items(): 

28 setattr(self, key, value) 

29 

30 def __getitem__(self, attr): 

31 return getattr(self, attr) 

32 

33 def __setitem__(self, attr, value): 

34 setattr(self, attr, value) 

35 

36 def get(self, attr, default): 

37 return getattr(self, attr, default) 

38 

39 def update(self, *args, **kwargs): 

40 pass 

41 

42 

43class FakeKeypair(object): 

44 def __init__(self, **kwargs): 

45 self.id = kwargs.pop('id', 'fake_keypair_id') 

46 self.name = None 

47 for key, value in kwargs.items(): 

48 setattr(self, key, value) 

49 

50 

51class API(object): 

52 """Fake Compute API.""" 

53 def instance_volume_attach(self, ctx, server_id, volume_id, mount_path): 

54 pass 

55 

56 def instance_volume_detach(self, ctx, server_id, volume_id): 

57 pass 

58 

59 def instance_volumes_list(self, ctx, server_id): 

60 pass 

61 

62 def server_create(self, *args, **kwargs): 

63 pass 

64 

65 def server_delete(self, *args, **kwargs): 

66 pass 

67 

68 def server_get(self, *args, **kwargs): 

69 pass 

70 

71 def server_get_by_name_or_id(self, *args, **kwargs): 

72 pass 

73 

74 def server_reboot(self, *args, **kwargs): 

75 pass 

76 

77 def keypair_list(self, *args, **kwargs): 

78 pass 

79 

80 def keypair_import(self, *args, **kwargs): 

81 pass 

82 

83 def keypair_delete(self, *args, **kwargs): 

84 pass 

85 

86 def add_security_group_to_server(self, *args, **kwargs): 

87 pass