not failing if platform is not set
This commit is contained in:
parent
a7b965a8b5
commit
2a4f24f00a
3 changed files with 9 additions and 5 deletions
|
@ -30,6 +30,9 @@ def get_device_type(type):
|
|||
|
||||
|
||||
def get_device_platform(config):
|
||||
if config.device.platform is None:
|
||||
return None
|
||||
|
||||
device_platform = nb.dcim.platforms.get(
|
||||
name=config.device.platform
|
||||
)
|
||||
|
|
|
@ -465,10 +465,11 @@ class ServerBase():
|
|||
ret, server = self.update_netbox_location(server)
|
||||
update += ret
|
||||
|
||||
if get_device_platform(config) is not None:
|
||||
if server.platform != get_device_platform(config).name:
|
||||
if config.device.platform is not None:
|
||||
platform = get_device_platform(config)
|
||||
if server.platform != platform.name:
|
||||
update += 1
|
||||
server.platform = get_device_platform(config).id
|
||||
server.platform = platform.id
|
||||
|
||||
if update:
|
||||
server.save()
|
||||
|
|
|
@ -95,8 +95,8 @@ class VirtualMachine(object):
|
|||
vm = nb.virtualization.virtual_machines.create(
|
||||
name=hostname,
|
||||
cluster=cluster.id,
|
||||
platform=device_platform.id,
|
||||
device_platform = get_device_platform(config),
|
||||
platform=device_platform.id if device_platform is not None else None,
|
||||
device_platform=device_platform,
|
||||
vcpus=vcpus,
|
||||
memory=memory,
|
||||
tenant=tenant.id if tenant else None,
|
||||
|
|
Loading…
Reference in a new issue