mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2024-11-25 16:17:56 +01:00
Fix Machines using their name instead of their id
This commit is contained in:
parent
fd7fec2cbe
commit
eeb0ff306b
@ -35,7 +35,7 @@
|
||||
{ description = Some "A test machine"
|
||||
, disclose = "lab.test.read"
|
||||
, manage = "lab.test.admin"
|
||||
, name = "Testmachine"
|
||||
, name = "MachineA"
|
||||
, read = "lab.test.read"
|
||||
, write = "lab.test.write"
|
||||
},
|
||||
|
2
schema
2
schema
@ -1 +1 @@
|
||||
Subproject commit 743c18393c6e01edeec1e04ab8998176d78f9a04
|
||||
Subproject commit c855646a90958ae575d58be074d187acb9f8f4fa
|
@ -74,7 +74,8 @@ impl machines::Server for Machines {
|
||||
let perms = Perms::get_for(&machine.desc.privs, permissions.iter());
|
||||
|
||||
let mut builder = machines.reborrow().get(i as u32);
|
||||
builder.set_name(&name);
|
||||
builder.set_id(&name);
|
||||
builder.set_name(&machine.desc.name);
|
||||
if let Some(ref desc) = machine.desc.description {
|
||||
builder.set_description(desc);
|
||||
}
|
||||
@ -134,9 +135,9 @@ impl machines::Server for Machines {
|
||||
) -> Promise<(), capnp::Error> {
|
||||
let rc = Rc::clone(&self.session);
|
||||
if self.session.borrow().is_some() {
|
||||
let name = {
|
||||
let id = {
|
||||
let params = pry!(params.get());
|
||||
pry!(params.get_name()).to_string()
|
||||
pry!(params.get_id()).to_string()
|
||||
};
|
||||
|
||||
let network = self.network.clone();
|
||||
@ -145,17 +146,18 @@ impl machines::Server for Machines {
|
||||
let user = &session.as_ref().unwrap().authzid;
|
||||
let permissions = &session.as_ref().unwrap().perms;
|
||||
|
||||
if let Some(machine) = network.machines.get(&name) {
|
||||
if let Some(machine) = network.machines.get(&id) {
|
||||
let mut builder = results.get().init_machine();
|
||||
let perms = Perms::get_for(&machine.desc.privs, permissions.iter());
|
||||
builder.set_name(&name);
|
||||
builder.set_id(&id);
|
||||
builder.set_name(&machine.desc.name);
|
||||
if let Some(ref desc) = machine.desc.description {
|
||||
builder.set_description(desc);
|
||||
}
|
||||
if let Some(ref wiki) = machine.desc.wiki {
|
||||
builder.set_wiki(wiki);
|
||||
}
|
||||
builder.set_urn(&format!("urn:fabaccess:resource:{}", &name));
|
||||
builder.set_urn(&format!("urn:fabaccess:resource:{}", &id));
|
||||
|
||||
let machineapi = Machine::new(user.clone(), perms, machine.clone());
|
||||
let state = machine.get_status().await;
|
||||
|
@ -59,16 +59,16 @@ impl Index {
|
||||
// memory
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Machine {
|
||||
pub id: uuid::Uuid,
|
||||
pub id: MachineIdentifier,
|
||||
pub desc: MachineDescription,
|
||||
|
||||
inner: Arc<Mutex<Inner>>,
|
||||
}
|
||||
|
||||
impl Machine {
|
||||
pub fn new(inner: Inner, desc: MachineDescription) -> Self {
|
||||
pub fn new(inner: Inner, id: MachineIdentifier, desc: MachineDescription) -> Self {
|
||||
Self {
|
||||
id: uuid::Uuid::default(),
|
||||
id,
|
||||
inner: Arc::new(Mutex::new(inner)),
|
||||
desc,
|
||||
}
|
||||
@ -81,7 +81,7 @@ impl Machine {
|
||||
db: Arc<MachineDB>,
|
||||
) -> Machine
|
||||
{
|
||||
Self::new(Inner::new(id, state, db), desc)
|
||||
Self::new(Inner::new(id.clone(), state, db), id, desc)
|
||||
}
|
||||
|
||||
pub fn do_state_change(&self, new_state: MachineState)
|
||||
@ -284,10 +284,10 @@ pub fn load(config: &crate::config::Config, db: Databases, log: &Logger)
|
||||
// TODO: Read state from the state db
|
||||
if let Some(state) = db.get(&k).unwrap() {
|
||||
debug!(log, "Loading old state from db for {}: {:?}", &k, &state);
|
||||
(v.name.clone(), Machine::construct(k, v, state, db.clone()))
|
||||
(k.clone(), Machine::construct(k, v, state, db.clone()))
|
||||
} else {
|
||||
debug!(log, "No old state found in db for {}, creating new.", &k);
|
||||
(v.name.clone(), Machine::construct(k, v, MachineState::new(), db.clone()))
|
||||
(k.clone(), Machine::construct(k, v, MachineState::new(), db.clone()))
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user