Created
September 7, 2017 20:28
-
-
Save cholcombe973/af360f738c94d7d2663e7cdbfb926f0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn run_ceph_command( | |
cluster_handle: rados_t, | |
name: &str, | |
json_data: serde_json::Value, | |
) -> Result<(Option<String>, Option<String>), String> { | |
let mut data: Vec<*mut c_char> = Vec::with_capacity(1); | |
let data_str = CString::new(json_data.to_string()).map_err( | |
|e| e.to_string(), | |
)?; | |
data.push(data_str.as_ptr() as *mut i8); | |
Ok(ceph_mon_command_with_data( | |
cluster_handle, | |
"prefix", | |
name, | |
None, | |
data, | |
).map_err(|e| e.to_string())?) | |
} | |
fn auth_add( | |
cluster_handle: rados_t, | |
osd_id: u64, | |
) -> Result<(Option<String>, Option<String>), String> { | |
let id_data = json!({ | |
"entity": format!("osd.{}", osd_id), | |
"caps": ["mon allow profile osd", "osd allow *"] | |
}); | |
Ok(run_ceph_command(cluster_handle, "auth add", id_data)?) | |
} | |
fn main() { | |
let cluster_handle = | |
connect_to_ceph("admin", "/etc/ceph/ceph.conf").expect("failed to connect to ceph"); | |
let result = auth_add(cluster_handle, 1); | |
println!("result: {:?}", result); | |
} | |
Running this gives: | |
result: Err("Unknown error -22\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\u{0}\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