Skip to content

Commit

Permalink
createVms: add subnet selection
Browse files Browse the repository at this point in the history
Signed-off-by: matthias.gatto <[email protected]>
  • Loading branch information
outscale-mgo committed Feb 13, 2024
1 parent 327c7c0 commit 541989a
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions osc_tui/createVm.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
AOS_COMBO = None
# security groups
SG = None
# Subnet
SUBNET = None

SUBNETS_IDS = []

SELECTED_SG = []

Expand Down Expand Up @@ -127,13 +131,17 @@ def create():
}
}
]
subnet = None
if SUBNET.get_value() > 0:
subnet=SUBNETS_IDS[SUBNET.get_value() - 1]

res = main.GATEWAY.CreateVms(
form=self, ImageId=id, KeypairName=keypair, VmType=vmtype, Placement={
"SubregionName": REGION.get_values()[REGION.get_value()]
},
SecurityGroups=sg,
BlockDeviceMappings=bdm,
SubnetId=subnet,
VmInitiatedShutdownBehavior=AOS_COMBO.get_values()[AOS_COMBO.get_value()],
)
else:
Expand Down Expand Up @@ -274,6 +282,25 @@ def exit():
values=cpu_vals,
value=CPU.get_value() if CPU else 3,
)
global SUBNET
global SUBNETS_IDS
SUBNETS_IDS = []
subnet_read = main.GATEWAY.ReadSubnets(form=self)["Subnets"]
subnet_vals = ["Default"]
for sn in subnet_read:
sn_id = sn["SubnetId"]
name = sn_id
if "Tags" in sn and len(sn["Tags"]) > 0 and sn["Tags"][0]["Key"] == "Name":
name = sn["Tags"][0]["Value"] + "(id :" + sn_id + ")"
subnet_vals.append(name)
SUBNETS_IDS.append(sn_id)
SUBNET = self.add_widget(
OscCombo,
name="Subnet",
values=subnet_vals,
value=SUBNET.get_value() if SUBNET else 0,
)

global PERFORMANCE
perf_vals = "MEDIUM HIGH HIGHEST".split(" ")
PERFORMANCE = self.add_widget(
Expand Down

0 comments on commit 541989a

Please sign in to comment.