Skip to content

Commit 8ea7643

Browse files
committed
lib: Add some types
.. for functions that are going to be used by test_plugin_nfs_on_on_slave(). Signed-off-by: Anthony PERARD <[email protected]>
1 parent b873582 commit 8ea7643

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

lib/basevm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22

3-
from typing import Any, Literal, Optional, overload, TYPE_CHECKING
3+
from typing import Any, List, Literal, Optional, overload, TYPE_CHECKING
44

55
import lib.commands as commands
66
if TYPE_CHECKING:
@@ -60,7 +60,7 @@ def name(self) -> str:
6060
def _disk_list(self):
6161
raise NotImplementedError()
6262

63-
def vdi_uuids(self, sr_uuid=None):
63+
def vdi_uuids(self, sr_uuid: Optional[str] = None) -> List[str]:
6464
output = self._disk_list()
6565
if output == '':
6666
return []
@@ -92,7 +92,7 @@ def all_vdis_on_sr(self, sr) -> bool:
9292
return False
9393
return True
9494

95-
def get_sr(self):
95+
def get_sr(self) -> SR:
9696
# in this method we assume the SR of the first VDI is the VM SR
9797
vdis = self.vdi_uuids()
9898
assert len(vdis) > 0, "Don't ask for the SR of a VM without VDIs!"

lib/host.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,13 @@ def main_sr_uuid(self):
649649
def hostname(self):
650650
return self.ssh(['hostname'])
651651

652-
def call_plugin(self, plugin_name, function, args=None):
653-
params = {'host-uuid': self.uuid, 'plugin': plugin_name, 'fn': function}
652+
def call_plugin(self, plugin_name: str, function: str,
653+
args: Optional[Dict[str, Union[str, bool]]] = None) -> str:
654+
params: Dict[str, Union[str, bool]] = {
655+
'host-uuid': self.uuid,
656+
'plugin': plugin_name,
657+
'fn': function
658+
}
654659
if args is not None:
655660
for k, v in args.items():
656661
params['args:%s' % k] = v

lib/pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def first_shared_sr(self) -> Optional[SR]:
117117
return SR(uuids[0], self)
118118
return None
119119

120-
def get_vdi_sr_uuid(self, vdi_uuid):
120+
def get_vdi_sr_uuid(self, vdi_uuid: str) -> str:
121121
return self.master.xe('vdi-param-get', {'uuid': vdi_uuid, 'param-name': 'sr-uuid'})
122122

123123
def get_iso_sr(self):

lib/vm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,10 @@ def create_vif(self, vif_num, *, network_uuid=None, network_name=None):
298298
'network-uuid': network_uuid,
299299
})
300300

301-
def is_running_on_host(self, host):
301+
def is_running_on_host(self, host: Host) -> bool:
302302
return self.is_running() and self.param_get('resident-on') == host.uuid
303303

304-
def get_residence_host(self):
304+
def get_residence_host(self) -> Host:
305305
assert self.is_running()
306306
host_uuid = self.param_get('resident-on')
307307
return self.host.pool.get_host_by_uuid(host_uuid)

0 commit comments

Comments
 (0)