LoginSignup
0
0

More than 3 years have passed since last update.

CVPySDK (Commvault の Developer SDK for Python) について

Last updated at Posted at 2020-10-21

はじめに

CVPySDK は Commvault の各種操作を Python から実行するための SDK です。
CVPySDK をインストールすることにより、他の Commvault のモジュールをインストールすることなく Commvault の操作をすることが可能です。

ソース等は https://github.com/Commvault/cvpysdk から参照できます。

CVPySDK の前提条件

  • Python v3 以降
  • Python のパッケージ (future、requests および xmltodict)
    pip で依存コンポーネントとしてインストールされますので、事前に個別でインストールする必要はありません。
  • Commvault V11 SP7 以降
    内部的には Commvault の Web Server に対して REST API を発行しますので、CVPySDK を使用するためには Web Server がセットアップされている必要があります。

CVPySDK のインストール

CVPySDK は pip からインストールすることが可能です。

c:\>pip install cvpysdk
Collecting cvpysdk
  Using cached cvpysdk-11.20-py2.py3-none-any.whl (842 kB)
Collecting future
  Using cached future-0.18.2.tar.gz (829 kB)
Collecting requests
  Using cached requests-2.24.0-py2.py3-none-any.whl (61 kB)
Collecting xmltodict
  Using cached xmltodict-0.12.0-py2.py3-none-any.whl (9.2 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2020.6.20-py2.py3-none-any.whl (156 kB)
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Using cached urllib3-1.25.10-py2.py3-none-any.whl (127 kB)
Collecting chardet<4,>=3.0.2
  Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting idna<3,>=2.5
  Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Using legacy setup.py install for future, since package 'wheel' is not installed.
Installing collected packages: future, certifi, urllib3, chardet, idna, requests, xmltodict, cvpysdk
    Running setup.py install for future ... done
Successfully installed certifi-2020.6.20 chardet-3.0.4 cvpysdk-11.20 future-0.18.2 idna-2.10 requests-2.24.0 urllib3-1.25.10 xmltodict-0.12.0
WARNING: You are using pip version 20.1.1; however, version 20.2.2 is available.
You should consider upgrading via the 'c:\program files\python38\python.exe -m pip install --upgrade pip' command.

c:\>

pip list で cvpysdk パッケージがインストールされていることを確認します。

c:\>pip list
Package    Version
---------- ---------
certifi    2020.6.20
chardet    3.0.4
cvpysdk    11.20
future     0.18.2
idna       2.10
pip        20.1.1
requests   2.24.0
setuptools 47.1.0
urllib3    1.25.10
xmltodict  0.12.0
WARNING: You are using pip version 20.1.1; however, version 20.2.2 is available.
You should consider upgrading via the 'c:\program files\python38\python.exe -m pip install --upgrade pip' command.

c:\>

CVPySDK による操作

いくつかの操作を試してみます。

Commcell モジュールのインポート

>>> from cvpysdk.commcell import Commcell
>>>

ログイン

# ログイン (指定するホスト名は CommServe ホストではなく Web Server ホストです)
>>> commcell = Commcell("webserver_hostname","admin","password")
# ログイン情報の確認
>>> print(commcell)
Commcell class instance of Commcell: "commserve", for User: "admin"
>>>

クライアント情報の表示

>>> print(commcell.clients)
S. No.         Client

  1     commserve
  2     webserver

qcommand の実行 (ジョブ情報の表示 : qlist job)

# qlist job の実行
>>> qcmd = commcell.execute_qcommand("qlist job")
>>>
# 実行結果の表示
>>> print(qcmd.text)
JOBID    OPERATION    STATUS     PHASE             JOB DESCRIPTION    COMPLETE PERCENTAGE
-----    ---------    ------     -----             ---------------    -------------------
598      Backup       Waiting    Backup                               0
600      Backup       Pending    Scan                                 5
778      Aux Copy     Waiting    Auxiliary Copy                       0

>>>

スクリプトの実行 (ジョブの実行 qoperation execute)

# スクリプト (C:\scripts\backup01.xml) の読込み
>>> with open("C:\scripts\backup01.xml") as qcmd_file:
...      qcmd_xml = qcmd_file.read()
...
>>>
# qoperation execute の実行
>>> qcmd = commcell.execute_qcommand("qoperation execute", qcmd_xml)
>>>
# 実行結果の表示
>>> import json
>>> qcmd_response = qcmd.json()
>>> print (qcmd_response)
{'taskId': 167, 'jobIds': ['779']}
>>>
# 

ログアウト

>>> commcell.logout()
'User logged out'
>>>
0
0
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
0
0