mirror of
https://github.com/faas-rs/faasd-in-rust.git
synced 2025-06-09 00:06:47 +00:00
This reverts commit d46ccf6ea77c62527df7977ec2dd5fbaad6c1245.
This commit is contained in:
parent
d46ccf6ea7
commit
1830e40326
@ -67,19 +67,11 @@ fn get_netns(ns: &str, cid: &str) -> String {
|
|||||||
fn get_path(netns: &str) -> String {
|
fn get_path(netns: &str) -> String {
|
||||||
format!("/var/run/netns/{}", netns)
|
format!("/var/run/netns/{}", netns)
|
||||||
}
|
}
|
||||||
pub struct CNINetwork {
|
|
||||||
cid: String,
|
|
||||||
ns: String
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CNINetwork{
|
|
||||||
fn new (cid: String,ns:String) -> CNINetwork{
|
|
||||||
return CNINetwork { cid: cid, ns: ns }
|
|
||||||
}
|
|
||||||
//TODO: 创建网络和删除网络的错误处理
|
//TODO: 创建网络和删除网络的错误处理
|
||||||
pub fn create_cni_network(&self) -> Result<(String, String), Err> {
|
pub fn create_cni_network(cid: String, ns: String) -> Result<(String, String), Err> {
|
||||||
// let netid = format!("{}-{}", cid, pid);
|
// let netid = format!("{}-{}", cid, pid);
|
||||||
let netns = get_netns(self.ns.as_str(), self.cid.as_str());
|
let netns = get_netns(ns.as_str(), cid.as_str());
|
||||||
let path = get_path(netns.as_str());
|
let path = get_path(netns.as_str());
|
||||||
let mut ip = String::new();
|
let mut ip = String::new();
|
||||||
|
|
||||||
@ -127,12 +119,6 @@ pub fn create_cni_network(&self) -> Result<(String, String), Err> {
|
|||||||
|
|
||||||
Ok((ip, path))
|
Ok((ip, path))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
impl Drop for CNINetwork {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
delete_cni_network(&self.ns, &self.cid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn delete_cni_network(ns: &str, cid: &str) {
|
pub fn delete_cni_network(ns: &str, cid: &str) {
|
||||||
let netns = get_netns(ns, cid);
|
let netns = get_netns(ns, cid);
|
||||||
@ -153,7 +139,6 @@ pub fn delete_cni_network(ns: &str, cid: &str) {
|
|||||||
.output();
|
.output();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn dir_exists(dirname: &Path) -> bool {
|
fn dir_exists(dirname: &Path) -> bool {
|
||||||
path_exists(dirname).is_some_and(|info| info.is_dir())
|
path_exists(dirname).is_some_and(|info| info.is_dir())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user