Cisco ACI の 2.2(1n) から App Center という機能が導入され、「誰かが App Center にアップロードしたアプリケーション」や「自分で書いたアプリケーション」を ACI の Web UI へ簡単に追加することが出来るようになりました。 今回は Cisco が提供している App Creator Utility というツールを使ってサンプルアプリケーションを作成し、実際に ACI 上にインストール&実行するところまでを試してみます。
事前準備
pip のインストール
後の手順で必要なパッケージを pip
でインストールする必要がある為、まず pip
をインストールしておきます。
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py
python-devel のインストール
後の手順で App Packager Utility というツールを使うのですが、その際に必要だったので python-devel パッケージを追加しておきます。
yum -y isntall python-devel
App Center アプリケーションディレクトリの作成
App Center アプリケーションを格納するディレクトリを作成しておきます。
mkdir ~/MyFirstApp
App Creator Utility のインストール
App Center アプリケーションの作成を補助してくれる App Creator Utility というツールをダウンロードします。 Getting Started with ACI App Center からダウンロード出来ます。 パッケージをダウンロードしたら pip
でインストールし、パッケージを展開します。
wget -L https://developer.cisco.com/fileMedia/download/3b2c497f-2da5-4003-8773-304c529bfe1d -O cisco_aci_app_tools-1.0.tar.gz
pip install cisco_aci_app_tools-1.0.tar.gz
tar zxvf cisco_aci_app_tools-1.0.tar.gz
アプリケーションを作成する
cisco_aci_app_tools-1.0/tools/aci_app_creator.py
というスクリプトを使って App Center アプリケーションの雛形を作成します。 別のディレクトリから実行するとエラーになってしまう為、スクリプトが保存されているディレクトリに移動してから実行します。
cd cisco_aci_app_tools-1.0/tools/
python aci_app_creator.py -o ~/MyFirstApp
実際の実行例は以下の通りです。 -o
オプションでアプリケーションを書き出すディレクトリを指定します。 このディレクトリは存在している必要があります(存在しないディレクトリを指定するとエラーになりました)。
# python aci_app_creator.py -o ~/MyFirstApp
*******************************************
* ACI App Creator *
*******************************************
Welcome! This tool will guide you through the creation of a fully functional ACI App Center application.
The information that you will provide can be changed later on, please read the ACI App Center Developer Guide to learn more about it.
--- General information ---
Let's begin! What should be the name of your application? (e.g. "TestingApp", "MyFirstApp",...)
Note: The name of the application will also be used as the application ID.
This can be changed afterwards in "app.json".
> (Application name) MyFirstApp
企業名は SampleCompany
としました。
What is the name of your company?
Note: The company name will also be used as the vendor domain.
This can be changed afterwards in "app.json".
> (Company name) SampleCompany
説明は My first ACI application
としました。
Can you describe briefly what the application is supposed to do?
To skip it, leave the field empty. The following description will be used: "My first ACI app"
> (Description) My first ACI application
作成者は SampleAuthor
としました。
--- About you ---
What is your name?
> (Author) SampleAuthor
電子メールアドレスは省略しました。
What is your email address?
To skip it, leave the field empty.
> (Email)
アプリケーションバージョンは 0.1
としました。
--- App versions ---
Would you like to change the version of the application?
To skip it, leave the field empty. The following version will be used: "1.0"
> (Version, the format is: Major.Minor) 0.1
アプリケーションを実行する際に必要な APIC の最少バージョンは 2.2(1n)
としました。
Would you like to change the mininum APIC version on which the application can run?
To skip it, leave the field empty. The following APIC version will be used: "2.2(1k)"
> (Min APIC version, the format is: Major.Minor(mp), where m=maintenance and p=patch) 2.2(1n)
パーミッションは admin
としました。 デフォルト値が admin
なので、実際には入力を省略しています。
--- Permissions ---
What permissions would you like the application to have?
Read more at this address: http://www.cisco.com/c/en/us/td/docs/switches/datacenter/aci/apic/sw/kb/b_KB_AAA-RBAC-roles-privileges.html
To skip it, leave the field empty. The following permissions will be used: "['admin']"
> (Permission)
特権は read
のみとしました。 デフォルト値が read
なので、実際には入力を省略しています。
Should the application run with read or write priviledges?
To skip it, leave the field empty. The following priviledge will be used: "read"
> (Priviledge)
アプリケーションは以下の 6 種類に分類されます。
番号 | 分類 |
---|---|
1 | Tools and Utilities |
2 | Visibility and Monitoring |
3 | Optimization |
4 | Security |
5 | Networking |
6 | Cisco Automation and Orchestration |
今回は Tools and Utilities
だけに該当するアプリケーションとしました。
--- Categories ---
Here are different categories:
Tools and Utilities
Visibility and Monitoring
Optimization
Security
Networking
Cisco Automation and Orchestration
Please select the category(ies) which is(are) the most suitable for your app:
If none of the categories are selected, the following category will be used: "['Tools and Utilities']"
> (Tools and Utilities, y/n) y
> (Visibility and Monitoring, y/n) n
> (Optimization, y/n) n
> (Security, y/n) n
> (Networking, y/n) n
> (Cisco Automation and Orchestration, y/n) n
アプリケーションには以下の 2 種類があります。
番号 | 種類 | 特徴 |
---|---|---|
1 | Stateless | 状態を持たない(持てない)。 Web フロントエンドだけで構成される |
2 | Stateful | 状態を持てる。 バックエンドとして Docker コンテナをアプリケーションに含める必要がある |
今回はあくまでサンプルなので、より簡単な Stateless アプリケーションとしました。
--- Other ---
Would you like to add a docker container to your application?
Note: There are 2 kinds of apps: "stateless" and "stateful":
- A stateless app is only composed of a front-end part, it communicates with the APIC without keeping any state.
- A stateful app have a back-end (docker container) to keep a state amongst multiple launches of the app.
> (y/n) n
アプリケーションの内容を変更した場合は python aci_app_packager.py -f /root/MyFirstApp/SampleCompany_MyFirstApp
を実行して再パッケージし直すよう、注釈が表示されます。 このままアプリケーションをパッケージングして良いか?聞かれますので、パッケージングします。
We are now creating your fully functional app in this directory: /root/MyFirstApp...
The application has been successfully created.
Don't forget, you can modify the content of the directory and repackage the app using the command "python aci_app_packager.py -f /root/MyFirstApp/SampleCompany_MyFirstApp"
--- Packaging ---
Would you like to package the app?
This will create a .aci application.
> (y/n) y
アプリケーションのパッケージングが完了しました。 今回のアプリケーションはスケルトンだけであり、何もコードを追加していませんので、作成したアプリケーションは 3.7MB しかありませんでした。
Validation of mandatory files and directories successful
Retrieving app meta data successful
Validation of app meta data successful
App successfully packaged - /root/MyFirstApp/SampleCompany-MyFirstApp-0.1.aci
作成したアプリケーションを ACI にインストールする
作成したアプリケーションを ACI にインストールしてみます。 Apps
メニューの All Apps
をクリックし、画面左上の「+」(プラス)マークをクリックします。
Upload App というダイアログが表示されます。BROWSE
ボタンをクリックし、作成したアプリケーション(今回なら SampleCompany-MyFirstApp-0.1.aci
)を指定します。
SUBMIT
をクリックし、アプリケーションをアップロードします。
アップロードが開始されます。
アップロードが完了すると、自動的にアプリケーションの追加が開始されます(インストールされたわけではありません)。
アプリケーションの追加が完了するとアイコンが表示されます。アイコンをクリックします。 余談ですが、アプリケーションを削除したい場合はアプリケーションの右上にある「X」(バツ)マークをクリックします。
アプリケーションの説明が表示されます。 緑色の Install
ボタンをクリックし、アプリケーションをインストールします。
ボタンの表示が Installed
に変化したらインストールは完了です。
アプリケーションを実行する
最後に、インストールしたアプリケーションを実行してみます。 右上のメニューを Installed Apps
に切り替える、インストールしたアプリケーションのアイコンをクリックします。
以下のように「Congratulations!」と表示されれば、アプリケーションは正常に動作しています。
コメント