rewrite builder pattern + clean script as template
This commit is contained in:
@@ -170,6 +170,20 @@ pub fn cloudhv_vm_info(id: &str) -> Result<Map, Box<EvalAltResult>> {
|
||||
Ok(vmrecord_to_map(&rec))
|
||||
}
|
||||
|
||||
pub fn cloudhv_discover_ipv4_from_leases(lease_path: &str, mac_lower: &str, timeout_secs: i64) -> Dynamic {
|
||||
match crate::cloudhv::net::discover_ipv4_from_leases(lease_path, mac_lower, timeout_secs as u64) {
|
||||
Some(ip) => ip.into(),
|
||||
None => Dynamic::UNIT,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn cloudhv_discover_ipv6_on_bridge(bridge_name: &str, mac_lower: &str) -> Dynamic {
|
||||
match crate::cloudhv::net::discover_ipv6_on_bridge(bridge_name, mac_lower) {
|
||||
Some(ip) => ip.into(),
|
||||
None => Dynamic::UNIT,
|
||||
}
|
||||
}
|
||||
|
||||
// Module registration
|
||||
|
||||
pub fn register_cloudhv_module(engine: &mut Engine) -> Result<(), Box<EvalAltResult>> {
|
||||
@@ -179,5 +193,7 @@ pub fn register_cloudhv_module(engine: &mut Engine) -> Result<(), Box<EvalAltRes
|
||||
engine.register_fn("cloudhv_vm_delete", cloudhv_vm_delete);
|
||||
engine.register_fn("cloudhv_vm_list", cloudhv_vm_list);
|
||||
engine.register_fn("cloudhv_vm_info", cloudhv_vm_info);
|
||||
engine.register_fn("cloudhv_discover_ipv4_from_leases", cloudhv_discover_ipv4_from_leases);
|
||||
engine.register_fn("cloudhv_discover_ipv6_on_bridge", cloudhv_discover_ipv6_on_bridge);
|
||||
Ok(())
|
||||
}
|
Reference in New Issue
Block a user