例 4 作成、更新、および破棄

以下の XML ファイルは、DTD に含まれているエレメントのほとんどの機能を示します。このファイルはトポロジ ビューと場所ビューの両方でデータを作成し、接続を作成し、属性を更新し、モデルと接続を破棄します。
casp1032jp
以下の XML ファイルは、DTD に含まれているエレメントのほとんどの機能を示します。このファイルはトポロジ ビューと場所ビューの両方でデータを作成し、接続を作成し、属性を更新し、モデルと接続を破棄します。
XML ファイルの最初のセクションでは、トポロジ ビューでモデルを作成し、モデル間の接続を作成します。セクションは Topology エレメントで始まります(<Topology>)。最初にコンテナ モデルとデバイス モデルが作成され、次に接続が確立されます。このセクションは、Topology エレメントが閉じるときに終了します(</Topology>)。
Topology エレメントが閉じられた後、別の接続が作成されるセクションがあります。このセクションでは、Topology エレメント内で Connection エレメントをネストせずに、接続を作成できることを示します。
ファイルの次のセクションは Location エレメントで始まります(<Location>)。このセクションでは、場所ビューでのコンテナ モデルとデバイス モデルの作成を示します。このセクションは、Location エレメントが閉じるときに終了します(</Location>)。
次のセクションは、Update エレメントで始まります(<Update>)。このセクションでは、コンテナ、デバイス、およびポートの属性値が変更されます。XML ファイルを見ても、表されている各エレメントの現在の属性値はわかりません。そのため、更新されているエレメントを識別するのは簡単ではありません。一般的に、各エレメントには、更新されるモデルまたはポートを一意に識別する属性が含まれます。他の属性は、値を更新するために指定されます。たとえば、最初のエレメントは Location_Container エレメントです。name 属性は一意にモデルを識別します。model_type 属性は、その値を(おそらくは Region から Building に)更新するために指定されます。Update エレメントで定義できる唯一の階層は、更新するポートを指定する Device/Port 階層です。このセクションは、Update エレメントが閉じるときに終了します(</Update>)。
このファイルの最後のセクションでは、Destroy エレメントを使用します。Destroy エレメントは以下のものを除外します。
  • 10.253.9.19 のデバイス
  • コンテナ モデル Durham
  • デバイス nmcss52-5 上の指定されたポートと 10.253.9.17 のデバイス間の接続
<?xml version="1.0" standalone="no"?> <!DOCTYPE Import SYSTEM ".modelinggateway.dtd"> <Import> <!-- ************************************* --> <!-- This part is for Topology view import --> <!-- ************************************* --> <Topology discover_connections="false" complete_topology="false"> <Device ip_dnsname="10.253.9.109" model_type="GnSNMPDev" community_string="public" is_managed="false"/> <Device ip_dnsname="10.253.9.17" poll_interval="333" log_ratio="11"/> <Device ip_dnsname="10.253.9.19" community_string="public"/> <Device ip_dnsname="nmcss52-5" /> <Topology_Container model_type="Network" name="My Network" Security_String="public" subnet_address="10.253.0.0" subnet_mask="255.255.0.0" complete_topology="true"> <Topology_Container model_type="Lan" name="MyLan" Security_String="public" subnet_address="10.253.9.0" subnet_mask="255.255.255.0"> <Device ip_dnsname="10.253.9.18" community_string="public" poll_interval="333" log_ratio="5"/> </Topology_Container> </Topology_Container> <Topology_Container model_type="IPClassC" name="my_net" subnet_address="172.19.57.0"> <Device model_type="Pingable" ip_dnsname="172.19.57.91"/> <Device model_type="Fanout" ip_dnsname="1.2.3.4"/> <Device ip_dnsname="10.253.9.16" community_string="public"/> </Topology_Container> <Topology_Container model_type="Lan" name="lan2" Security_String="public" subnet_address="10.253.7.0" subnet_mask="255.255.255.0" complete_topology="true"> <Device ip_dnsname="10.253.7.17" community_string="public" poll_interval="333" log_ratio="11"/> <Device ip_dnsname="10.253.32.101"/> <Device ip_dnsname="192.168.125.161" model_type="GnSNMPDev"/> </Topology_Container> <Device ip_dnsname="172.19.57.92" /> <Device ip_dnsname="172.19.57.93" /> <Device ip_dnsname="10.253.32.225" model_type="M46_04"/> <Connection> <Device ip_dnsname="172.19.57.93"> <Port identifier_name= "frCircuitTableInstance" identifier_value="4.161"/> </Device> <Device ip_dnsname="192.168.125.161"> <Port identifier_name ="frCircuitTableInstance" identifier_value="2.161"/> </Device> </Connection> <Connection create_pipe="false"> <Device ip_dnsname="10.253.32.101"> <Port identifier_name ="atmVclTableInstance" identifier_value="3.1.52"/> </Device> <Device ip_dnsname="10.253.32.225"> <Port identifier_name ="atmVclTableInstance" identifier_value="5.0.68" circuit_name="ATM 68" circuit_id ="ATM ID 68"/> </Device> </Connection> <Connection> <Device ip_dnsname="nmcss52-5"> <Port identifier_name="ifIndex" identifier_value="1"/> </Device> <Device ip_dnsname="10.253.9.17"> <Port identifier_name="ipAddress" identifier_value="10.253.8.18"/> </Device> </Connection> </Topology> <Connection> <Device ip_dnsname="172.19.57.92"> <Port identifier_name="ifPhysAddress" identifier_value="0:E0:63:7C:19:61"/> </Device> <Device ip_dnsname="10.253.9.17"> <Port identifier_name="ipAddress" identifier_value="10.253.8.65"/> </Device> </Connection> <!-- ************************************* --> <!-- This part is for Location view import --> <!-- ************************************* --> <Location complete_topology="true"> <Location_Container model_type="Country" name="USA" Security_String="whatever"> <Location_Container model_type="Region" name="New Hampshire" complete_topology="false"> <Location_Container model_type="Site" name="Durham" <Device ip_dnsname = "10.253.32.10"/> <Device ip_dnsname = "172.19.57.93" /> </Location_Container> </Location_Container> </Location_Container> <Location_Container model_type="Building" name="Durham" Security_String="public"> <Location_Container model_type="Room" name="my_room" Security_String="hahaha"> <Device ip_dnsname="10.253.9.16" community_string="public"/> <Device ip_dnsname="10.253.9.17" /> <Device ip_dnsname = "10.253.9.18"/> </Location_Container> </Location_Container> <Location_Container model_type="Building" name="Peace" Security_String="aprisma"> <Location_Container model_type="Room" name= "Lab 1"> <Device ip_dnsname="10.253.7.17" community_string="public"/> <Device ip_dnsname="192.168.125.161"/> </Location_Container> </Location_Container> </Location> <!-- ***************************************** --> <!-- This part is for model update --> <!-- ***************************************** --> <Update> <Location_Container model_type="Building" name="Peace" model_modify_author="ltang"/> <Device ip_dnsname="172.19.57.93" poll_interval="101" model_name="haha" /> <!-- ***************************************** --> <!-- This part is to update the port ifIndex=2 --> <!-- on device nmcss52-5 --> <!-- ***************************************** --> <Device ip_dnsname="nmcss52-5"> <Port identifier_name="ifIndex" identifier_value="2" model_name="port 2" poll_interval="1103" poll_status="false" log_ratio="12"/> </Device> <Topology_Container model_type="Lan" name="lan2" Security_String="top secret"/> </Update> <!-- ********************************************** --> <!-- This part is for model and connection deletion --> <!-- ********************************************** --> <Destroy> <Device ip_dnsname="10.253.9.19"/> <Location_Container model_type="Building" name="Durham"/> <Connection> <Device ip_dnsname="nmcss52-5"> <Port identifier_name="ifIndex" identifier_value="1"/> </Device> <Device ip_dnsname="10.253.9.17"> <Port identifier_name="ipAddress" identifier_value="10.253.8.18"/> </Device> </Connection> </Destroy> </Import>