Skip to content

Commit

Permalink
fix: create server
Browse files Browse the repository at this point in the history
  • Loading branch information
NichArchA82 committed Jan 8, 2025
1 parent 4a3e057 commit 3f55f9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion command-handler/src/commands/vm.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default {
hetzner.createServer({ app, body, imageID, imageName, region, serverType });
} else if (actionId.startsWith('button_create_image_libvirt')) {
const { imageName, instanceType } = JSON.parse(body.actions[0].value);
libvirt.createServer({ app, body, imageName, instanceType });
libvirt.createServer({ app, body, imageName, region, instanceType });
} else if (actionId === 'button_create_vm_hetzner') {
//select the hetzner server to create before calling the create server
hetzner.selectRegion({ app, body });
Expand Down
8 changes: 5 additions & 3 deletions command-handler/src/util/libvirt/libvirt-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const delay = (ms) => {
}

export default {
createServer: async({ app, body, imageName }) => {
createServer: async({ app, body, imageName, region, instanceType }) => {
//auto generate the name
const serverName = uniqueNamesGenerator({
dictionaries: [ colors, animals ],
Expand Down Expand Up @@ -59,7 +59,9 @@ export default {
"owner": userEmail,
},
"user_data": Buffer.from(configUserData(serverName)).toString('base64'),
"image": imageName
"image": imageName,
"region_name": region,
"instance_type": instanceType
}, {
headers: {
'Authorization': `${process.env.PROVISIONER_API_TOKEN}`,
Expand Down Expand Up @@ -366,7 +368,7 @@ export default {
const buttonsArray = [];

for (const serverType of data.instances) {
data.serverType = serverType.instance_type;
data.instanceType = serverType.instance_type;
buttonsArray.push({ text: serverType.instance_type, actionId: `button_select_libvirt_image_${serverType.instance_type}`, value: JSON.stringify(data) });
};
const buttons = buttonBuilder({ buttonsArray, headerText: 'Select a server', fallbackText: 'unsupported device' });
Expand Down

0 comments on commit 3f55f9f

Please sign in to comment.