feat: load resources only from template

This commit is contained in:
2025-02-17 15:55:12 +00:00
parent 94ca78940f
commit 0b84a3e6ab
4 changed files with 17 additions and 20 deletions

View File

@ -231,12 +231,6 @@ pub struct Vm {
pub created: DateTime<Utc>,
/// When the VM expires
pub expires: DateTime<Utc>,
/// How many vCPU's this VM has
pub cpu: u16,
/// How much RAM this VM has in bytes
pub memory: u64,
/// How big the disk is on this VM in bytes
pub disk_size: u64,
/// The [VmHostDisk] this VM is on
pub disk_id: u64,
/// Network MAC address

View File

@ -222,7 +222,7 @@ impl LNVpsDb for LNVpsDbMysql {
}
async fn insert_vm(&self, vm: &Vm) -> Result<u64> {
Ok(sqlx::query("insert into vm(host_id,user_id,image_id,template_id,ssh_key_id,created,expires,cpu,memory,disk_size,disk_id,mac_address) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) returning id")
Ok(sqlx::query("insert into vm(host_id,user_id,image_id,template_id,ssh_key_id,created,expires,disk_id,mac_address) values(?, ?, ?, ?, ?, ?, ?, ?, ?) returning id")
.bind(vm.host_id)
.bind(vm.user_id)
.bind(vm.image_id)
@ -230,9 +230,6 @@ impl LNVpsDb for LNVpsDbMysql {
.bind(vm.ssh_key_id)
.bind(vm.created)
.bind(vm.expires)
.bind(vm.cpu)
.bind(vm.memory)
.bind(vm.disk_size)
.bind(vm.disk_id)
.bind(&vm.mac_address)
.fetch_one(&self.db)
@ -251,14 +248,11 @@ impl LNVpsDb for LNVpsDbMysql {
}
async fn update_vm(&self, vm: &Vm) -> Result<()> {
sqlx::query("update vm set image_id=?,template_id=?,ssh_key_id=?,expires=?,cpu=?,memory=?,disk_size=?,disk_id=? where id=?")
sqlx::query("update vm set image_id=?,template_id=?,ssh_key_id=?,expires=?,disk_id=? where id=?")
.bind(vm.image_id)
.bind(vm.template_id)
.bind(vm.ssh_key_id)
.bind(vm.expires)
.bind(vm.cpu)
.bind(vm.memory)
.bind(vm.disk_size)
.bind(vm.disk_id)
.bind(vm.id)
.execute(&self.db)