aibor / marmoset

Simple HTTP API for managing stuff on libvirt hosts
GNU Affero General Public License v3.0
4 stars 4 forks source link

Unable to create pxe record without password #3

Open bastelfreak opened 9 years ago

bastelfreak commented 9 years ago

My default label doesn't need a password so it doesn't have a callback method defined:

[Modules]
PXE: True
VM: False

[Webserver]
Username: admin
Password: secret
BasicRealm: marmoset
Host: 10.30.7.40
Port: 8080
ServerName: dhcp01.aweso.me
Debug: True

[Libvirt]
URI: qemu:///system
XMLTemplateDirectory: 
Network:
Storage: 

[PXEConfig]
ConfigDirectory: /srv/tftp/pxelinux.cfg/

[PXELabel]
arch-hdd-net:
rescue: setpwhash

If fails to create a PXE entry if I start marmoset without a password:

root@dhcp01 /opt/marmoset # ./marmoset.py pxe create 10.30.7.41
Traceback (most recent call last):
  File "./marmoset.py", line 6, in <module>
    marmoset.run()
  File "/opt/marmoset/marmoset/__init__.py", line 5, in run
    cli.parse(cfg)
  File "/opt/marmoset/marmoset/cli/__init__.py", line 47, in parse
    args.func(args)
  File "/opt/marmoset/marmoset/pxe/__init__.py", line 9, in create
    print(msg % (pxe_client.file_path(), pxe_client.password))
AttributeError: 'ClientConfig' object has no attribute 'password'
root@dhcp01 /opt/marmoset # ./marmoset.py pxe create -p 123 10.30.7.41
Created /srv/tftp/pxelinux.cfg/0A1E0729 with password 123
root@dhcp01 /opt/marmoset # cat /srv/tftp/pxelinux.cfg/0A1E0729
INCLUDE pxelinux.cfg/default
DEFAULT instantboot
PROMPT 0
TIMEOUT 1
LABEL instantboot
    KERNEL cmd.c32
    APPEND arch-hdd-net 
root@dhcp01 /opt/marmoset #
aibor commented 9 years ago

https://github.com/aibor/marmoset/blob/master/marmoset/pxe/__init__.py#L9 is missing a check if a password is set before trying to access the attribute. Not my use case, so PR welcome.