Cybersecurity
DevOps Cloud (ADM)
IT Operations Cloud
In NetWare, most iManager plugin developers use NJCL to configure and manage remote servers. NJCL provides file and directory access APIs in Java. When accessing iManager the eDirectory admin (or any user with sufficient rights) logs into the tree and hence has access to all volumes and files on all the servers that are in the tree. Hence writing information (configuration information that needs to be written) to a remote server using NJCL was a good solution. However NJCL is not being supported in Linux any more. Thus we need an alternative way to satisfy the same requirement in Linux servers. Three alternative approaches can be thought of to solve the problem of remote configuration and management in Linux servers:
In the following sections iManager developers will get introduced to the convenient way of using CIM based services for remote management of Linux servers. It is assumed that the reader is familiar with iManager plugin development and the basics of writing a CIM provider. The reader is advised to go through the Supplementary section for better familiarity with CIM technologies.
[Description ("This class represents a session with a file.")]
class MyFileSession {
[Description ("The ID of the current session"), Key ]
uint32 ID;
[Description ("The name of the file to access") ]
String filename;
[Description ("Write to the file. Returns 0 on success ") ]
uint32 write ([in (true), out (false)] string to Write);
[Description ("Read from the file."
"Returns OK on success, EOF if end of file is reached "
"while reading, and ERROR if an error occurred while reading. "
"Length is the desired length requested by the client. ") ,
ValueMap {“0", "1", "2”},
Values {“OK", "EOF", "ERROR”}]
uint32 read ([out (true), in (false)] string buf,
[in (true), out (false)] uint32 length);
};
Remote read and write of any file can be done by directly calling the invokeMethod() of the provider from a CIM client interface defined in iManager. Given below are the steps to define the CIM client in iManager. The details regarding string manipulations and exception handling have been deliberately removed to stress on the basic functionality.
Authenticating to CIMOM: In Linux LUM is required for authentication. The authenticator calls into PAM. Authentication to CIMOM occurs when a user logs into an eDirectory tree and tries to access CIM for the first time. This will set up the Session. Given below are the steps of authenticating an iManager CIM client.
From here onwards iManager can call on the MyCIMClient’s read() or write() methods. These methods call invokemethods() on the CIM provider which we have defined in the earlier section. An implementation of the CIM client is given in the next section.
Defining a CIM client from iManager: Figure 2 is the skeleton program of a CIM client class in iManager.
public class MyCIMClient
{
private CIMObjectPath cop = null;
private CIMClient client;
private CIMObjectPath myCop;
private CIMClass myClass;
private String MY_CIM_CLASS = "MyFileSession";
public MyCIMClient (
String uriHostOrIP, //Host or IPAddres of the server to contact
UserPrincipal principal,
PasswordCredential credential){
CIMNameSpace cns = new CIMNameSpace (“https://” uriHostOrIP “: 5989”);
try{
client = new CIMClient(cns, principal, credential);
myCop = new CIMObjectPath (MY_CIM_CLASS);
myClass = client.getClass (myCop);
} catch (CIMException e){/*Ignoring Exception handling*/}
}
private CIMObjectPath getMyPath(long sessionID){
CIMValue sessionIDValue = new CIMValue (new UnsignedInt32 (sessionID),
new CIMDataType(CIMDataType.UINT32));
CIMObjectPath myPath = new CIMObjectPath (MY_CIM_CLASS);
myPath.addKey ("ID", sessionIDValue);
return myPath;
}
private CIMObjectPath createMyInstance (String filename){
long sessionID = 0;
CIMInstance myInstance = myClass.newInstance ();
CIMValue filenameValue = new CIMValue (filename, new CIMDataType (CIMDataType.STRING));
try {
myInstance.setProperty ("filename", filenameValue);
} catch (CIMException e){/*Ignoring Exception Handling*/}
CIMValue sessionIDValue = new CIMValue (new UnsignedInt32 (sessionID), new CIMDataType (CIMDataType.UINT32));
try {
myInstance.setProperty ("ID", sessionIDValue);
} catch (CIMException e){/*Ignoring Exception Handling*/}
CIMObjectPath cop = new CIMObjectPath ();
cop = client.createInstance (myCop, myInstance);
}
public void open(String filename){ //filename for the file with path to open
CIMObjectPath newCop = null;
try{
newCop = createMyInstance (filename);
} catch (CIMException e){/*Ignoring Exception Handling*/}
CIMProperty key = newCop.getKey("ID");
CIMValue sessionIDValue = key.getValue();
long sessionID = ((UnsignedInt32)sessionIDValue.getValue()).longValue();
cop = getMyPath(sessionID);
}
public void close(){
try{
client.deleteInstance(cop);
} catch (CIMException e){}
}
public String read(long length){
CIMArgument[] inArgs = new CIMArgument[1];
CIMValue lengthValue = new CIMValue(new UnsignedInt32(length), new
CIMDataType(CIMDataType.UINT32));
inArgs[0] = new CIMArgument("length", lengthValue);
CIMArgument[] outArgs = new CIMArgument[1];
String buf = null;
CIMValue bufValue = new CIMValue(buf, new
CIMDataType(CIMDataType.STRING));
outArgs[0] = new CIMArgument("buf", bufValue);
CIMValue returnVal = new CIMValue(new UnsignedInt32(1), new
CIMDataType(CIMDataType.UINT32));
try{
returnVal = client.invokeMethod( cop, //object path to instance
"read", // method to invoke
inArgs, //input array
outArgs); //output parameters
}catch (CIMException e){/*Ignoring Exception Handling*/}
String str= returnVal.toString();
return str;
}
public void write(String toWrite){ /* Ignoring the details of this method*/}
Figure 2: The CIM client code