#pythonで書いております(スクリプト)
scripts.py
1 import commands 2 clid =commands.getoutput('cloudstack-api listZones -t id |grep e8|cut -f 2 -d "|" ') 3 print clid 4 5 import commands 6 clst =commands.getoutput('cloudstack-api listServiceOfferings -t id,displaytext |grep bd226b3b-6ae7-454d-b53d-c886f7eebe42 |cut -f 2 -d "|"') 7 print clst 8 9 import commands 10 cltp =commands.getoutput('cloudstack-api listTemplates --templatefilter executable -t id,ostypename|grep 05e7df20-7b4d-4b5c-954a-0893939dd5e5|cut -f 2 -d "|"|uniq -d') 11 print cltp 12 13 import commands 14 clmk=commands.getoutput('cloudstack-api deployVirtualMachine --serviceofferingid $clst --templateid $cltp --zoneid $clid --group test_gorup --keypair kanegon --name test_api-1') 15 print clmk 16
#問題点
clmk=commands.getoutputの前でスクリプトを実行している結果を変数としてプッシュしています
★clmkで実行しているスクリプトで変数を引数として割り当て、実行したいと思っております。
import commands
clmk=commands.getoutput('cloudstack-api deployVirtualMachine --serviceofferingid $clst --templateid $cltp --zoneid $clid --group test_gorup --keypair kanegon --name test_api-1')
print clmk
の部分で
--serviceofferingid 引数
--templateid 引数
--zoneid 引数
引数は固定のため今回は除外
--group test_gorup
--keypair XXXXX
--name test_api-1
Pythonでなくシェルであれば容易じゃないかということになりますが、現在Pythonを勉強中となっております。commands.getoutputの使い方がググってもほとんどヒットせずに立ちすくんでおります・・
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/09/17 19:13
2017/09/18 07:09 編集
2017/09/18 16:15
2017/09/20 00:00
2017/09/22 17:21