Detailed instructions for use are in the User's Guide.
[. . . ] API Guide API Guide API Guide API Guide API Guide
StorNext® SNAPI 2. 0. 1
StorNext
6-01375-05
StorNext API Guide, 6-01375-05, Ver. Quantum Corporation provides this publication "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability or fitness for a particular purpose. Quantum Corporation may revise this publication from time to time without notice. COPYRIGHT STATEMENT Copyright 2008 by Quantum Corporation. [. . . ] --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <ARGUMENT name="archiveName" value="Andromeda"/> <ARGUMENT name="state" value="ON"/> </COMMAND> Response:
<?xml version="1. 0" encoding="UTF-8" standalone="yes" ?> <RESPONSE name="SetArchiveState" statusCode="0" status="SUCCESS" statusDescription="Command Successful"> <STATUSDETAIL name="archiveName" value="Andromeda" statusCode="0" status="SUCCESS" statusDescription="Command Successful"/> </RESPONSE>
2 2
2
C++ Class Declaration class SetArchiveState : public Request { public: /// State values enum StateType { ONLINE=0, OFFLINE }; /// Primary Constructor /// This constructor is intended for primary instantiation of the /// object, providing it the archive name and state. SetArchiveState(const std::string& inArchiveName,
2
StorNext API Guide
72
Chapter 2 StorNext Storage Manager APIs API Descriptions and Arguments
const StateType& inArchiveState); /// Method to return the archive name const std::string& getArchiveName() const; /// Method to return the archive state const StateType& getArchiveState() const; /// Method to return the archive state as a string const std::string& getArchiveStateAsString() const; /// method to return the local status const Status& getLocalStatus() const; }
SetDirAttributes
2
This API allows you to set the following directory attributes: · store (enable or disable) · truncate (enable or disable) · policy class name for the directory
Input directoryName: The name of the directory for which you want to set attributes. policyClass: The name of the policy class you want to apply to the directory.
2
Output status: SUCCESS, FAILURE, SUBFAILURE, or SYNTAXERROR status code.
2
StorNext API Guide
73
Chapter 2 StorNext Storage Manager APIs API Descriptions and Arguments
XML Example Request: <?xml version="1. 0" encoding="UTF-8" standalone="yes" ?> <!-- Set the attributes for a specific directory. --> <COMMAND name="SetDirAttributes"> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- directoryName : name of directory --> <!-- noTruncate : TRUE, FALSE --> <!-- noStore : TRUE, FALSE --> <!-- policyClass : valid policy class name --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- The directoryName argument is required exactly once. --> <!-- At least one of the following arguments are required, but --> <!-- no more than one of each: --> <!-- noTruncate --> <!-- noStore --> <!-- policyClass --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <ARGUMENT name="directoryName" value="/snfs/mydirectory"/> <ARGUMENT name="noTruncate" value="TRUE"/> <ARGUMENT name="noStore" value="TRUE"/> <ARGUMENT name="policyClass" value="mypolicyclass"/> </COMMAND> Response:
<?xml version="1. 0" encoding="UTF-8" standalone="yes" ?> <RESPONSE name="SetDirAttributes" statusCode="0" status="SUCCESS" statusDescription="Command Successful"> <STATUSDETAIL name="directoryName" value="/snfs/mydirectory" statusCode="0" status="SUCCESS" statusDescription="Command Successful"/> </RESPONSE>
2 2
2
C++ Class Declaration class SetDirAttributes : public Request { public: /// Primary Constructor
2
StorNext API Guide
74
Chapter 2 StorNext Storage Manager APIs API Descriptions and Arguments
/// This constructor is intended for primary instantiation of the object, /// providing it the directory name, policy class, truncate, and store /// settings. /// the state SetDirAttributes(const std::string& inDirectoryName, const std::string& inPolicyClass, const bool& inNoTruncate, const bool& inNoStore); /// Secondary Constructor /// This constructor is a secondary means to instantiate the object, /// the state SetDirAttributes(const std::string& inDirectoryName); /// Method to return the directory name const std::string& getDirectoryName() const; /// Method to return the policy class const std::string& getPolicyClass() const; /// Method to return the noTruncate flag bool getNoTruncateFlag() const; /// Method to return the noStore flag bool getNoStoreFlag() const; /// Method to return the local status const StatusPair& getLocalStatus() const; }
SetDriveState
2
This API allows you to set the drive state to ON or OFF.
Input drivename: The name of the drive whose state you want to set. state: ON or OFF.
2
StorNext API Guide
75
Chapter 2 StorNext Storage Manager APIs API Descriptions and Arguments
Output status: SUCCESS, FAILURE, SUBFAILURE, or SYNTAXERROR status code.
2
XML Example Request: <?xml version="1. 0" encoding="UTF-8" standalone="yes" ?> <!-- Set the operating state of a specific drive. --> <COMMAND name="SetDriveState"> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- drivename : valid drive name --> <!-- state : ON, OFF --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- Exactly one each of the above arguments is required. --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <ARGUMENT name="drivename" value="lto2-001"/> <ARGUMENT name="state" value="ON"/> </COMMAND> Response:
2 2
2
<?xml version="1. 0" encoding="UTF-8" standalone="yes" ?> <RESPONSE name="SetDriveState" statusCode="0" status="SUCCESS" statusDescription="Command Successful"> <STATUSDETAIL name="drivename" value="Andromeda_LTO_Drive1" statusCode="0" status="SUCCESS" statusDescription="Command Successful"/> </RESPONSE>
C++ Class Declaration class SetDriveState : public Request { public: /// Drive state values. enum DriveState { ON = 0, OFF
2
StorNext API Guide
76
Chapter 2 StorNext Storage Manager APIs API Descriptions and Arguments
}; /// Primary Constructor /// This constructor is intended for primary instantiation /// of the object, providing it the drive name and state. SetDriveState(const std::string& inDriveName, const DriveState& inDriveState); /// Method to return the drivename std::string getDrivename() const; /// Method to return the drive state DriveState getDriveState() const; /// Method to return the drive state as a string std::string getDriveStateAsString() const; /// Method to return the local status pair const StatusPair& getLocalStatus() const; }
SetFileAttributes
2
This API allows you to set the following attributes for a file: · store (enable or disable) · truncate (enable or disable)
Input fileName: The name of the file for which you want to set attributes. noTruncate: TRUE or FALSE.
2
Output status: SUCCESS, FAILURE, SUBFAILURE, or SYNTAXERROR status code.
2
StorNext API Guide
77
Chapter 2 StorNext Storage Manager APIs API Descriptions and Arguments
XML Example Request:
2 2
<?xml version="1. 0" encoding="UTF-8" standalone="yes" ?> <!-- Set the attributes for a specific file. --> <COMMAND name="SetFileAttributes"> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- fileName : name of file --> <!-- noTruncate : TRUE, FALSE --> <!-- noStore : TRUE, FALSE --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- The fileName argument is required exactly once. --> <!-- At least one of the following arguments are required, but --> <!-- no more than one of each: --> <!-- noTruncate --> <!-- noStore --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <ARGUMENT name="fileName" value="/snfs/myDirectory/myFile. dat"/> <ARGUMENT name="noTruncate" value="TRUE"/> <ARGUMENT name="noStore" value="TRUE"/> </COMMAND>
Response:
2
<?xml version="1. 0" encoding="UTF-8" standalone="yes" ?> <RESPONSE name="SetFileAttributes" statusCode="0" status="SUCCESS" statusDescription="Command Successful"> <STATUSDETAIL name="filename" value="/snfs/myDirectory/myFile. dat" statusCode="0" status="SUCCESS" statusDescription="Command Successful"/> </RESPONSE>
C++ Class Declaration class SetFileAttributes : public Request { public: /// Primary Constructor /// This constructor is intended for primary instantiation of the object, /// providing it the file name, notruncate, and nostore attributes to be /// set for the file. SetFileAttributes(const std::string& inFileName, const bool& inNoTruncate,
2
StorNext API Guide
78
Chapter 2 StorNext Storage Manager APIs API Descriptions and Arguments
const bool&
inNoStore);
/// Secondary Constructor /// This constructor is a secondary means to instantiate the object, SetFileAttributes(const std::string& inFileName); /// Method to return the fileName const std::string& getFileName() const; /// Method to return the noTruncate flag bool getNoTruncateFlag() const; /// Method to return the noStore flag bool getNoStoreFlag() const; /// Method to return the local status const StatusPair& getLocalStatus() const; }
SetMediaState
2
This API allows you to set the state for one or more piece of media.
Input state: AVAIL (available), UNAVAIL (not available), PROTECT (write protected), UNPROTECT (not write protected), UNMARK (not marked), or UNSUSP (not suspect).
2
mediaID: The ID of the media whose state you want to set. When entering multiple media IDs, enter one media ID per line.
Output status: SUCCESS, FAILURE, SUBFAILURE, or SYNTAXERROR status code for each media ID entered.
2
XML Example Request: <?xml version="1. 0" encoding="UTF-8" standalone="yes" ?>
2 2
StorNext API Guide
79
Chapter 2 StorNext Storage Manager APIs API Descriptions and Arguments
<!-- Set the operating state for specific media. --> <COMMAND name="SetMediaState"> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- state : avail, unavail, protect, unprotect, unmark, unsusp --> <!-- (the state will be set on all specified media) --> <!-- mediaID : valid media ID --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <!-- The state argument is required exactly once. --> <!-- One or more mediaID arguments are required. --> <!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - --> <ARGUMENT name="state" value="avail"/> <ARGUMENT name="mediaID" value="025311"/> <ARGUMENT name="mediaID" value="025312"/> </COMMAND> Response:
<?xml version="1. 0" encoding="UTF-8" standalone="yes" ?> <RESPONSE name="SetMediaState" statusCode="0" status="SUCCESS" statusDescription="Command Successful"> <!-- A status detail element will be returned for each media --> <STATUSDETAIL name="mediaID" value="025311" statusCode="0" status="SUCCESS" statusDescription="Command Successful"/> <STATUSDETAIL name="mediaID" value="025312" statusCode="0" status="SUCCESS" statusDescription="Command Successful"/> </RESPONSE>
2
C++ Class Declaration class SetMediaState : public Request { public: /// Media State values enum MediaState { MEDIA_STATE_TYPE_START=0, AVAIL=MEDIA_STATE_TYPE_START, UNAVAIL, PROTECT, UNPROTECT,
2
StorNext API Guide
80
Chapter 2 StorNext Storage Manager APIs API Descriptions and Arguments
UNMARK, UNSUSP, MEDIA_STATE_TYPE_END }; /// Primary Constructor /// This constructor is intended for primary instantiation of the object, /// providing it the media name and state. SetMediaState(const std::string& inMediaID, const MediaState& inState); /// Secondary Constructor /// This constructor is intended for instantiation of the object from a /// vector of media ids SetMediaState(const MediaList& inMedia, const MediaState& inState); /// Method to retrieve the map of mediaIDs to their status' std::map<std::string, Status> getMediaMap() const; /// Method to return the media state const MediaState& getMediaState() const; /// Method to return the media state as a string const std::string& getMediaStateAsString() const; /// Method to return the list of media MediaList getMediaList() const; /// Method to return the list of local status pairs const StatusPairList& getLocalStatus() const; /// Method to return the specific local status pair for a given mediaID const StatusPair& getLocalStatus(const std::string& mediaID) const; }
SetPolicy
2
This API allows you to set the number of copies and the maximum number of inactive versions for a policy class.
StorNext API Guide
81
Chapter 2 StorNext Storage Manager APIs API Descriptions and Arguments
Input policyClass: The name of the policy class for which you want to set arguments, or enter "all" to apply arguments to all policy classes. numberOfCopies: The number of copies to maintain for the policy class. maxInactiveVersions: The maximum of versions to maintain for the policy class. [. . . ] All examples in this appendix apply only to the Storage Manger APIs, not the File System APIs. The makefiles are designed to work with the C++ files. Put the C++ source files and the makefile appropriate to your operating system into the same directory and then run the make command to create executable binaries. (The makefiles and C++ files can be found in the directory /usr/ adic/SNAPI/examples. )
C++ Test Program Example
Following is a test program for the GetFileAttribute API.
2
//////////////////////////////////////////////////////////////// // Copyright 2007 Quantum, Inc. [. . . ]