Skip to content

Commit 5f0c94d

Browse files
committed
Adding API support for getting tape drive information as well as tape failure information.
1 parent 8dc3782 commit 5f0c94d

File tree

13 files changed

+589
-0
lines changed

13 files changed

+589
-0
lines changed

ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3Client.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,15 @@ GetTapeLibrariesResponse getTapeLibraries(GetTapeLibrariesRequest request)
309309
GetTapeLibraryResponse getTapeLibrary(GetTapeLibraryRequest request)
310310
throws IOException, SignatureException;
311311

312+
GetTapeDrivesResponse getTapeDrives(GetTapeDrivesRequest request)
313+
throws IOException, SignatureException;
314+
315+
GetTapeDriveResponse getTapeDrive(GetTapeDriveRequest request)
316+
throws IOException, SignatureException;
317+
318+
GetTapeFailureResponse getTapeFailure(GetTapeFailureRequest request)
319+
throws IOException, SignatureException;
320+
312321
/**
313322
* Creates a new Ds3Client instance for the system pointed to by Node.
314323
*/

ds3-sdk/src/main/java/com/spectralogic/ds3client/Ds3ClientImpl.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,21 @@ public GetTapeLibraryResponse getTapeLibrary(final GetTapeLibraryRequest request
265265
return new GetTapeLibraryResponse(this.netClient.getResponse(request));
266266
}
267267

268+
@Override
269+
public GetTapeDrivesResponse getTapeDrives(final GetTapeDrivesRequest request) throws IOException, SignatureException {
270+
return new GetTapeDrivesResponse(this.netClient.getResponse(request));
271+
}
272+
273+
@Override
274+
public GetTapeDriveResponse getTapeDrive(final GetTapeDriveRequest request) throws IOException, SignatureException {
275+
return new GetTapeDriveResponse(this.netClient.getResponse(request));
276+
}
277+
278+
@Override
279+
public GetTapeFailureResponse getTapeFailure(final GetTapeFailureRequest request) throws IOException, SignatureException {
280+
return new GetTapeFailureResponse(this.netClient.getResponse(request));
281+
}
282+
268283
@Override
269284
public Ds3Client newForNode(final Node node) {
270285
final ConnectionDetails newConnectionDetails = ConnectionDetailsImpl.newForNode(node, this.getConnectionDetails());
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2015 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
16+
package com.spectralogic.ds3client.commands;
17+
18+
import com.spectralogic.ds3client.HttpVerb;
19+
20+
import java.util.UUID;
21+
22+
public class GetTapeDriveRequest extends AbstractRequest {
23+
24+
private final UUID id;
25+
26+
public GetTapeDriveRequest(final UUID id) {
27+
this.id = id;
28+
}
29+
30+
@Override
31+
public String getPath() {
32+
return "/_rest_/tape_drive/" + id.toString();
33+
}
34+
35+
@Override
36+
public HttpVerb getVerb() {
37+
return HttpVerb.GET;
38+
}
39+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2015 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
16+
package com.spectralogic.ds3client.commands;
17+
18+
import com.spectralogic.ds3client.models.tape.TapeDrive;
19+
import com.spectralogic.ds3client.networking.WebResponse;
20+
import com.spectralogic.ds3client.serializer.XmlOutput;
21+
22+
import java.io.IOException;
23+
import java.io.InputStream;
24+
25+
public class GetTapeDriveResponse extends AbstractResponse {
26+
27+
private TapeDrive tapeDrive;
28+
29+
public GetTapeDriveResponse(final WebResponse response) throws IOException {
30+
super(response);
31+
}
32+
33+
@Override
34+
protected void processResponse() throws IOException {
35+
try (final WebResponse response = getResponse()) {
36+
this.checkStatusCode(200);
37+
try (final InputStream inputStream = response.getResponseStream()) {
38+
this.tapeDrive = XmlOutput.fromXml(inputStream, TapeDrive.class);
39+
}
40+
}
41+
}
42+
43+
public TapeDrive getTapeDrive() {
44+
return tapeDrive;
45+
}
46+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2015 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
16+
package com.spectralogic.ds3client.commands;
17+
18+
import com.spectralogic.ds3client.HttpVerb;
19+
20+
public class GetTapeDrivesRequest extends AbstractRequest {
21+
@Override
22+
public String getPath() {
23+
return "/_rest_/tape_drive";
24+
}
25+
26+
@Override
27+
public HttpVerb getVerb() {
28+
return HttpVerb.GET;
29+
}
30+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2015 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
16+
package com.spectralogic.ds3client.commands;
17+
18+
import com.spectralogic.ds3client.models.tape.TapeDrive;
19+
import com.spectralogic.ds3client.models.tape.TapeDrives;
20+
import com.spectralogic.ds3client.networking.WebResponse;
21+
import com.spectralogic.ds3client.serializer.XmlOutput;
22+
23+
import java.io.IOException;
24+
import java.io.InputStream;
25+
import java.util.List;
26+
27+
public class GetTapeDrivesResponse extends AbstractResponse {
28+
29+
private List<TapeDrive> tapeDrives;
30+
31+
public GetTapeDrivesResponse(final WebResponse response) throws IOException {
32+
super(response);
33+
}
34+
35+
@Override
36+
protected void processResponse() throws IOException {
37+
try (final WebResponse response = getResponse()) {
38+
this.checkStatusCode(200);
39+
try (final InputStream inputStream = response.getResponseStream()) {
40+
this.tapeDrives = XmlOutput.fromXml(inputStream, TapeDrives.class).getTapeDrives();
41+
}
42+
}
43+
}
44+
45+
public List<TapeDrive> getTapeDrives() {
46+
return tapeDrives;
47+
}
48+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2015 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
16+
package com.spectralogic.ds3client.commands;
17+
18+
import com.spectralogic.ds3client.HttpVerb;
19+
20+
public class GetTapeFailureRequest extends AbstractRequest {
21+
@Override
22+
public String getPath() {
23+
return "/_rest_/tape_failure";
24+
}
25+
26+
@Override
27+
public HttpVerb getVerb() {
28+
return HttpVerb.GET;
29+
}
30+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2015 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
16+
package com.spectralogic.ds3client.commands;
17+
18+
import com.spectralogic.ds3client.models.tape.TapeFailure;
19+
import com.spectralogic.ds3client.models.tape.TapeFailures;
20+
import com.spectralogic.ds3client.networking.WebResponse;
21+
import com.spectralogic.ds3client.serializer.XmlOutput;
22+
23+
import java.io.IOException;
24+
import java.io.InputStream;
25+
import java.util.List;
26+
27+
public class GetTapeFailureResponse extends AbstractResponse {
28+
private List<TapeFailure> tapeFailures;
29+
public GetTapeFailureResponse(final WebResponse response) throws IOException {
30+
super(response);
31+
}
32+
33+
@Override
34+
protected void processResponse() throws IOException {
35+
try (final WebResponse response = getResponse()) {
36+
this.checkStatusCode(200);
37+
try (final InputStream inputStream = response.getResponseStream()) {
38+
this.tapeFailures = XmlOutput.fromXml(inputStream, TapeFailures.class).getTapeFailures();
39+
}
40+
}
41+
}
42+
43+
public List<TapeFailure> getTapeFailures() {
44+
return tapeFailures;
45+
}
46+
}
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* ******************************************************************************
3+
* Copyright 2014-2015 Spectra Logic Corporation. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
5+
* this file except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* or in the "license" file accompanying this file.
10+
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
11+
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
12+
* specific language governing permissions and limitations under the License.
13+
* ****************************************************************************
14+
*/
15+
16+
package com.spectralogic.ds3client.models.tape;
17+
18+
import com.fasterxml.jackson.annotation.JsonProperty;
19+
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
20+
21+
import java.util.UUID;
22+
23+
@JacksonXmlRootElement(namespace = "Data")
24+
public class TapeDrive {
25+
@JsonProperty("ErrorMessage")
26+
private String errorMessage;
27+
@JsonProperty("ForceTapeRemoval")
28+
private boolean forceTapeRemoval;
29+
@JsonProperty("Id")
30+
private UUID id;
31+
@JsonProperty("PartitionId")
32+
private UUID partitionId;
33+
@JsonProperty("SerialNumber")
34+
private String serialNumber;
35+
@JsonProperty("State")
36+
private State state;
37+
@JsonProperty("TapeId")
38+
private UUID tapeId;
39+
@JsonProperty("Type")
40+
private Type type;
41+
42+
public String getErrorMessage() {
43+
return errorMessage;
44+
}
45+
46+
public void setErrorMessage(String errorMessage) {
47+
this.errorMessage = errorMessage;
48+
}
49+
50+
public boolean isForceTapeRemoval() {
51+
return forceTapeRemoval;
52+
}
53+
54+
public void setForceTapeRemoval(boolean forceTapeRemoval) {
55+
this.forceTapeRemoval = forceTapeRemoval;
56+
}
57+
58+
public UUID getId() {
59+
return id;
60+
}
61+
62+
public void setId(UUID id) {
63+
this.id = id;
64+
}
65+
66+
public UUID getPartitionId() {
67+
return partitionId;
68+
}
69+
70+
public void setPartitionId(UUID partitionId) {
71+
this.partitionId = partitionId;
72+
}
73+
74+
public String getSerialNumber() {
75+
return serialNumber;
76+
}
77+
78+
public void setSerialNumber(String serialNumber) {
79+
this.serialNumber = serialNumber;
80+
}
81+
82+
public State getState() {
83+
return state;
84+
}
85+
86+
public void setState(State state) {
87+
this.state = state;
88+
}
89+
90+
public UUID getTapeId() {
91+
return tapeId;
92+
}
93+
94+
public void setTapeId(UUID tapeId) {
95+
this.tapeId = tapeId;
96+
}
97+
98+
public Type getType() {
99+
return type;
100+
}
101+
102+
public void setType(Type type) {
103+
this.type = type;
104+
}
105+
106+
public enum State {
107+
NORMAL, OFFLINE, ONLINE_PENDING, ONLINE_IN_PROGRESS, PENDING_INSPECTION, UNKNOWN, DATA_CHECKPOINT_FAILURE,
108+
DATA_CHECKPOINT_MISSING, LTFS_WITH_FOREIGN_DATA, FOREIGN, IMPORT_PENDING, IMPORT_IN_PROGRESS, LOST, BAD,
109+
SERIAL_NUMBER_MISMATCH, BAR_CODE_MISSING, FORMAT_PENDING, FORMAT_IN_PROGRESS, EJECT_TO_EE_IN_PROGRESS,
110+
EJECT_FROM_EE_PENDING, EJECTED
111+
}
112+
113+
public enum Type {
114+
UNKNOWN, LTO5, LTO6, LTO_CLEANING_TAPE, TS_JC, TS_JY, TS_JK, TS_JD, TS_JZ, TS_JL, TS_CLEANING_TAPE, FORBIDDEN
115+
}
116+
}

0 commit comments

Comments
 (0)