forked from ungleich-public/dynamicweb
Only derive the template name from VM names dynamicweb itself produced
On production 143 of 233 active VMs reference a deleted template, and
many of those were created or renamed outside dynamicweb ("gitea",
"ipv6only-Alpine 3.15-27397-Jonas"). Blindly cutting at the last "-"
mangled such names, so only strip a trailing "-<vm id>" suffix, which is
exactly what OpenNebulaManager.create_vm appends.
This commit is contained in:
parent
cb16114aba
commit
f30e70c20c
2 changed files with 21 additions and 7 deletions
|
|
@ -173,10 +173,19 @@ class TemplateNameHelpersTestCase(TestCase):
|
|||
|
||||
def test_template_name_from_vm_name(self):
|
||||
self.assertEqual(
|
||||
template_name_from_vm_name('public-Ubuntu 20.10-26623'),
|
||||
template_name_from_vm_name('public-Ubuntu 20.10-26623', 26623),
|
||||
'public-Ubuntu 20.10'
|
||||
)
|
||||
|
||||
def test_template_name_from_vm_name_keeps_custom_names(self):
|
||||
# VMs created or renamed outside dynamicweb
|
||||
self.assertEqual(template_name_from_vm_name('gitea', 27001), 'gitea')
|
||||
self.assertEqual(
|
||||
template_name_from_vm_name('ipv6only-Alpine 3.15-27397-Jonas',
|
||||
27397),
|
||||
'ipv6only-Alpine 3.15-27397-Jonas'
|
||||
)
|
||||
|
||||
|
||||
def _fake_vm(vm_id, name, template_id):
|
||||
vm = MagicMock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue