Skip to content

Instantly share code, notes, and snippets.

View cholcombe973's full-sized avatar

Chris Holcombe cholcombe973

  • @tesla.com
  • Portland
View GitHub Profile
/// A HashMap representation of the charm's config.yaml, with some
/// extra features:
/// - See which values in the HashMap have changed since the previous hook.
/// - For values that have changed, see what the previous value was.
/// - Store arbitrary data for use in a later hook.
#[derive(Debug)]
pub struct Config {
values: HashMap<String, String>,
}
pub fn enable_volume_quota() -> Result<(), String> {
// Gather our action parameters
let volume = match juju::action_get("volume") {
Ok(v) => v,
Err(e) => {
// Notify the user of the failure and then return the error up the stack
juju::action_fail(&e.to_string()).map_err(|e| e.to_string())?;
return Err(e.to_string());
}
};
pub fn write_async<F>(&self,
file_handle: *mut Struct_glfs_fd,
buffer: &[u8],
flags: i32,
callback: F,
data: &mut ::libc::c_void)
-> Result<(), GlusterError>
where F: Fn(*mut Struct_glfs_fd, isize, *mut ::libc::c_void)
{
let closure = Closure3::new(&callback);
pub fn write_async<F>(&self,
file_handle: *mut Struct_glfs_fd,
buffer: &[u8],
flags: i32,
callback: F,
data: &mut ::libc::c_void)
-> Result<(), GlusterError>
where F: Fn(*mut Struct_glfs_fd, isize, *mut ::libc::c_void)
{
let closure = Closure3::new(&callback);
let keystore = if args.is_present("vault") {
match KeyStore::load_from_vault() {
Ok(keystore) => keystore,
Err(err) => {
error!("Unable to load keyfile: {}", err);
return;
}
}
} else {
let args_keyfile = args.value_of("keyfile")
// Test vector generated manually using Python
const TEST_KEYSTORE_JSON: &'static String = format!("
{{
\"block_secret_key\": \"19646cf14953bf0544aa84ac117c1442b4eb5c4a1fb4c519e5ed97ffcd3fd77d8f6e3cecde0a97dab2ef2d7f67d4a817c9211e2b19d7cc1fa4dc8956c646cccd\",
\"block_id_key\": \"11807f49e4d6acca44fec46f03e760b2ccd72d65f4710253aa58b92bc0ce70199150ae543f42b207a6f67c0cf6964696b03a6fa7a66b9298613fd5f102d5cf3f\",
\"block_kdf_key\": {{
\"key_key\": \"a109c333262f7c12d86b54c35ee402490935572fa91f1828e60137cfa56bd17d04e9313761756e0830068a6da8703e320ccf658454445015b9da36eecd7d0489\",
\"nonce_key\": \"6aeab81744ed1ca990f243de73a0ceb612f150bbf7c2f95af0af9e772977dd69d22b102ac410bc41779ea142ea600ac57a699fef35b34174ccd89c9258a9419b\"
}},
\"block_hmac_key\": \"bf5d949530d910df07ae5aeaf97aa48707ff27d4d6644fb1161681de7f4f1306892f51590199b828eb2084950e5c6a2a8abe31f04b22a2ee186e1f5eb3c279b7\",
Progress: 10MB of 11MB
Reading file: test2
Progress: 10MB of 11MB
Reading file: rust_rados
block_exists
encrypt: data_len: 1048576
encryptor.process final pointer: 0x1891f8c0
ciphertext pointer: 0x1891f8c0
ciphertext first element: Some(40)
mac extend_from_slice 2: 1048608, ptr: 0x18a21040
Reached byte 1048573.
Reached byte 1048574.
Reached byte 1048575.
mac extend_from_slice 2: 1048608
store block: da4ce9b108045a009d7e4e9ef2758e16cba0e0fc73a1d9743f5d945d43e735a9
ioctx pointer: 0x7f36f2438f00
buffer pointer: 0x7f36ebe00000
stored block
block_exists
ioctx pointer: 0x7f36f2438f00
block_exists
ioctx pointer: 0x7fffea438f00
block len: 1048576
encrypt: data_len: 1048576
ciphertext len: 1048576
mac extend_from_slice 1: 32
mac extend_from_slice 2: 1048608
store block: 79971bf403ad62537efc5198a2db58be509694170ca41f75f41686b7045f8713
ioctx pointer: 0x7fffea438f00
buffer pointer: 0x7fffe4000000
#0 0x0000555555726d2d in arena_dalloc_bin_locked_impl ()
#1 0x000055555574108a in je_tcache_bin_flush_small ()
#2 0x0000555555729376 in je_arena_ralloc ()
#3 0x000055555571f4b1 in rallocx ()
#4 0x000055555561e214 in alloc::heap::reallocate (ptr=<optimized out>, old_size=32, size=1048608, align=1)
at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/liballoc/heap.rs:79
#5 alloc::raw_vec::{{impl}}::reserve<u8> (used_cap=32, needed_extra_cap=<optimized out>, self=<optimized out>)
at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/liballoc/raw_vec.rs:427
#6 collections::vec::{{impl}}::reserve<u8> (additional=<optimized out>, self=<optimized out>)
at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/obj/../src/libcollections/vec.rs:428