本文整理汇总了Python中openstack.icehouse.common.Utils.ShellCmdExecutor.execCmd方法的典型用法代码示例。如果您正苦于以下问题:Python ShellCmdExecutor.execCmd方法的具体用法?Python ShellCmdExecutor.execCmd怎么用?Python ShellCmdExecutor.execCmd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openstack.icehouse.common.Utils.ShellCmdExecutor
的用法示例。
在下文中一共展示了ShellCmdExecutor.execCmd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: stopNetworkManager
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def stopNetworkManager():
stopCmd = "service NetworkManager stop"
chkconfigOffCmd = "chkconfig NetworkManager off"
ShellCmdExecutor.execCmd(stopCmd)
ShellCmdExecutor.execCmd(chkconfigOffCmd)
pass
示例2: install
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def install():
yumCmd = "yum install openstack-utils -y"
ShellCmdExecutor.execCmd(yumCmd)
yumCmd = "yum install openstack-selinux -y"
ShellCmdExecutor.execCmd(yumCmd)
pass
示例3: createAdminUser
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def createAdminUser():
## create admin user
ShellCmdExecutor.execCmd("keystone user-create --name=admin --pass=123456 [email protected]")
ShellCmdExecutor.execCmd("keystone role-create --name=admin")
ShellCmdExecutor.execCmd("keystone tenant-create --name=admin --description=\"Admin Tenant\"")
ShellCmdExecutor.execCmd("keystone user-role-add --user=admin --tenant=admin --role=admin")
ShellCmdExecutor.execCmd("keystone user-role-add --user=admin --role=_member_ --tenant=admin")
pass
示例4: createDb
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def createDb(user, passwd, db_name):
listDbCmd = 'mysql -u%s -p%s -e "show databases" | grep %s' % (user, passwd, db_name)
output, exitcde = ShellCmdExecutor.execCmd(listDbCmd)
if (db_name not in output) or output == '' or output == None :
createDbCmd = 'mysql -u%s -p%s -e "create database %s"' % (user, passwd, db_name)
output, exitcode = ShellCmdExecutor.execCmd(createDbCmd)
print "output=%s--" % output
else :
print "The DB:%s already exists!" % db_name
pass
pass
示例5: configMyConfFile
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def configMyConfFile():
print 'start to config my.conf file====='
curDir = os.getcwd()
print "curDir=%s" % curDir
curFileName = os.path.basename(curDir)
mysqlConfDir = os.path.join(curDir.rstrip(curFileName), 'configfile.template', 'controller')
mysqlConfFilePath = os.path.join(mysqlConfDir, 'my.cnf')
print 'mysqlConfFilePath=%s' % mysqlConfFilePath
cpMyCnfCmd = "sudo cp -rf %s /etc/" % mysqlConfFilePath
ShellCmdExecutor.execCmd(cpMyCnfCmd)
print 'config done####'
pass
示例6: configDB
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def configDB():
createDbCmd = "CREATE DATABASE nova"
MySQL.execMySQLCmd(MySQL.USERNAME, MySQL.INIT_PASSWORD, createDbCmd)
grantCmd = "GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' IDENTIFIED BY '123456'"
MySQL.execMySQLCmd(MySQL.USERNAME, MySQL.INIT_PASSWORD, grantCmd)
grantCmd = "GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY '123456'"
MySQL.execMySQLCmd(MySQL.USERNAME, MySQL.INIT_PASSWORD, grantCmd)
#Import db schema to Nova db
importDBCmd = "su -s /bin/sh -c \"nova-manage db_sync\" nova"
ShellCmdExecutor.execCmd(importDBCmd)
pass
示例7: createUserRole
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def createUserRole():
'''
$ keystone endpoint-create --service-id $(keystone service-list | awk '/ network / {print $2}') --publicurl http://controller:9696 --adminurl http://controller:9696 --internalurl http://controller:9696
'''
ShellCmdExecutor.execCmd("keystone user-create --name neutron --pass 123456 --email [email protected]")
ShellCmdExecutor.execCmd("keystone user-role-add --user neutron --tenant service --role admin")
ShellCmdExecutor.execCmd("keystone service-create --name neutron --type network --description \"OpenStack Networking\"")
ShellCmdExecutor.execCmd("keystone endpoint-create --service-id $(keystone service-list | awk '/ network / {print $2}') --publicurl http://controller:9696 --adminurl http://controller:9696 --internalurl http://controller:9696")
pass
示例8: configKeyStone
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def configKeyStone():
#configure KeyStone to support PKI token
cmd = "keystone-manage pki_setup --keystone-user keystone --keystone-group keystone"
ShellCmdExecutor.execCmd(cmd)
ShellCmdExecutor.execCmd("chown -R keystone:keystone /etc/keystone/ssl")
ShellCmdExecutor.execCmd("chmod -R o-rwx /etc/keystone/ssl")
pass
示例9: initRabbitMQ
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def initRabbitMQ(username, password):
startCmd = "/etc/init.d/rabbitmq-server restart"
ShellCmdExecutor.execCmd(startCmd)
chkconfigCmd = "chkconfig rabbitmq-server on"
ShellCmdExecutor.execCmd(chkconfigCmd)
initPasswordCmd = "rabbitmqctl change_password %s %s" % (username, password)
ShellCmdExecutor.execCmd(initPasswordCmd)
pass
示例10: initMySQL
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def initMySQL(user, initPasswd):
#when mysql is installed,config file and the root password is None, init the db.
MySQL.configMyConfFile()
#start
startCmd = "service mysql start"
ShellCmdExecutor.execCmd(startCmd)
#chkcofnig
chkconfigCmd = "chkconfig mysql on"
ShellCmdExecutor.execCmd(chkconfigCmd)
initPasswdCmd = 'mysqladmin -u%s password %s' % (user, initPasswd)
ShellCmdExecutor.execCmd(initPasswdCmd)
pass
示例11: configToEtcHosts
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def configToEtcHosts(ip, domain):
output, exitcode = ShellCmdExecutor.execCmd("cat /etc/hosts")
if domain not in output :
ShellCmdExecutor.execCmd("echo '%s %s' >> /etc/hosts" % (ip, domain))
pass
pass
示例12: start
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def start():
ShellCmdExecutor.execCmd("service httpd restart")
ShellCmdExecutor.execCmd("service memcached restart")
ShellCmdExecutor.execCmd("chkconfig httpd on")
ShellCmdExecutor.execCmd("chkconfig memcached on")
pass
示例13: stopIPTables
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def stopIPTables():
stopCmd = "service iptables stop"
ShellCmdExecutor.execCmd(stopCmd)
pass
示例14: restart
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def restart():
#restart Controller nova-api service
restartCmd = "service openstack-nova-api restart"
ShellCmdExecutor.execCmd(restartCmd)
pass
示例15: configEnvVar
# 需要导入模块: from openstack.icehouse.common.Utils import ShellCmdExecutor [as 别名]
# 或者: from openstack.icehouse.common.Utils.ShellCmdExecutor import execCmd [as 别名]
def configEnvVar():
## configure env var
ShellCmdExecutor.execCmd("export OS_SERVICE_TOKEN=123456")
ShellCmdExecutor.execCmd("export OS_SERVICE_ENDPOINT=http://controller:35357/v2.0")
pass