Commit d5c0d71e authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_subscription_request: Update sample script for KVM cluster

Use sticky-computer to make the requester use same COMP reference when request himself. It allow us to maintain the requested instance on the same computer as the requester.
parent f35b79a6
...@@ -15,11 +15,9 @@ if not amount or parameter_text is None: ...@@ -15,11 +15,9 @@ if not amount or parameter_text is None:
return None return None
json_parameter = context.Base_instanceXmlToDict(parameter_text) json_parameter = context.Base_instanceXmlToDict(parameter_text)
serialisation = "xml"
if "_" in json_parameter: if "_" in json_parameter:
# This is json-in-xml serialisation # This is json-in-xml serialisation
serialisation = "json-in-xml"
json_parameter = json.loads(json_parameter["_"]) json_parameter = json.loads(json_parameter["_"])
else: else:
raise ValueError("KVM Cluster only supports serialised values!") raise ValueError("KVM Cluster only supports serialised values!")
...@@ -27,7 +25,12 @@ else: ...@@ -27,7 +25,12 @@ else:
KVM0 = json_parameter["kvm-partition-dict"]["KVM0"] KVM0 = json_parameter["kvm-partition-dict"]["KVM0"]
for i in range(amount): for i in range(amount):
json_parameter["kvm-partition-dict"]["KVM" + str(i)] = KVM0 if i == 0:
k = KVM0.copy()
k["sticky-computer"] = True
json_parameter["kvm-partition-dict"]["KVM" + str(i)] = k
else:
json_parameter["kvm-partition-dict"]["KVM" + str(i)] = KVM0
xml_paramerter = """ xml_paramerter = """
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment