Skip to content

Commit

Permalink
fix: Support Proxmox 8.2 (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsieradzki committed May 8, 2024
1 parent 8245e98 commit 22dce6f
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resources without the need for complicated bash scripts, terraform or ansible.

### Additional information

* Proxmox 7.2-7 or later (previous versions were not tested)
* Tested with Proxmox: 8.2.2
* Supported MicroK8s versions:
* 1.28/stable
* 1.27/stable
Expand Down
10 changes: 4 additions & 6 deletions core/src/dispatcher/usecase/create_cluster.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
use log::info;
use std::collections::HashMap;
use std::sync::Arc;
use log::info;

use openssl::rsa::Rsa;
use pem::{encode, Pem};

use proxmox_client::model::AccessData;
use proxmox_client::{Client, ClientOperations};
use crate::dispatcher::usecase::common;
use crate::model::{Cluster, ClusterNode, ClusterNodeType, KeyPair, LogEntry};
use crate::Repository;

use proxmox_client::model::AccessData;
use proxmox_client::{Client, ClientOperations};

pub(crate) fn execute(
proxmox_client: Arc<Client>,
Expand Down Expand Up @@ -295,8 +294,7 @@ pub(crate) fn create_vms(
proxmox_client
.lxc_containers(&cluster.node)?
.iter()
.map(|i| &i.vm_id)
.map(|i| i.parse::<u32>().unwrap_or_default())
.map(|i| i.vm_id)
.collect::<Vec<u32>>(),
);

Expand Down
27 changes: 18 additions & 9 deletions core/src/generator.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
use std::string::ToString;
use log::info;
use std::string::ToString;

use crate::model::{ClusterNode, ClusterNodeType, ClusterRequest, KeyPair, Network};
use crate::Error;
use proxmox_client::model::{NetworkType, StorageContentType};
use proxmox_client::ClientOperations;
use crate::Error;
use crate::model::{ClusterNode, ClusterNodeType, ClusterRequest, KeyPair, Network};


const EMPTY: String = String::new();

Expand Down Expand Up @@ -68,11 +67,18 @@ impl DefaultClusterConfigurationGenerator {
}

fn get_default_os_image() -> String {
crate::supported::os_images().values().next().unwrap().to_string()
crate::supported::os_images()
.values()
.next()
.unwrap()
.to_string()
}

fn get_default_kube_version() -> String {
crate::supported::kube_versions().first().unwrap().to_string()
crate::supported::kube_versions()
.first()
.unwrap()
.to_string()
}

fn get_default_start_vm_id(proxmox_client: &ClientOperations, node: &str) -> crate::Result<u32> {
Expand All @@ -81,12 +87,12 @@ fn get_default_start_vm_id(proxmox_client: &ClientOperations, node: &str) -> cra
.iter()
.map(|i| i.vm_id)
.collect();

used_vm_ids.extend(
proxmox_client
.lxc_containers(node)?
.iter()
.map(|i| &i.vm_id)
.map(|i| i.parse::<u32>().unwrap_or_default())
.map(|i| i.vm_id)
.collect::<Vec<u32>>(),
);

Expand Down Expand Up @@ -133,7 +139,10 @@ fn get_default_iso_storage(proxmox_client: &ClientOperations, node: &str) -> cra
.ok_or(Error::ResourceNotFound)
}

fn get_default_disk_storage(proxmox_client: &ClientOperations, node: &str) -> crate::Result<String> {
fn get_default_disk_storage(
proxmox_client: &ClientOperations,
node: &str,
) -> crate::Result<String> {
let result = proxmox_client.storage(node, Some(StorageContentType::Images))?;
result
.get(0)
Expand Down
2 changes: 1 addition & 1 deletion proxmox-client/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ pub struct LxcContainer {

#[doc = "The (unique) ID of the VM."]
#[serde(rename = "vmid")]
pub vm_id: String,
pub vm_id: u32,

#[doc = "Maximum usable CPUs."]
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
13 changes: 13 additions & 0 deletions tasks.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
return {
tasks = {
{
name = "backend",
exec = "cargo watch -x run",
},
{
name = "frontend",
exec = "pnpm run dev",
working_dir = "web/src-web",
},
},
}
1 change: 0 additions & 1 deletion web/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use env_logger::Env;
use mime_guess::from_path;
use rust_embed::RustEmbed;


use crate::handlers::actix::inject;

mod handlers;
Expand Down

0 comments on commit 22dce6f

Please sign in to comment.