test with docker-api (no oficial) lib
This commit is contained in:
52
src/conf/mod.rs
Normal file
52
src/conf/mod.rs
Normal file
@@ -0,0 +1,52 @@
|
||||
use std::net::{Ipv4Addr, SocketAddrV4};
|
||||
use rusqlite::{Connection, Result};
|
||||
|
||||
const PATH: &str = "mdeploy.db";
|
||||
|
||||
pub struct ConfServer{
|
||||
ip: String,
|
||||
port: String,
|
||||
ip_top_limit: u8,
|
||||
ip_base_limit: u8,
|
||||
}
|
||||
|
||||
pub struct MInstance {
|
||||
id: i64,
|
||||
ip: Ipv4Addr,
|
||||
}
|
||||
|
||||
pub struct instance {
|
||||
con: Connection,
|
||||
|
||||
}
|
||||
|
||||
impl instance {
|
||||
pub fn new() -> Result<Self> {
|
||||
let con = Connection::open(PATH)?;
|
||||
let ret = Self {
|
||||
con : con,
|
||||
};
|
||||
ret.create_table()?;
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
fn create_table(&self) -> Result<()> {
|
||||
self.con.execute_batch(
|
||||
"BEGIN;
|
||||
CREATE TABLE IF NOT EXISTS images(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT UNIQUE);
|
||||
CREATE TABLE IF NOT EXISTS l_instances(
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
ip TEXT,
|
||||
image INTEGER
|
||||
FOREIGN KEY(INTEGER) REFERENCES images(id));
|
||||
COMMIT;"
|
||||
)
|
||||
}
|
||||
|
||||
fn insert_image(&self, image: String){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user