Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clippy Lints #37

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions examples/ceph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
extern crate ceph;
extern crate libc;

use ceph::JsonData;
#[cfg(target_os = "linux")]
use ceph::admin_sockets::*;
#[cfg(target_os = "linux")]
use ceph::ceph as ceph_helpers;
#[cfg(target_os = "linux")]
use ceph::rados;
use ceph::JsonData;

#[cfg(not(target_os = "linux"))]
fn main() {}
Expand All @@ -42,10 +42,10 @@ fn main() {
match admin_socket_command("help", "/var/run/ceph/ceph-mon.ip-172-31-31-247.asok") {
Ok(json) => {
println!("{}", json);
},
}
Err(e) => {
println!("{}", e);
},
}
}

let rados_version = ceph_helpers::rados_libversion();
Expand Down Expand Up @@ -88,22 +88,24 @@ fn main() {
Ok((outbuf, outs)) => {
match outbuf {
Some(output) => println!("Ceph mon command (outbuf):\n{}", output),
None => {},
None => {}
}
match outs {
Some(output) => println!("Ceph mon command (outs):\n{}", output),
None => {},
None => {}
}
},
}
Err(e) => {
println!("{:?}", e);
},
}
}

// This command encapsulates the lower level mon, osd, pg commands and returns JsonData
// objects based on the key path
println!("{:?}",
cluster.ceph_command("prefix", "status", ceph_helpers::CephCommandTypes::Mon, &["health"]));
println!(
"{:?}",
cluster.ceph_command("prefix", "status", ceph_helpers::CephCommandTypes::Mon, &["health"])
);

// Get a list of Ceph librados commands in JSON format.
// It's very long so it's commented out.
Expand All @@ -129,14 +131,16 @@ fn main() {
Ok((outbuf, outs)) => {
match outbuf {
Some(output) => println!("Ceph mon command (outbuf):\n{}", output),
None => {},
None => {}
}
match outs {
Some(output) => println!("Ceph mon command (outs):\n{}", output),
None => {},
None => {}
}
},
Err(e) => {println!("{:?}", e);},
}
Err(e) => {
println!("{:?}", e);
}
}

// Print CephHealth of cluster
Expand All @@ -146,7 +150,10 @@ fn main() {
println!("{}", cluster.ceph_status(&["health", "overall_status"]).unwrap());

// This command encapsulates the lower level mon, osd, pg commands and returns JsonData objects based on the key path
println!("{:?}", cluster.ceph_command("prefix", "status", ceph_helpers::CephCommandTypes::Mon, &["health"]));
println!(
"{:?}",
cluster.ceph_command("prefix", "status", ceph_helpers::CephCommandTypes::Mon, &["health"])
);

// Get a list of Ceph librados commands in JSON format.
// It's very long so it's commented out.
Expand Down
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ wrap_comments = true

report_todo = "Always"
report_fixme = "Always"
use_try_shorthand = true
8 changes: 4 additions & 4 deletions src/admin_sockets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ pub fn admin_socket_raw_command(cmd: &str, socket: &str) -> RadosResult<String>
let mut buffer = vec![0; 4]; // Should return 4 bytes with size or indicator.
let cmd = &format!("{}\0", cmd); // Terminator so don't add one to commands.

let mut stream = try!(UnixStream::connect(socket));
let wb = try!(stream.write(cmd.as_bytes()));
let ret_val = try!(stream.read(&mut buffer));
let mut stream = UnixStream::connect(socket)?;
let wb = stream.write(cmd.as_bytes())?;
let ret_val = stream.read(&mut buffer)?;
if ret_val < 4 {
try!(stream.shutdown(Shutdown::Both));
stream.shutdown(Shutdown::Both)?;
return Err(RadosError::new(
"Admin socket: Invalid command or socket did not return any data".to_string(),
));
Expand Down
Loading