How to use the proxmoxer.ResourceException function in proxmoxer

To help you get started, we’ve selected a few proxmoxer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LordGaav / proxmox-deploy / proxmoxdeploy / cli.py View on Github external
(proxmox, cloudinit) = interact_with_user(args, api)
        context = dict(proxmox, **cloudinit)
    except KeyboardInterrupt:
        logger.info("Aborted by user")
        sys.exit(0)

    logger.info("")
    logger.info("")
    logger.info("Starting provisioning process")

    try:
        api.create_vm(node=proxmox['node'], vmid=proxmox['vmid'],
                      name=cloudinit['name'], cpu=proxmox['cpu'],
                      cpu_family=proxmox['cpu_family'],
                      memory=proxmox['memory'], vlan_id=cloudinit['vlan_id'])
    except ResourceException:
        logger.error("Failed to create VM")
        sys.exit(1)

    try:
        cloudinit_iso = generate_seed_iso(context=context)
        logger.debug("File generated at: {0}".format(cloudinit_iso))

        logger.info("Uploading cloud-init seed ISO to Proxmox")
        api.attach_seed_iso(node=proxmox['node'], storage=proxmox["storage"],
                            vmid=proxmox['vmid'], iso_file=cloudinit_iso)
        logger.info("Uploading cloud image to Proxmox")
        disk_size = proxmox['disk'] * 1024 ** 2
        api.attach_base_disk(node=proxmox['node'], storage=proxmox["storage"],
                             vmid=proxmox['vmid'],
                             img_file=cloudinit['image'],
                             disk_size=disk_size)