Skip to content

Commit

Permalink
Adds cloud-vm-sim call
Browse files Browse the repository at this point in the history
  • Loading branch information
retpolanne committed Dec 14, 2023
1 parent 44044dd commit 882e010
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions moto/ec2/responses/instances.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from copy import deepcopy
from typing import Any, Dict, List, Optional
import requests
import base64

from moto.core.utils import camelcase_to_underscores
from moto.ec2.exceptions import (
Expand Down Expand Up @@ -91,6 +93,10 @@ def run_instances(self) -> str:
if self._get_param("Monitoring.Enabled") == "true"
else "disabled",
}
decoded_user_data = base64.b64decode(user_data).decode("utf-8")
cloud_config = decoded_user_data[decoded_user_data.find("#cloud-config"):decoded_user_data.find("--MIMEBOUNDARY--")]
instance_name = kwargs["tags"]["instance"].get("Name")
requests.post(url=f"http://localhost:3000/spawn_qemu/{instance_name}", data=cloud_config)
if len(kwargs["nics"]) and kwargs["subnet_id"]:
raise InvalidParameterCombination(
msg="Network interfaces and an instance-level subnet ID may not be specified on the same request"
Expand Down

0 comments on commit 882e010

Please sign in to comment.