Skip to content

Commit

Permalink
CreateVms now create it's own volume too
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Gatto <[email protected]>
  • Loading branch information
outscale-mgo committed Mar 21, 2024
1 parent 6a41f3c commit 9796545
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,20 @@ impl RicCall {

// {"BootOnCreation":true,"DeletionProtection":false,"ImageId":"ami-cd8d714e","KeypairName":"deployer","MaxVmsCount":1,"MinVmsCount":1,"NestedVirtualization":false,"SecurityGroupIds":["sg-ffffff00"],"SubnetId":"subnet-00000008","VmType":"tinav4.c1r1p2"}
println!("{:#}", in_json.dump());

// Vreate Volumes, should be optional TODO
let vol = json::object!{
VolumeId: format!("vol-{:08x}", req_id),
Tags: [],
VolumeType: "standard",
SubregionName: get_default_subregion(&cfg),
State: "creating",
CreationDate: "2022-08-01T13:37:54.356Z",
Iops: 100,
LinkedVolumes: [],
Size: 10
};

let mut vm = json::object!{
VmType: optional_arg!(in_json, "VmType", "small"),
"VmInitiatedShutdownBehavior": "stop",
Expand All @@ -1947,7 +1961,7 @@ impl RicCall {
{
"DeviceName": "/dev/sda1",
"Bsu": {
"VolumeId": "vol-6ce9a61e",
"VolumeId": vol["VolumeId"].clone(),
"State": "attached",
"LinkDate": "2022-08-01T13:37:54.356Z",
"DeleteOnVmDeletion": true
Expand Down Expand Up @@ -2006,6 +2020,8 @@ impl RicCall {
}
main_json[user_id]["Vms"].push(
vm.clone()).unwrap();
main_json[user_id]["Volumes"].push(
vol.clone()).unwrap();
json["Vms"] = json::array!{vm};
Ok((jsonobj_to_strret(json, req_id), StatusCode::OK))
},
Expand Down

0 comments on commit 9796545

Please sign in to comment.