apache / apache/libcloud

azure_arm.py: create_node: cannot create windows VM

Offen
#1,327 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
api: compute drivers: azure stale
Vorherrschende Sprache
Python
Sterne
2.1k
Forks
931
Ø Merge
1 T. 2 Std.
Gemergte PRs (30 T.)
4

Beschreibung

## Summary

Using the azure_arm provider, I cannot create a windows VM. in the create_node function it has been hardcoded to only support linux VMs (I have commented `#HERE` in the code below).

## Detailed Information

I was able to check the name of the image and see if it is a windows Image (all windows images have image.offer == "WindowsServer") and then set the correct osType with in `create_node`. However, this does not work with AzureVhdImage Images. And that's where I am stuck ...

Also, we also set up authentication assuming a linux machine. when the os is windows we don't need to set `data["properties"]["osProfile"]["linuxConfiguration"] ` for `NodeAuthSSHKey` and also `NodeAuthPassword`.

I tried to make a fix but I couldn't figure how to get the osType from a VHD Image.

Please let me know if you have any insights!

# Stack

Traceback (most recent call last):
node = conn.create_node(name=name, location=location, image=image, size=size, auth=auth, ex_resource_group=resource_group, ex_storage_account=storage_account, ex_blob_container=blob_container, ex_nic=nic)
File "/Library/Python/2.7/site-packages/libcloud/compute/drivers/azure_arm.py", line 672, in create_node
method="PUT")
File "/Library/Python/2.7/site-packages/libcloud/common/azure_arm.py", line 229, in request
method=method, raw=raw)
File "/Library/Python/2.7/site-packages/libcloud/common/base.py", line 636, in request
response = responseCls(**kwargs)
File "/Library/Python/2.7/site-packages/libcloud/common/base.py", line 153, in __init__
headers=self.headers)
libcloud.common.exceptions.BaseHTTPError: [InvalidParameter] The value 'Linux' of parameter 'osDisk.osType' is not allowed. Allowed values are 'Windows'.

# Code:

compute/drivers/azure_arm.py

```
if isinstance(image, AzureVhdImage):
instance_vhd = self._get_instance_vhd(
name=name,
ex_resource_group=ex_resource_group,
ex_storage_account=ex_storage_account,
ex_blob_container=ex_blob_container)
storage_profile = {
"osDisk": {
"name": name,
"osType": "linux", #HERE!
"caching": "ReadWrite",
"createOption": "FromImage",
"image": {
"uri": image.id
},
"vhd": {
"uri": instance_vhd,
}
}
}
if ex_use_managed_disks:
raise LibcloudError(
"Creating managed OS disk from %s image "
"type is not supported." % type(image))
elif isinstance(image, AzureImage):
storage_profile = {
"imageReference": {
"publisher": image.publisher,
"offer": image.offer,
"sku": image.sku,
"version": image.version
},
"osDisk": {
"name": name,
"osType": "linux", #HERE!
"caching": "ReadWrite",
"createOption": "FromImage"
}
}
```
...

```
if isinstance(auth, NodeAuthSSHKey):
data["properties"]["osProfile"]["adminPassword"] = \
binascii.hexlify(os.urandom(20)).decode("utf-8")
data["properties"]["osProfile"]["linuxConfiguration"] = { #HERE!
"disablePasswordAuthentication": "true",
"ssh": {
"publicKeys": [
{
"path": '/home/%s/.ssh/authorized_keys' % (
ex_user_name),
"keyData": auth.pubkey # pylint: disable=no-member
}
]
}
}
elif isinstance(auth, NodeAuthPassword):
data["properties"]["osProfile"]["linuxConfiguration"] = { #HERE!
"disablePasswordAuthentication": "false"
}
data["properties"]["osProfile"]["adminPassword"] = auth.password
else:
raise ValueError(
"Must provide NodeAuthSSHKey or NodeAuthPassword in auth")

```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne in compute/drivers/azure_arm.py, insbesondere bei create_node und den im Issue gezeigten Zweigen AzureVhdImage, AzureImage, NodeAuthSSHKey und NodeAuthPassword. Verfolge, wie der Image-Typ und die Authentifizierungsdaten verwendet werden, einschließlich des Azure-Fehlers für Windows-Images. Als abgeschlossen gilt die Aufgabe, wenn Windows-VMs ohne Linux-spezifische Einstellungen erstellt werden können und das bestehende Verhalten für Linux-VMs weiterhin unterstützt wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
azure, python
Bereich
cloud
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.