- TODO: should define in view yaml ??
-
- )}
>
)
}
diff --git a/src/fireedge/src/client/features/One/vm/actions.js b/src/fireedge/src/client/features/One/vm/actions.js
index afb54df343..c0108f56a0 100644
--- a/src/fireedge/src/client/features/One/vm/actions.js
+++ b/src/fireedge/src/client/features/One/vm/actions.js
@@ -46,4 +46,5 @@ export const resize = createAction('vm/resize', vmService.resize)
export const changePermissions = createAction('vm/chmod', vmService.changePermissions)
export const changeOwnership = createAction('vm/chown', vmService.changeOwnership)
export const attachDisk = createAction('vm/attach/disk', vmService.attachDisk)
+export const attachNic = createAction('vm/attach/nic', vmService.attachNic)
export const detachNic = createAction('vm/detach/nic', vmService.detachNic)
diff --git a/src/fireedge/src/client/features/One/vm/hooks.js b/src/fireedge/src/client/features/One/vm/hooks.js
index faa0ecebaa..42af70ab0d 100644
--- a/src/fireedge/src/client/features/One/vm/hooks.js
+++ b/src/fireedge/src/client/features/One/vm/hooks.js
@@ -45,6 +45,7 @@ export const useVmApi = () => {
changeOwnership: (id, ownership) =>
unwrapDispatch(actions.changeOwnership({ id, ownership })),
attachDisk: (id, template) => unwrapDispatch(actions.attachDisk({ id, template })),
+ attachNic: (id, template) => unwrapDispatch(actions.attachNic({ id, template })),
detachNic: (id, nic) => unwrapDispatch(actions.detachNic({ id, nic }))
}
}
diff --git a/src/fireedge/src/client/features/One/vm/services.js b/src/fireedge/src/client/features/One/vm/services.js
index 14462773ef..632dcab107 100644
--- a/src/fireedge/src/client/features/One/vm/services.js
+++ b/src/fireedge/src/client/features/One/vm/services.js
@@ -242,6 +242,28 @@ export const vmService = ({
return res?.data
},
+ /**
+ * Attaches a new network interface to the virtual machine.
+ *
+ * @param {object} params - Request parameters
+ * @param {string|number} params.id - Virtual machine id
+ * @param {string} params.template
+ * - A string containing a single NIC vector attribute
+ * @returns {number} Virtual machine id
+ * @throws Fails when response isn't code 200
+ */
+ attachNic: async ({ id, template }) => {
+ const name = Actions.VM_NIC_ATTACH
+ const command = { name, ...Commands[name] }
+ const config = requestConfig({ id, template }, command)
+
+ const res = await RestClient.request(config)
+
+ if (!res?.id || res?.id !== httpCodes.ok.id) throw res?.data
+
+ return res?.data
+ },
+
/**
* Detaches a network interface from a virtual machine.
*