mirror of
https://github.com/dkmstr/openuds.git
synced 2025-03-20 06:50:23 +03:00
Merge remote-tracking branch 'origin/v4.0'
This commit is contained in:
commit
d6518ee30c
@ -174,13 +174,17 @@ class DynamicService(services.Service, abc.ABC): # pylint: disable=too-many-pub
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_mac(
|
||||
self, caller_instance: typing.Optional['DynamicUserService | DynamicPublication'], vmid: str
|
||||
self,
|
||||
caller_instance: typing.Optional['DynamicUserService | DynamicPublication'],
|
||||
vmid: str,
|
||||
*,
|
||||
force_new: bool = False,
|
||||
) -> str:
|
||||
"""
|
||||
Returns the mac of the machine
|
||||
If cannot be obtained, MUST raise an exception
|
||||
Note:
|
||||
vmid can be '' if we are requesting a new mac (on some services, where UDS generate the machines MAC)
|
||||
vmid can be '' or force_new can be True, in this case, a new mac must be generated
|
||||
If the service does not support this, it can raise an exception
|
||||
"""
|
||||
...
|
||||
|
@ -342,7 +342,7 @@ class DynamicUserService(services.UserService, autoserializable.AutoSerializable
|
||||
# Note that get_mac is used for creating a new mac, returning the one of the vm or whatever
|
||||
# This is responsibility of the service, not of the user service
|
||||
if not self._mac:
|
||||
self._mac = self.service().get_mac(self, self._vmid) or ''
|
||||
self._mac = self.service().get_mac(self, self._vmid, force_new=True) or ''
|
||||
return self._mac
|
||||
|
||||
@typing.final
|
||||
|
@ -255,7 +255,11 @@ class OpenStackLiveService(DynamicService):
|
||||
return '' if not net_info else net_info[0].ip
|
||||
|
||||
def get_mac(
|
||||
self, caller_instance: typing.Optional['DynamicUserService | DynamicPublication'], vmid: str
|
||||
self,
|
||||
caller_instance: typing.Optional['DynamicUserService | DynamicPublication'],
|
||||
vmid: str,
|
||||
*,
|
||||
force_new: bool = False,
|
||||
) -> str:
|
||||
net_info = self.api.get_server_info(vmid).validated().addresses
|
||||
return '' if not net_info else net_info[0].mac
|
||||
|
@ -273,10 +273,14 @@ class ProxmoxServiceLinked(DynamicService):
|
||||
return self.provider().api.get_guest_ip_address(int(vmid))
|
||||
|
||||
def get_mac(
|
||||
self, caller_instance: typing.Optional['DynamicUserService | DynamicPublication'], vmid: str
|
||||
self,
|
||||
caller_instance: typing.Optional['DynamicUserService | DynamicPublication'],
|
||||
vmid: str,
|
||||
*,
|
||||
force_new: bool = False,
|
||||
) -> str:
|
||||
# If vmid is empty, we are requesting a new mac
|
||||
if not vmid:
|
||||
if not vmid or force_new:
|
||||
return self.mac_generator().get(self.get_macs_range())
|
||||
return self.provider().api.get_vm_config(int(vmid)).networks[0].macaddr.lower()
|
||||
|
||||
|
@ -320,11 +320,12 @@ class XenLinkedService(DynamicService): # pylint: disable=too-many-public-metho
|
||||
return '' # No ip will be get, UDS will assign one (from actor)
|
||||
|
||||
def get_mac(
|
||||
self, caller_instance: typing.Optional['DynamicUserService | DynamicPublication'], vmid: str
|
||||
self,
|
||||
caller_instance: typing.Optional['DynamicUserService | DynamicPublication'],
|
||||
vmid: str,
|
||||
*,
|
||||
force_new: bool = False,
|
||||
) -> str:
|
||||
"""
|
||||
For
|
||||
"""
|
||||
return self.mac_generator().get(self.provider().get_macs_range())
|
||||
|
||||
def is_running(
|
||||
|
@ -485,6 +485,8 @@ class DynamicTestingService(dynamic_service.DynamicService):
|
||||
self,
|
||||
caller_instance: typing.Optional[dynamic_userservice.DynamicUserService | dynamic_publication.DynamicPublication],
|
||||
vmid: str,
|
||||
*,
|
||||
force_new: bool = False,
|
||||
) -> str:
|
||||
self.mock.get_mac(caller_instance, vmid)
|
||||
return '02:04:06:08:0A:0C'
|
||||
@ -686,6 +688,8 @@ class DynamicTestingServiceForDeferredDeletion(dynamic_service.DynamicService):
|
||||
self,
|
||||
caller_instance: typing.Optional[dynamic_userservice.DynamicUserService | dynamic_publication.DynamicPublication],
|
||||
vmid: str,
|
||||
*,
|
||||
force_new: bool = False,
|
||||
) -> str:
|
||||
return ''
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user