LoginSignup
1
1

More than 1 year has passed since last update.

CML2を使いこなす。(その15:ラボのバックアップ)

Posted at

はじめに

前回はTRexを使ったトラフィックの生成を行いましたが、今回は作成したラボのバックアップを行ってみます。

CML2でのラボバックアップについて

ラボのバックアップを行うには、ラボのメニューからSIMULATEタブを選択し、DOWNLOAD LABを選択することで、YAML形式でラボの構成をバックアップ・ダウンロードすることができます。

capture_20092021_153230.jpg

バックアップファイルは以下のような情報が記録されるため、取得したバックアップファイルを別環境でインポートすれば、そのまますぐに使うことが可能です。

  • ラボの基本情報(ラボ名等)
  • ラボの機器構成
  • 各機器との接続情報
  • ノードの設定情報

但し、ノードの設定情報は、DOWNLOAD LABを選択する前に事前にコンフィグを反映する操作を行う必要があること、また、サーバ機器については現在の設定を保存することができません。

なぜサーバ機器の設定がバックアップできないのか。

DOWNLOAD LABでダウンロードできるYAMLファイルは各ノードが無効化された状態(WIPE状態)から設定することを前提としているため、ノード起動後にサーバにログインして行った操作はYAMLファイルに保存されないことから、サーバ機器の設定はバックアップできません。

Ciscoノードについてはshow running-config形式のコンフィグをバックアップファイルに書き出すことができるようになっているため、別環境でもそのまま使うことができます。

サーバ機器に関しては起動後に行われた設定はバックアップできませんが、起動時に実行されるEDIT CONFIGの設定は保存されるため、EDIT CONFIGに設定情報を全て記載しておけば、別環境にインポートした場合でも、そのまま使うことができるようになっています。

Ciscoノードのコンフィグバックアップ

Cisco機器のノードを起動し、適当な設定を行った後、保存したいCiscoノードのEDIT CONFIGタブにある、FETCH FROM DEVICEを選択することで、EDIT CONFIGタブに表示されているコンフィグが最新化されます。

サーバ機器の設定

上述の通り、サーバ機器は起動後に設定した情報がバックアップファイルに反映されないため、サーバノードのEDIT CONFIGから初回起動時に実行されるコンフィグを設定してしまいます。

以下はServerノードのデフォルト設定に、IPアドレスとルーティングを追加するようにした設定。

IPアドレスとルーティング設定
# this is a shell script which will be sourced at boot
hostname inserthostname_here
# configurable user account
USERNAME=cisco
PASSWORD=cisco
# no password for tc user by default
TC_PASSWORD=
ifconfig eth0 192.168.0.100 netmask 255.255.255.0 up
route add -net default gw 192.168.0.1

全機器の設定を一度に最新化する方法

複数のCiscoノードのコンフィグを最新化する場合に、1つ1つノードを選択して保存するのは手間なので、一度に保存する方法を紹介します。

ラボのNODESタブを選択するとラボ上に配置されたノード情報が表示されるため、コンフィグを保存したいノードを選択後、EXTRACT CONFIGSを選択することで、まとめてコンフィグを最新化することができます。

capture_20092021_161459.jpg

ラボのインポート

ラボのトップ画面から、IMPORTでバックアップしたYAMLファイルを指定することでラボをインポートできます。

以下、サーバノード2台、IOSVノード2台でアドレス、ルーティングの設定を行ったラボをバックアップしたYAMLファイルを参考として載せておきます。

設定済みラボのYAMLファイル(展開してください)
testlab.yaml
lab:
  description: ''
  notes: ''
  timestamp: 1632113967.4568799
  title: testlab
  version: 0.0.4
nodes:
  - id: n1
    label: iosv-0
    node_definition: iosv
    x: 350
    y: 50
    configuration: |-
      Building configuration...

      Current configuration : 3542 bytes
      !
      ! Last configuration change at 07:17:21 UTC Mon Sep 20 2021
      !
      version 15.9
      service timestamps debug datetime msec
      service timestamps log datetime msec
      no service password-encryption
      !
      hostname iosv-0
      !
      boot-start-marker
      boot-end-marker
      !
      !
      no logging console
      enable secret 4 tnhtc92DXBhelxjYk8LWJrPV36S2i4ntXrpb4RFmfqY
      enable password cisco
      !
      no aaa new-model
      !
      !
      !
      mmi polling-interval 60
      no mmi auto-configure
      no mmi pvc
      mmi snmp-timeout 180
      !
      !
      !
      !
      !
      !
      !
      !
      !
      !
      !
      no ip domain lookup
      ip domain name virl.info
      ip cef
      no ipv6 cef
      !
      multilink bundle-name authenticated
      !
      !
      !
      !
      username cisco privilege 15 secret 9 $9$rTTd/xCgNard17$tLu/D8OdtnNUxy3Q7pYy0DxvdhAdbHFPa8p42okLqhs
      !
      redundancy
      !
      no cdp run
      !
      !
      !
      !
      !
      !
      !
      !
      !
      !
      !
      !
      !
      !
      interface Loopback0
       description to
       no ip address
       shutdown
      !
      interface GigabitEthernet0/0
       description to GigabitEthernet0/0.iosv-1
       ip address 10.0.0.1 255.255.255.0
       duplex auto
       speed auto
       media-type rj45
      !
      interface GigabitEthernet0/1
       description to eth0.server-0
       ip address 192.168.0.1 255.255.255.0
       duplex auto
       speed auto
       media-type rj45
      !
      interface GigabitEthernet0/2
       description to
       no ip address
       shutdown
       duplex auto
       speed auto
       media-type rj45
      !
      interface GigabitEthernet0/3
       description to
       no ip address
       shutdown
       duplex auto
       speed auto
       media-type rj45
      !
      ip forward-protocol nd
      !
      !
      no ip http server
      no ip http secure-server
      ip route 0.0.0.0 0.0.0.0 10.0.0.2
      ip ssh server algorithm authentication password
      !
      ipv6 ioam timestamp
      !
      !
      !
      control-plane
      !
      banner exec ^C
      **************************************************************************
      * IOSv is strictly limited to use for evaluation, demonstration and IOS  *
      * education. IOSv is provided as-is and is not supported by Cisco's      *
      * Technical Advisory Center. Any use or disclosure, in whole or in part, *
      * of the IOSv Software or Documentation to any third party for any       *
      * purposes is expressly prohibited except as otherwise authorized by     *
      * Cisco in writing.                                                      *
      **************************************************************************^C
      banner incoming ^C
      **************************************************************************
      * IOSv is strictly limited to use for evaluation, demonstration and IOS  *
      * education. IOSv is provided as-is and is not supported by Cisco's      *
      * Technical Advisory Center. Any use or disclosure, in whole or in part, *
      * of the IOSv Software or Documentation to any third party for any       *
      * purposes is expressly prohibited except as otherwise authorized by     *
      * Cisco in writing.                                                      *
      **************************************************************************^C
      banner login ^C
      **************************************************************************
      * IOSv is strictly limited to use for evaluation, demonstration and IOS  *
      * education. IOSv is provided as-is and is not supported by Cisco's      *
      * Technical Advisory Center. Any use or disclosure, in whole or in part, *
      * of the IOSv Software or Documentation to any third party for any       *
      * purposes is expressly prohibited except as otherwise authorized by     *
      * Cisco in writing.                                                      *
      **************************************************************************^C
      !
      line con 0
       exec-timeout 0 0
       password cisco
      line aux 0
      line vty 0 4
       exec-timeout 720 0
       password cisco
       login local
       transport input telnet ssh
      !
      no scheduler allocate
      !
      end
    image_definition: iosv-159-3-m3
    tags: []
    interfaces:
      - id: i0
        label: Loopback0
        type: loopback
      - id: i1
        slot: 0
        label: GigabitEthernet0/0
        type: physical
      - id: i2
        slot: 1
        label: GigabitEthernet0/1
        type: physical
      - id: i3
        slot: 2
        label: GigabitEthernet0/2
        type: physical
      - id: i4
        slot: 3
        label: GigabitEthernet0/3
        type: physical
  - id: n2
    label: iosv-1
    node_definition: iosv
    x: 500
    y: 50
    configuration: |-
      Building configuration...

      Current configuration : 3544 bytes
      !
      ! Last configuration change at 07:17:20 UTC Mon Sep 20 2021
      !
      version 15.9
      service timestamps debug datetime msec
      service timestamps log datetime msec
      no service password-encryption
      !
      hostname iosv-1
      !
      boot-start-marker
      boot-end-marker
      !
      !
      no logging console
      enable secret 4 tnhtc92DXBhelxjYk8LWJrPV36S2i4ntXrpb4RFmfqY
      enable password cisco
      !
      no aaa new-model
      !
      !
      !
      mmi polling-interval 60
      no mmi auto-configure
      no mmi pvc
      mmi snmp-timeout 180
      !
      !
      !
      !
      !
      !
      !
      !
      !
      !
      !
      no ip domain lookup
      ip domain name virl.info
      ip cef
      no ipv6 cef
      !
      multilink bundle-name authenticated
      !
      !
      !
      !
      username cisco privilege 15 secret 9 $9$kxFmfAxLyuEz7d$0.Q4Xvxvd/gK.ahmijohqGY1TjWOnCAAvptyjMajkiw
      !
      redundancy
      !
      no cdp run
      !
      !
      !
      !
      !
      !
      !
      !
      !
      !
      !
      !
      !
      !
      interface Loopback0
       description to
       no ip address
       shutdown
      !
      interface GigabitEthernet0/0
       description to GigabitEthernet0/0.iosv-0
       ip address 10.0.0.2 255.255.255.0
       duplex auto
       speed auto
       media-type rj45
      !
      interface GigabitEthernet0/1
       description to eth0.server-1
       ip address 192.168.100.1 255.255.255.0
       duplex auto
       speed auto
       media-type rj45
      !
      interface GigabitEthernet0/2
       description to
       no ip address
       shutdown
       duplex auto
       speed auto
       media-type rj45
      !
      interface GigabitEthernet0/3
       description to
       no ip address
       shutdown
       duplex auto
       speed auto
       media-type rj45
      !
      ip forward-protocol nd
      !
      !
      no ip http server
      no ip http secure-server
      ip route 0.0.0.0 0.0.0.0 10.0.0.1
      ip ssh server algorithm authentication password
      !
      ipv6 ioam timestamp
      !
      !
      !
      control-plane
      !
      banner exec ^C
      **************************************************************************
      * IOSv is strictly limited to use for evaluation, demonstration and IOS  *
      * education. IOSv is provided as-is and is not supported by Cisco's      *
      * Technical Advisory Center. Any use or disclosure, in whole or in part, *
      * of the IOSv Software or Documentation to any third party for any       *
      * purposes is expressly prohibited except as otherwise authorized by     *
      * Cisco in writing.                                                      *
      **************************************************************************^C
      banner incoming ^C
      **************************************************************************
      * IOSv is strictly limited to use for evaluation, demonstration and IOS  *
      * education. IOSv is provided as-is and is not supported by Cisco's      *
      * Technical Advisory Center. Any use or disclosure, in whole or in part, *
      * of the IOSv Software or Documentation to any third party for any       *
      * purposes is expressly prohibited except as otherwise authorized by     *
      * Cisco in writing.                                                      *
      **************************************************************************^C
      banner login ^C
      **************************************************************************
      * IOSv is strictly limited to use for evaluation, demonstration and IOS  *
      * education. IOSv is provided as-is and is not supported by Cisco's      *
      * Technical Advisory Center. Any use or disclosure, in whole or in part, *
      * of the IOSv Software or Documentation to any third party for any       *
      * purposes is expressly prohibited except as otherwise authorized by     *
      * Cisco in writing.                                                      *
      **************************************************************************^C
      !
      line con 0
       exec-timeout 0 0
       password cisco
      line aux 0
      line vty 0 4
       exec-timeout 720 0
       password cisco
       login local
       transport input telnet ssh
      !
      no scheduler allocate
      !
      end
    image_definition: iosv-159-3-m3
    tags: []
    interfaces:
      - id: i0
        label: Loopback0
        type: loopback
      - id: i1
        slot: 0
        label: GigabitEthernet0/0
        type: physical
      - id: i2
        slot: 1
        label: GigabitEthernet0/1
        type: physical
      - id: i3
        slot: 2
        label: GigabitEthernet0/2
        type: physical
      - id: i4
        slot: 3
        label: GigabitEthernet0/3
        type: physical
  - id: n3
    label: server-0
    node_definition: server
    x: 150
    y: 50
    configuration: |-
      # this is a shell script which will be sourced at boot
      hostname inserthostname_here
      # configurable user account
      USERNAME=cisco
      PASSWORD=cisco
      # no password for tc user by default
      TC_PASSWORD=
      ifconfig eth0 192.168.0.100 netmask 255.255.255.0 up
      route add -net default gw 192.168.0.1
    image_definition: server-tcl-11-1
    tags: []
    interfaces:
      - id: i0
        slot: 0
        label: eth0
        type: physical
  - id: n4
    label: server-1
    node_definition: server
    x: 700
    y: 50
    configuration: |-
      # this is a shell script which will be sourced at boot
      hostname inserthostname_here
      # configurable user account
      USERNAME=cisco
      PASSWORD=cisco
      # no password for tc user by default
      TC_PASSWORD=
      ifconfig eth0 192.168.100.100 netmask 255.255.255.0 up
      route add -net default gw 192.168.100.1
    image_definition: server-tcl-11-1
    tags: []
    interfaces:
      - id: i0
        slot: 0
        label: eth0
        type: physical
links:
  - id: l0
    i1: i1
    n1: n1
    i2: i1
    n2: n2
  - id: l1
    i1: i0
    n1: n4
    i2: i2
    n2: n2
  - id: l2
    i1: i0
    n1: n3
    i2: i2
    n2: n1

おわりに

CML2ではノードが停止状態だったとしても、WIPEしないとQCOW2のディスクイメージが残ってしまい、ホスト側ディスクを圧迫してしまうため、使い終わったラボでまた使いそうなものはバックアップして消すようにしましょう。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1