My cloud init script never appears to work and the users option does not work either. If I use root_password and user_name for types.Initialization (as in the example below) it will generate the correct users, but if I put in the types.CloudInit piece it will break it.
types.Initialization(
user_name=cloud_init_username,
root_password=cloud_init_password,
regenerate_ssh_keys=True,
host_name="testingcloudinit",
nic_configurations=[
types.NicConfiguration(
boot_protocol=types.BootProtocol.DHCP,
name='ens3',
on_boot=True
)
],
custom_script=cloud_init_script
)
What I currently have is below. cloud_init_script is the script I want to run as a string. Looking at the REST API documentation it shows that I need to upload the file as a CDATA entry, but I am unsure of how I can ensure that in python. Is there potentially a way I could get the full XML call in python to ensure API compliance?
vm_service.start(
use_cloud_init=True,
vm=types.Vm(
initialization=types.Initialization(
nic_configurations=[types.NicConfiguration(
boot_protocol=types.BootProtocol.DHCP,
name="ens3",
on_boot=True
)],
cloud_init=types.CloudInit(
files=[types.File(
name="initialrunner",
content=cloud_init_script,
type="plaintext"
),
],
users=[types.User(
user_name=cloud_init_username,
password=cloud_init_password
)]
)
)
)
)
Documentation that I have been using: