The following is a simple function that will get the Server ID of a Container using its name. This function can be helpful when you want to use any of the other functions that accept the Server ID as a parameter. The reason is that you usually know the name of the Container that you would like to work with, but you most likely don't know its Server ID (the globally unique ID that Agent automatically assigns to every Container).
/// <summary>
/// Sample function NameToEid.
/// Gets the Server ID of the Container specified by its name.
/// </summary>
/// <param name="name">Container name.</param>
/// <returns>Server ID of the Container.</returns>
public string NameToEid(string name)
{
try {
// Instantiate the proxy class.
vzaenvmBinding env = (vzaenvmBinding)binder.InitBinding(typeof(vzaenvmBinding));
get_info2 getInfo = new get_info2();
getInfo.eid = new string[1];
get_list1 velist = new get_list1();
string eids = "";
string[] nn = env.get_list(velist);
foreach (string eid in nn) {
getInfo.eid[0] = eid;
envType[] envs = env.get_info(getInfo);
if (envs.Length != 0) {
if (env.get_info(getInfo)[0].virtual_config.name == name) {
eids = eid;
break;
}
else {
eids = "";
}
}
}
return eids;
}
catch (Exception e) {
return "Exception: " + e.Message;
}
}