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):
|
def get_device_platform(config):
|
||||||
|
if config.device.platform is None:
|
||||||
|
return None
|
||||||
|
|
||||||
device_platform = nb.dcim.platforms.get(
|
device_platform = nb.dcim.platforms.get(
|
||||||
name=config.device.platform
|
name=config.device.platform
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -465,10 +465,11 @@ class ServerBase():
|
||||||
ret, server = self.update_netbox_location(server)
|
ret, server = self.update_netbox_location(server)
|
||||||
update += ret
|
update += ret
|
||||||
|
|
||||||
if get_device_platform(config) is not None:
|
if config.device.platform is not None:
|
||||||
if server.platform != get_device_platform(config).name:
|
platform = get_device_platform(config)
|
||||||
|
if server.platform != platform.name:
|
||||||
update += 1
|
update += 1
|
||||||
server.platform = get_device_platform(config).id
|
server.platform = platform.id
|
||||||
|
|
||||||
if update:
|
if update:
|
||||||
server.save()
|
server.save()
|
||||||
|
|
|
||||||
|
|
@ -95,8 +95,8 @@ class VirtualMachine(object):
|
||||||
vm = nb.virtualization.virtual_machines.create(
|
vm = nb.virtualization.virtual_machines.create(
|
||||||
name=hostname,
|
name=hostname,
|
||||||
cluster=cluster.id,
|
cluster=cluster.id,
|
||||||
platform=device_platform.id,
|
platform=device_platform.id if device_platform is not None else None,
|
||||||
device_platform = get_device_platform(config),
|
device_platform=device_platform,
|
||||||
vcpus=vcpus,
|
vcpus=vcpus,
|
||||||
memory=memory,
|
memory=memory,
|
||||||
tenant=tenant.id if tenant else None,
|
tenant=tenant.id if tenant else None,
|
||||||
|
|
|
||||||
Loading…
Add table
editor.link_modal.header
Reference in a new issue