.NET SDK
システムAPI
//Specify the IP address of the appliance and service type
nitro_service nitroservice = new nitro_service ("10.102.31.16", "https");
//Specify the login credentials
nitroservice.login("nsroot", "verysecret");
nitroservice.logout();
構成API
リソースの作成
-
対応するプロパティ名を使用して、リソースの必須プロパティの値を設定します。その結果、リソースに必要な詳細を含むリソースオブジェクトが作成されます。 注: これらの値はクライアントにローカルに設定されます。オブジェクトがアップロードされるまで、値はアプライアンスに反映されません。
-
静的 add() メソッドを使用して、リソースオブジェクトをアプライアンスにアップロードします。
ns newns = new ns();
//Set the properties of the NetScaler locally
newns.name = "ns_instance";
newns.ip_address = "10.70.136.5";
newns.netmask = "255.255.255.0";
newns.gateway = "10.70.136.1";
newns.image_name = "nsvpx-9.3.45_nc.xva";
newns.profile_name = "ns_nsroot_profile";
newns.vm_memory_total = 2048;
newns.throughput = 1000;
newns.pps = 1000000;
newns.license = "Standard";
newns.username = "admin";
newns.password = "admin";
int number_of_interfaces = 2;
network_interface[] interface_array = new network_interface[number_of_interfaces];
//Adding 10/1
interface_array[0] = new network_interface();
interface_array[0].port_name = "10/1";
//Adding 10/2
interface_array[1] = new network_interface();
interface_array[1].port_name = "10/2";
newns.network_interfaces = interface_array;
//Upload the NetScaler instance
ns result = ns.add(nitroservice, newns);
リソースの詳細を取得する
-
get() メソッドを使用してアプライアンスから構成を取得します。その結果、リソースオブジェクトが作成されます。
-
対応するプロパティ名を使用して、オブジェクトから必要なプロパティを抽出します。
//Retrieve the resource object from the SDX appliance
ns[] returned_ns = ns.get(nitroservice);
//Extract the properties of the resource from the object
Console.WriteLine(returned_ns[i].ip_address);
Console.WriteLine(returned_ns[i].netmask);
リソース統計を取得する
ns obj = new ns();
obj.id = "123456a";
ns stats = ns.get(nitroservice, obj);
Console.WriteLine("CPU Usage:" + stats.ns_cpu_usage);
Console.WriteLine("Memory Usage:" + stats.ns_memory_usage);
Console.WriteLine("Request rate/sec:" +stats.http_req);
リソースを更新する
-
idプロパティを更新するリソースのIDに設定します。
-
対応するプロパティ名を使用して、リソースの必須プロパティの値を設定します。結果はリソースオブジェクトになります。 注: これらの値はクライアント上でローカルに設定されます。オブジェクトがアップロードされるまで、これらの値はアプライアンスに反映されません。
-
update() メソッドを使用して、リソースオブジェクトをアプライアンスにアップロードします。
ns update_obj = new ns();
//Set the ID of the NetScaler to be updated
update_obj.id = "123456a";
//Get existing NetScaler details
update_obj = ns.get(nitroservice, update_obj);
//Update the name of the NetScaler to "ns_instance_new" locally
update_obj.name = "ns_instance_new";
//Upload the updated NetScaler details
ns result = ns.update(nitroservice, update_obj);
リソースを削除する
ns obj = new ns();
obj.id = "123456a";
ns.delete(nitroservice, obj);
一括操作
-
終了。 最初のエラーが発生すると、実行は停止します。エラーの前に実行されたコマンドはコミットされます。
-
続行。 一部のコマンドが失敗しても、リスト内のすべてのコマンドが実行されます。
onerror パラメータを設定して、 必要な動作を構成します。
ns[] newns = new ns[2];
//Specify details of first NetScaler
newns[0] = new ns();
newns[0].name = "ns_instance1";
newns[0].ip_address = "10.70.136.5";
newns[0].netmask = "255.255.255.0";
newns[0].gateway = "10.70.136.1";
...
...
//Specify details of second NetScaler
newns[1] = new ns();
newns[1].name = "ns_instance2";
newns[1].ip_address = "10.70.136.8";
newns[1].netmask = "255.255.255.0";
newns[1].gateway = "10.70.136.1";
...
...
//upload the details of the ADC appliances to the NITRO server
ns[] result = ns.add(nitroservice, newns);
例外処理
-
エラーコードが0の場合、操作は成功しています。
-
ゼロ以外のエラーコードは、NITROリクエストの処理中にエラーが発生したことを示します。
getErrorCode() メソッドを使用できます。
<NITRO_SDK_HOME>/doc フォルダーにあるAPIリファレンスを参照してください。