fix: deduplicate SSH keys on LXC/VM create; filter qemu templates in wizard
Some checks failed
Backend Tests / pytest (Python 3.12) (push) Has been cancelled
Some checks failed
Backend Tests / pytest (Python 3.12) (push) Has been cancelled
This commit is contained in:
@@ -2358,6 +2358,15 @@ async def create_lxc_container(
|
||||
combined_ssh_keys = f"{combined_ssh_keys}\n{current_user.ssh_public_key}"
|
||||
else:
|
||||
combined_ssh_keys = current_user.ssh_public_key
|
||||
# Deduplicate SSH keys while preserving order
|
||||
_seen_ssh: set = set()
|
||||
_uniq_ssh = []
|
||||
for _k in combined_ssh_keys.splitlines():
|
||||
_k = _k.strip()
|
||||
if _k and _k not in _seen_ssh:
|
||||
_seen_ssh.add(_k)
|
||||
_uniq_ssh.append(_k)
|
||||
combined_ssh_keys = "\n".join(_uniq_ssh)
|
||||
|
||||
upid = client.create_lxc_container(
|
||||
node=node,
|
||||
@@ -2492,6 +2501,15 @@ async def create_lxc_container_smart(
|
||||
combined_ssh_keys = f"{combined_ssh_keys}\n{current_user.ssh_public_key}"
|
||||
else:
|
||||
combined_ssh_keys = current_user.ssh_public_key
|
||||
# Deduplicate SSH keys while preserving order
|
||||
_seen_ssh: set = set()
|
||||
_uniq_ssh = []
|
||||
for _k in combined_ssh_keys.splitlines():
|
||||
_k = _k.strip()
|
||||
if _k and _k not in _seen_ssh:
|
||||
_seen_ssh.add(_k)
|
||||
_uniq_ssh.append(_k)
|
||||
combined_ssh_keys = "\n".join(_uniq_ssh)
|
||||
|
||||
# Создаём контейнер
|
||||
upid = client.create_lxc_container(
|
||||
|
||||
@@ -893,6 +893,15 @@ def _do_deploy_sync(task_id: int, deploy_data: VMDeployRequest,
|
||||
ssh_keys = deploy_data.ssh_keys or ""
|
||||
if user_ssh_key:
|
||||
ssh_keys = f"{ssh_keys}\n{user_ssh_key}".strip()
|
||||
# Deduplicate SSH keys while preserving order
|
||||
_seen_ssh: set = set()
|
||||
_uniq_ssh = []
|
||||
for _k in ssh_keys.splitlines():
|
||||
_k = _k.strip()
|
||||
if _k and _k not in _seen_ssh:
|
||||
_seen_ssh.add(_k)
|
||||
_uniq_ssh.append(_k)
|
||||
ssh_keys = "\n".join(_uniq_ssh)
|
||||
|
||||
config_success = client.configure_vm(
|
||||
node=deploy_node,
|
||||
|
||||
@@ -319,7 +319,7 @@ export default function CreateInstanceWizard({ onClose }: { onClose?: () => void
|
||||
<div className="space-y-4">
|
||||
<h3 className="text-lg font-semibold">{t('wizard.select_template')}</h3>
|
||||
{groups.map(group => {
|
||||
const groupTemplates = templates.filter(t => t.group_id === group.id);
|
||||
const groupTemplates = templates.filter(t => t.group_id === group.id && t.vm_type === 'qemu');
|
||||
if (groupTemplates.length === 0) return null;
|
||||
return (
|
||||
<div key={group.id} className="space-y-2">
|
||||
@@ -350,7 +350,7 @@ export default function CreateInstanceWizard({ onClose }: { onClose?: () => void
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{templates.length === 0 && (
|
||||
{templates.filter(t => t.vm_type === 'qemu').length === 0 && (
|
||||
<p className="text-center text-muted-foreground py-8">{t('wizard.no_templates')}</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user