Fixing syntax for main.
This commit is contained in:
parent
ff2f4252e4
commit
9b8c772615
@ -1,4 +1,5 @@
|
|||||||
"""A Pulumi deployment with libvirt and Python"""
|
"""A Pulumi deployment with libvirt and Python"""
|
||||||
|
# vim:sts=4:sw=4
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from dotmap import DotMap
|
from dotmap import DotMap
|
||||||
@ -12,14 +13,14 @@ cloudimages = DotMap(yaml.safe_load(open("cloud-images.yaml").read()))
|
|||||||
conf.password = sha512_crypt.hash(conf.password, rounds=4096)
|
conf.password = sha512_crypt.hash(conf.password, rounds=4096)
|
||||||
config = pulumi.Config()
|
config = pulumi.Config()
|
||||||
|
|
||||||
pool = lv.Pool("mypool", type = "dir", path = conf.poolpath)
|
pool = lv.Pool("mypool", type="dir", path=conf.poolpath)
|
||||||
baseimg = lv.Volume("myimage", pool = pool.name, source = cloudimages[conf.image])
|
baseimg = lv.Volume("myimage", pool=pool.name, source=cloudimages[conf.image])
|
||||||
|
|
||||||
volume = lv.Volume("mydisk",
|
volume = lv.Volume("mydisk",
|
||||||
base_volume_id = baseimg.id,
|
base_volume_id=baseimg.id,
|
||||||
pool = pool.name,
|
pool=pool.name,
|
||||||
size = int(conf.disksize) * 1024 ** 3
|
size=int(conf.disksize) * 1024 ** 3
|
||||||
)
|
)
|
||||||
|
|
||||||
# Stream configuration files
|
# Stream configuration files
|
||||||
userdata = Template(open("./cloud-init/user-data.jinja").read()).render(conf)
|
userdata = Template(open("./cloud-init/user-data.jinja").read()).render(conf)
|
||||||
@ -27,31 +28,30 @@ metadata = Template(open("./cloud-init/meta-data.jinja").read()).render(conf)
|
|||||||
networkconfig = open("./cloud-init/network-config").read()
|
networkconfig = open("./cloud-init/network-config").read()
|
||||||
|
|
||||||
cloudinit = lv.CloudInitDisk("cloud-init",
|
cloudinit = lv.CloudInitDisk("cloud-init",
|
||||||
meta_data = metadata,
|
meta_data=metadata,
|
||||||
user_data = userdata,
|
user_data=userdata,
|
||||||
network_config = networkconfig
|
network_config=networkconfig
|
||||||
)
|
)
|
||||||
|
|
||||||
vm = lv.Domain(conf.name,
|
vm = lv.Domain(conf.name,
|
||||||
boot_devices = [ lv.DomainBootDeviceArgs(
|
boot_devices=[lv.DomainBootDeviceArgs(devs=["hd", "cdrom"])],
|
||||||
devs = [ "hd", "cdrom" ]
|
cloudinit=cloudinit.id,
|
||||||
) ],
|
vcpu=conf.vcpu,
|
||||||
cloudinit = cloudinit.id,
|
disks=[lv.DomainDiskArgs(volume_id=volume.id)],
|
||||||
vcpu = conf.vcpu,
|
memory=int(conf.ram),
|
||||||
disks = [ lv.DomainDiskArgs(volume_id = volume.id) ],
|
network_interfaces=[lv.DomainNetworkInterfaceArgs(
|
||||||
memory = int(conf.ram),
|
network_name="default",
|
||||||
network_interfaces = [ lv.DomainNetworkInterfaceArgs(
|
wait_for_lease=True
|
||||||
network_name = "default",
|
)
|
||||||
wait_for_lease = True
|
],
|
||||||
) ],
|
consoles=[lv.DomainConsoleArgs(
|
||||||
consoles = [ lv.DomainConsoleArgs(
|
type="pty",
|
||||||
type = "pty",
|
target_port='0',
|
||||||
target_port = 0,
|
target_type="serial"
|
||||||
target_type = "serial"
|
)],
|
||||||
) ],
|
opts=pulumi.ResourceOptions(
|
||||||
opts = pulumi.ResourceOptions(
|
custom_timeouts=pulumi.CustomTimeouts(create="3m")
|
||||||
custom_timeouts = pulumi.CustomTimeouts(create = "3m")
|
)
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
pulumi.export("ip", vm.network_interfaces[0]['addresses'][0])
|
pulumi.export("ip", vm.network_interfaces[0]['addresses'][0])
|
||||||
|
Loading…
Reference in New Issue
Block a user