Skip to content

Commit af348f3

Browse files
committed
Rename error
1 parent e96991e commit af348f3

8 files changed

Lines changed: 187 additions & 179 deletions

File tree

src/brocade.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use self::chrono::offset::Utc;
77
use self::chrono::DateTime;
88
use self::reqwest::header::{qitem, Accept, Headers};
99
use self::serde::de::DeserializeOwned;
10-
use error::{MetricsResult, StorageMetricsError};
10+
use error::{MetricsResult, StorageError};
1111
use ir::{TsPoint, TsValue};
1212
use IntoPoint;
1313

@@ -508,7 +508,7 @@ pub fn login(client: &reqwest::Client, config: &BrocadeConfig) -> MetricsResult<
508508
.ok_or("WStoken missing from server. Cannot proceed".to_string())?;
509509
match token.one() {
510510
Some(data) => Ok(String::from_utf8(data.to_vec())?),
511-
None => Err(StorageMetricsError::new(format!(
511+
None => Err(StorageError::new(format!(
512512
"WSToken multiple lines. {:?}. Please check server",
513513
token
514514
))),

src/error.rs

Lines changed: 132 additions & 132 deletions
Large diffs are not rendered by default.

src/hitachi.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ extern crate reqwest;
77
extern crate serde;
88
extern crate serde_json;
99

10-
use error::{MetricsResult, StorageMetricsError};
10+
use error::{MetricsResult, StorageError};
1111

1212
use std::collections::HashMap;
1313
use std::str;
@@ -420,7 +420,7 @@ pub fn csv_to_points(
420420
"Unable to discover csv fields. Cannot parse record: {}",
421421
text
422422
);
423-
return Err(StorageMetricsError::new("CSV Parsing failure".into()));
423+
return Err(StorageError::new("CSV Parsing failure".into()));
424424
}
425425
let fields = fields.unwrap()?;
426426

src/isilon.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -368,43 +368,43 @@ fn test_node_status() {
368368
// Try to keep these public functions as futures as long as possible to prevent blocking
369369
pub fn get_cluster_usage<C: hyper::client::Connect>(
370370
rc_config: Rc<configuration::Configuration<C>>,
371-
) -> Box<Future<Item = Vec<TsPoint>, Error = StorageMetricsError>> {
371+
) -> Box<Future<Item = Vec<TsPoint>, Error = StorageError>> {
372372
let cluster_api = isilon::apis::ClusterApiClient::new(rc_config.clone());
373373
Box::new(
374374
cluster_api
375375
.get_cluster_statfs()
376376
.map(|res| res.into_point(Some("isilon_usage")))
377-
.map_err(|err| StorageMetricsError::from(err)),
377+
.map_err(|err| StorageError::from(err)),
378378
)
379379
}
380380

381381
pub fn get_cluster_performance<C: hyper::client::Connect>(
382382
rc_config: Rc<configuration::Configuration<C>>,
383-
) -> Box<Future<Item = Vec<TsPoint>, Error = StorageMetricsError>> {
383+
) -> Box<Future<Item = Vec<TsPoint>, Error = StorageError>> {
384384
let stats_api = isilon::apis::StatisticsApiClient::new(rc_config.clone());
385385
Box::new(
386386
stats_api
387387
.get_summary_protocol_stats(true, None, None, 600)
388388
.map(|res| res.into_point(Some("isilon_perf")))
389-
.map_err(|err| StorageMetricsError::from(err)),
389+
.map_err(|err| StorageError::from(err)),
390390
)
391391
}
392392

393393
pub fn get_node_status<C: hyper::client::Connect>(
394394
rc_config: Rc<configuration::Configuration<C>>,
395-
) -> Box<Future<Item = Vec<TsPoint>, Error = StorageMetricsError>> {
395+
) -> Box<Future<Item = Vec<TsPoint>, Error = StorageError>> {
396396
let cluster_api = isilon::apis::ClusterNodesApiClient::new(rc_config.clone());
397397
Box::new(
398398
cluster_api
399399
.get_node_status(None)
400400
.map(|res| res.into_point(Some("isilon_node_status")))
401-
.map_err(|err| StorageMetricsError::from(err)),
401+
.map_err(|err| StorageError::from(err)),
402402
)
403403
}
404404

405405
pub fn get_cluster_drives<C: hyper::client::Connect>(
406406
rc_config: Rc<configuration::Configuration<C>>,
407-
) -> Box<Future<Item = Vec<TsPoint>, Error = StorageMetricsError>> {
407+
) -> Box<Future<Item = Vec<TsPoint>, Error = StorageError>> {
408408
let cluster_api = isilon::apis::ClusterApiClient::new(rc_config.clone());
409409
Box::new(
410410
cluster_api
@@ -422,7 +422,7 @@ pub fn get_cluster_drives<C: hyper::client::Connect>(
422422
}
423423

424424
points
425-
}).map_err(|err| StorageMetricsError::from(err)),
425+
}).map_err(|err| StorageError::from(err)),
426426
)
427427
}
428428

src/netapp.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,29 +74,29 @@ where
7474
T: FromStr,
7575
{
7676
if e.children.is_empty() {
77-
return Err(StorageMetricsError::new(format!("{} not found", tag)));
77+
return Err(StorageError::new(format!("{} not found", tag)));
7878
}
7979
for child in &e.children {
8080
if child.name == tag {
8181
let res = T::from_str(&child.clone().text.unwrap_or("".to_string()));
8282
match res {
8383
Ok(val) => return Ok(val),
8484
Err(_) => {
85-
return Err(StorageMetricsError::new(format!(
85+
return Err(StorageError::new(format!(
8686
"parsing {} failed",
8787
child.name
8888
)))
8989
}
9090
}
9191
}
9292
}
93-
Err(StorageMetricsError::new(format!("{} not found", tag)))
93+
Err(StorageError::new(format!("{} not found", tag)))
9494
}
9595

9696
fn check_failure(e: &treexml::Element) -> MetricsResult<()> {
9797
if let Some(s) = e.attributes.get("status") {
9898
if s == "failed" {
99-
return Err(StorageMetricsError::new(format!(
99+
return Err(StorageError::new(format!(
100100
"netapp query failed: {}",
101101
e.attributes.get("reason").unwrap()
102102
)));
@@ -176,18 +176,18 @@ pub struct PerformanceStat {
176176
impl FromXml for HaPerformanceStats {
177177
fn from_xml(data: &str) -> MetricsResult<Self> {
178178
let doc = Document::parse(data.as_bytes())?;
179-
let root = doc.root.ok_or(StorageMetricsError::new(format!(
179+
let root = doc.root.ok_or(StorageError::new(format!(
180180
"root xml not found for {}",
181181
data
182182
)))?;
183183
let results = root.find_child(|tag| tag.name == "results").ok_or(
184-
StorageMetricsError::new(format!("results tag not found in {:?}", root)),
184+
StorageError::new(format!("results tag not found in {:?}", root)),
185185
)?;
186186
check_failure(&results)?;
187187

188188
let attribute_list = results
189189
.find_child(|tag| tag.name == "attributes-list")
190-
.ok_or(StorageMetricsError::new(format!(
190+
.ok_or(StorageError::new(format!(
191191
"results tag not found in {:?}",
192192
root
193193
)))?;
@@ -384,56 +384,56 @@ pub struct NetappVolume {
384384
impl FromXml for NetappVolumes {
385385
fn from_xml(data: &str) -> MetricsResult<Self> {
386386
let doc = Document::parse(data.as_bytes())?;
387-
let root = doc.root.ok_or(StorageMetricsError::new(format!(
387+
let root = doc.root.ok_or(StorageError::new(format!(
388388
"root xml not found for {}",
389389
data
390390
)))?;
391391
let results = root.find_child(|tag| tag.name == "results").ok_or(
392-
StorageMetricsError::new(format!("results tag not found in {:?}", root)),
392+
StorageError::new(format!("results tag not found in {:?}", root)),
393393
)?;
394394
check_failure(&results)?;
395395

396396
let vols = results
397397
.find_child(|tag| tag.name == "attributes-list")
398-
.ok_or(StorageMetricsError::new(format!(
398+
.ok_or(StorageError::new(format!(
399399
"results tag not found in {:?}",
400400
root
401401
)))?;
402402
let mut volumes: Vec<NetappVolume> = Vec::new();
403403
for vol_child in &vols.children {
404404
let autosize_attributes = vol_child
405405
.find_child(|tag| tag.name == "volume-autosize-attributes")
406-
.ok_or(StorageMetricsError::new(format!(
406+
.ok_or(StorageError::new(format!(
407407
"volume-autosize-attributes tag not found in {:?}",
408408
vol_child
409409
)))?;
410410
let id_attributes = vol_child
411411
.find_child(|tag| tag.name == "volume-id-attributes")
412-
.ok_or(StorageMetricsError::new(format!(
412+
.ok_or(StorageError::new(format!(
413413
"volume-id-attributes tag not found in {:?}",
414414
vol_child
415415
)))?;
416416
let inode_attributes = vol_child
417417
.find_child(|tag| tag.name == "volume-inode-attributes")
418-
.ok_or(StorageMetricsError::new(format!(
418+
.ok_or(StorageError::new(format!(
419419
"volume-inode-attributes tag not found in {:?}",
420420
vol_child
421421
)))?;
422422
let sis_attributes = vol_child
423423
.find_child(|tag| tag.name == "volume-sis-attributes")
424-
.ok_or(StorageMetricsError::new(format!(
424+
.ok_or(StorageError::new(format!(
425425
"volume-sis-attributes tag not found in {:?}",
426426
vol_child
427427
)))?;
428428
let space_attributes = vol_child
429429
.find_child(|tag| tag.name == "volume-space-attributes")
430-
.ok_or(StorageMetricsError::new(format!(
430+
.ok_or(StorageError::new(format!(
431431
"volume-space-attributes tag not found in {:?}",
432432
vol_child
433433
)))?;
434434
let state_attributes = vol_child
435435
.find_child(|tag| tag.name == "volume-state-attributes")
436-
.ok_or(StorageMetricsError::new(format!(
436+
.ok_or(StorageError::new(format!(
437437
"volume-state-attributes tag not found in {:?}",
438438
vol_child
439439
)))?;
@@ -619,12 +619,12 @@ impl FromXml for OnTapVersion {
619619
debug!("parsing ontap data: {}", data);
620620

621621
let doc = Document::parse(data.as_bytes())?;
622-
let root = doc.root.ok_or(StorageMetricsError::new(format!(
622+
let root = doc.root.ok_or(StorageError::new(format!(
623623
"root xml not found for {}",
624624
data
625625
)))?;
626626
let results = root.find_child(|tag| tag.name == "results").ok_or(
627-
StorageMetricsError::new(format!("results tag not found in {:?}", root)),
627+
StorageError::new(format!("results tag not found in {:?}", root)),
628628
)?;
629629
check_failure(&results)?;
630630

src/scaleio.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern crate reqwest;
1414
extern crate serde;
1515
extern crate serde_json;
1616

17-
use error::{MetricsResult, StorageMetricsError};
17+
use error::{MetricsResult, StorageError};
1818
use ir::{TsPoint, TsValue};
1919
use IntoPoint;
2020

@@ -1285,11 +1285,11 @@ pub fn get_api_token(client: &reqwest::Client, config: &ScaleioConfig) -> Metric
12851285

12861286
match api_token(t.as_bytes()) {
12871287
IResult::Done(_, o) => Ok(o.into()),
1288-
IResult::Incomplete(_) => Err(StorageMetricsError::new(format!(
1288+
IResult::Incomplete(_) => Err(StorageError::new(format!(
12891289
"Unable to parse api token {} from server",
12901290
t
12911291
))),
1292-
IResult::Error(e) => Err(StorageMetricsError::new(e.to_string())),
1292+
IResult::Error(e) => Err(StorageError::new(e.to_string())),
12931293
}
12941294
}
12951295

src/vnx.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn parse_data_services_policies(s: &str) -> MetricsResult<HashMap<String, String
7878
let key_value = part.split_terminator("=").collect::<Vec<&str>>();
7979
if key_value.len() != 2 {
8080
// Key=Value isn't formatted here properly
81-
return Err(StorageMetricsError::new(format!(
81+
return Err(StorageError::new(format!(
8282
"Invalid key=value in dataServicesPolicy string: {}",
8383
part
8484
)));
@@ -269,7 +269,7 @@ impl FromXml for NetworkAllSample {
269269
}
270270
Ok(Event::End(_e)) => {}
271271
Err(e) => {
272-
return Err(StorageMetricsError::new(format!(
272+
return Err(StorageError::new(format!(
273273
"invalid xml data from server at position: {}: {:?}",
274274
reader.buffer_position(),
275275
e
@@ -546,7 +546,7 @@ impl FromXml for CifsAllSample {
546546
}
547547
Ok(Event::End(_e)) => {}
548548
Err(e) => {
549-
return Err(StorageMetricsError::new(format!(
549+
return Err(StorageError::new(format!(
550550
"invalid xml data from server at position: {}: {:?}",
551551
reader.buffer_position(),
552552
e
@@ -791,7 +791,7 @@ impl FromXml for NfsAllSample {
791791
}
792792
Ok(Event::End(_e)) => {}
793793
Err(e) => {
794-
return Err(StorageMetricsError::new(format!(
794+
return Err(StorageError::new(format!(
795795
"invalid xml data from server at position: {}: {:?}",
796796
reader.buffer_position(),
797797
e
@@ -873,7 +873,7 @@ impl FromXml for DiskInfo {
873873
}
874874
Ok(Event::End(_e)) => {}
875875
Err(e) => {
876-
return Err(StorageMetricsError::new(format!(
876+
return Err(StorageError::new(format!(
877877
"invalid xml data from server at position: {}: {:?}",
878878
reader.buffer_position(),
879879
e
@@ -998,7 +998,7 @@ impl FromXml for ResourceUsageSample {
998998
}
999999
Ok(Event::End(_e)) => {}
10001000
Err(e) => {
1001-
return Err(StorageMetricsError::new(format!(
1001+
return Err(StorageError::new(format!(
10021002
"invalid xml data from server at position: {}: {:?}",
10031003
reader.buffer_position(),
10041004
e
@@ -1125,7 +1125,7 @@ impl FromXml for FilesystemUsage {
11251125
}
11261126
Ok(Event::End(_e)) => {}
11271127
Err(e) => {
1128-
return Err(StorageMetricsError::new(format!(
1128+
return Err(StorageError::new(format!(
11291129
"invalid xml data from server at position: {}: {:?}",
11301130
reader.buffer_position(),
11311131
e
@@ -1530,7 +1530,7 @@ impl FromXml for Volumes {
15301530
}
15311531
}
15321532
Err(e) => {
1533-
return Err(StorageMetricsError::new(format!(
1533+
return Err(StorageError::new(format!(
15341534
"invalid xml data from server at position: {}: {:?}",
15351535
reader.buffer_position(),
15361536
e
@@ -1727,7 +1727,7 @@ impl FromXml for StoragePools {
17271727
}
17281728
Ok(Event::Empty(_e)) => {}
17291729
Err(e) => {
1730-
return Err(StorageMetricsError::new(format!(
1730+
return Err(StorageError::new(format!(
17311731
"invalid xml data from server at position: {}: {:?}",
17321732
reader.buffer_position(),
17331733
e
@@ -1792,12 +1792,12 @@ pub fn login_request(
17921792
jar.add(parsed);
17931793
Ok(())
17941794
}
1795-
None => Err(StorageMetricsError::new(
1795+
None => Err(StorageError::new(
17961796
"Cookie missing from server".into(),
17971797
)),
17981798
}
17991799
}
1800-
None => Err(StorageMetricsError::new(
1800+
None => Err(StorageError::new(
18011801
"Server responded 200 OK but cookie not set. Cannot proceed further".into(),
18021802
)),
18031803
}
@@ -1823,7 +1823,7 @@ pub fn logout_request(
18231823
headers.set_raw("Cookie", cookie);
18241824
}
18251825
None => {
1826-
return Err(StorageMetricsError::new(
1826+
return Err(StorageError::new(
18271827
"Unable to find Ticket cookie from vnx server".into(),
18281828
));
18291829
}
@@ -1834,7 +1834,7 @@ pub fn logout_request(
18341834
headers.set_raw("CelerraConnector-Sess", t.value());
18351835
}
18361836
None => {
1837-
return Err(StorageMetricsError::new(
1837+
return Err(StorageError::new(
18381838
"Unable to find JSESSIONID cookie from vnx server".into(),
18391839
));
18401840
}
@@ -1875,7 +1875,7 @@ where
18751875
//headers.set_raw("Cookie", ticket_cookie);
18761876
}
18771877
None => {
1878-
return Err(StorageMetricsError::new(
1878+
return Err(StorageError::new(
18791879
"Unable to find Ticket cookie from vnx server".into(),
18801880
));
18811881
}

vscode.code-workspace

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"folders": [
3+
{
4+
"path": "."
5+
}
6+
],
7+
"settings": {}
8+
}

0 commit comments

Comments
 (0)