Skip to content

Commit c34bce5

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 21416f5 commit c34bce5

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

lib/basevm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def all_vdis_on_host(self, host):
8888
def all_vdis_on_sr(self, sr) -> bool:
8989
return all(self.host.pool.get_vdi_sr_uuid(vdi_uuid) == sr.uuid for vdi_uuid in self.vdi_uuids())
9090

91-
def get_sr(self):
91+
def get_sr(self) -> SR:
9292
# in this method we assume the SR of the first VDI is the VM SR
9393
vdis = self.vdi_uuids()
9494
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
@@ -673,8 +673,13 @@ def main_sr_uuid(self):
673673
def hostname(self):
674674
return self.ssh(['hostname'])
675675

676-
def call_plugin(self, plugin_name, function, args=None):
677-
params = {'host-uuid': self.uuid, 'plugin': plugin_name, 'fn': function}
676+
def call_plugin(self, plugin_name: str, function: str,
677+
args: Optional[Dict[str, str]] = None) -> str:
678+
params: Dict[str, Union[str, bool]] = {
679+
'host-uuid': self.uuid,
680+
'plugin': plugin_name,
681+
'fn': function
682+
}
678683
if args is not None:
679684
for k, v in args.items():
680685
params['args:%s' % k] = v

lib/pool.py

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

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

124124
def get_iso_sr(self):

lib/vm.py

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

365-
def is_running_on_host(self, host):
365+
def is_running_on_host(self, host: Host) -> bool:
366366
return self.is_running() and self.param_get('resident-on') == host.uuid
367367

368-
def get_residence_host(self):
368+
def get_residence_host(self) -> Host:
369369
assert self.is_running()
370370
host_uuid = self.param_get('resident-on')
371371
return self.host.pool.get_host_by_uuid(host_uuid)

0 commit comments

Comments
 (0)