def endpoint_create(region, id, publicurl, adminurl, internalurl): tbl = table( osutils.run('keystone endpoint-list') ) r = row(tbl, 'internalurl', internalurl) if r == None: if openstack_conf.version == "essex": osutils.run_std( "keystone endpoint-create --region {0} --service_id {1} --publicurl '{2}' --adminurl '{3}' --internalurl '{4}'".format(region, id, publicurl, adminurl, internalurl) ) else: osutils.run_std( "keystone endpoint-create --region {0} --service-id {1} --publicurl '{2}' --adminurl '{3}' --internalurl '{4}'".format(region, id, publicurl, adminurl, internalurl) )
def endpoint_create(region, id, publicurl, adminurl, internalurl): tbl = table(osutils.run('keystone endpoint-list')) r = row(tbl, 'internalurl', internalurl) if r == None: if openstack_conf.version == "essex": osutils.run_std( "keystone endpoint-create --region {0} --service_id {1} --publicurl '{2}' --adminurl '{3}' --internalurl '{4}'" .format(region, id, publicurl, adminurl, internalurl)) else: osutils.run_std( "keystone endpoint-create --region {0} --service-id {1} --publicurl '{2}' --adminurl '{3}' --internalurl '{4}'" .format(region, id, publicurl, adminurl, internalurl))
def vg_create(vgname): osutils.run_std('apt-get install -y lvm2') out = osutils.run('vgscan') print(out) if not vgname in out: lvm_disk = get_lvm_disk() if lvm_disk != None: print('info: add vg ' + vgname + ' to lvm disk ' + lvm_disk) out = osutils.run('vgcreate ' + vgname + ' ' + lvm_disk) print(out)
def main(): osutils.run_std('apt-get install -y ntp') first_str = """server ntp.ubuntu.com iburst server 127.127.1.0 fudge 127.127.1.0 stratum 10 """ ntp_conf = patcher.read_text_file('/etc/ntp.conf') if not ntp_conf.startswith(first_str): with open('/etc/ntp.conf', 'w') as f: f.write(first_str + ntp_conf) print("info: added servers to ntp.conf") # Restart network and ntp services osutils.run_std('service ntp restart')
def main(): osutils.run_std('apt-get install -y rabbitmq-server python-amqplib') osutils.run_std('service rabbitmq-server restart') time.sleep(2) osutils.run_std('./rabbitpwd.py')
def setup_root_pass(): if os.system('mysqladmin -u root status') == 0: osutils.run_std('mysqladmin -u root password ' + openstack_pass.root_db_pass)
out = osutils.run('vgscan') print(out) if not vgname in out: lvm_disk = get_lvm_disk() if lvm_disk != None: print('info: add vg ' + vgname + ' to lvm disk ' + lvm_disk) out = osutils.run('vgcreate ' + vgname + ' ' + lvm_disk) print(out) if openstack_conf.version == 'essex': if openstack_conf.cinder_vgcreate: vg_create('nova-volumes') osutils.run_std('apt-get install -y nova-volume') else: if openstack_conf.cinder_vgcreate: vg_create('cinder-volumes') osutils.run_std( 'apt-get install -y cinder-api cinder-scheduler cinder-volume iscsitarget iscsitarget-dkms' ) # Create database for Cinder osutils.run_std("mysql -u root -p%s -e 'CREATE DATABASE cinder;'" % (openstack_pass.root_db_pass)) osutils.run_std( "mysql -u root -p%s -e \"GRANT ALL ON cinder.* TO 'cinder'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, '%', openstack_pass.cinder_db_pass)) osutils.run_std( "mysql -u root -p%s -e \"GRANT ALL ON cinder.* TO 'cinder'@'%s' IDENTIFIED BY '%s';\""
#!/usr/bin/python import os.path import patcher import openstack_conf import openstack_pass import shutil import osutils osutils.beroot() if openstack_conf.my_ip == openstack_conf.controller_ip: # Create database for Nova osutils.run_std("mysql -u root -p%s -e 'CREATE DATABASE nova;'" % (openstack_pass.root_db_pass) ) osutils.run_std("mysql -u root -p%s -e \"GRANT ALL ON nova.* TO 'nova'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, '%', openstack_pass.nova_db_pass) ) osutils.run_std("mysql -u root -p%s -e \"GRANT ALL ON nova.* TO 'nova'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, 'localhost', openstack_pass.nova_db_pass) ) osutils.run_std("mysql -u root -p%s -e \"GRANT ALL ON nova.* TO 'nova'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, openstack_pass.controller_host, openstack_pass.nova_db_pass) ) if openstack_conf.my_ip == openstack_conf.controller_ip: packages = 'nova-api nova-cert nova-common nova-compute nova-doc python-nova python-novaclient nova-consoleauth nova-scheduler nova-network' if openstack_conf.version == 'grizzly': packages = packages + ' nova-conductor' else: packages = 'nova-compute nova-network nova-api' if openstack_conf.hyperv == 'qemu': print "info: setup qemu" packages = packages + ' nova-compute-qemu qemu' elif openstack_conf.hyperv == 'kvm': print "info: setup kvm" packages = packages + ' nova-compute-kvm kvm'
#!/usr/bin/python import patcher import openstack_conf import openstack_pass import time import osutils import os osutils.beroot() #Create database for Glance osutils.run_std("mysql -u root -p%s -e 'CREATE DATABASE glance;'" % (openstack_pass.root_db_pass)) osutils.run_std( "mysql -u root -p%s -e \"GRANT ALL ON glance.* TO 'glance'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, '%', openstack_pass.glance_db_pass)) osutils.run_std( "mysql -u root -p%s -e \"GRANT ALL ON glance.* TO 'glance'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, 'localhost', openstack_pass.glance_db_pass)) osutils.run_std( "mysql -u root -p%s -e \"GRANT ALL ON glance.* TO 'glance'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, openstack_pass.controller_host, openstack_pass.glance_db_pass)) sql = "mysql://*****:*****@%s:3306/glance" % (openstack_pass.glance_db_pass, openstack_pass.controller_host) if openstack_conf.version == 'essex': osutils.run_std(
#!/usr/bin/python import patcher import osutils osutils.beroot() osutils.run_std('apt-get install -y bridge-utils vlan') props={} props["net.ipv4.ip_forward"] = ("0", "1") props["net.ipv4.conf.all.rp_filter"] = (None, "0") props["net.ipv4.conf.default.rp_filter"] = (None, "0") p = patcher.patch_file("/etc/sysctl.conf", props) print("info: /etc/sysctl.conf patched " + str(p)) osutils.run_std('sysctl net.ipv4.ip_forward=1') # Append eth1 to /etc/network/interface # # auto eth1 # iface eth1 inet manual # up ifconfig $IFACE 0.0.0.0 up # up ifconfig $IFACE promisc # # Restart network # osutils.run_std('service networking restart')
out = osutils.run('vgscan') print(out) if not vgname in out: lvm_disk = get_lvm_disk() if lvm_disk != None: print('info: add vg ' + vgname + ' to lvm disk ' + lvm_disk) out = osutils.run('vgcreate ' + vgname + ' ' + lvm_disk) print(out) if openstack_conf.version == 'essex': if openstack_conf.cinder_vgcreate: vg_create('nova-volumes') osutils.run_std('apt-get install -y nova-volume') else: if openstack_conf.cinder_vgcreate: vg_create('cinder-volumes') osutils.run_std('apt-get install -y cinder-api cinder-scheduler cinder-volume iscsitarget iscsitarget-dkms') # Create database for Cinder osutils.run_std("mysql -u root -p%s -e 'CREATE DATABASE cinder;'" % (openstack_pass.root_db_pass) ) osutils.run_std("mysql -u root -p%s -e \"GRANT ALL ON cinder.* TO 'cinder'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, '%', openstack_pass.cinder_db_pass) ) osutils.run_std("mysql -u root -p%s -e \"GRANT ALL ON cinder.* TO 'cinder'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, 'localhost', openstack_pass.cinder_db_pass) ) osutils.run_std("mysql -u root -p%s -e \"GRANT ALL ON cinder.* TO 'cinder'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, openstack_pass.controller_host, openstack_pass.cinder_db_pass) ) # Patch confs props = {} props['service_host'] = ('127.0.0.1', openstack_pass.controller_host) props['auth_host'] = ('127.0.0.1', openstack_pass.controller_host)
def install_mysql(): osutils.run_std( 'export DEBIAN_FRONTEND=noninteractive && apt-get install -q -y mysql-server' )
'export DEBIAN_FRONTEND=noninteractive && apt-get install -q -y mysql-server' ) def setup_root_pass(): if os.system('mysqladmin -u root status') == 0: osutils.run_std('mysqladmin -u root password ' + openstack_pass.root_db_pass) def install_python_mysql(): osutils.run_std('apt-get install -y python-mysqldb') install_mysql() while not os.path.exists('/etc/mysql/my.cnf'): print('warn: file /etc/mysql/my.cnf not found, reinstalling mysql') install_mysql() setup_root_pass() install_python_mysql() props = {} props['bind-address'] = ('127.0.0.1', '0.0.0.0') p = patcher.patch_file("/etc/mysql/my.cnf", props, True) print("info: my.cnf patched " + str(p)) #Restart MySQL osutils.run_std('service mysql restart')
#!/usr/bin/python import os import openstack_conf import osutils osutils.beroot() if openstack_conf.version in ["folsom", "grizzly"]: if not os.path.exists('/etc/apt/sources.list.d/openstack.list'): packages_str = 'apt-get -y install ubuntu-cloud-keyring python-software-properties software-properties-common python-keyring' sources_list = 'echo deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/' + openstack_conf.version + ' main >> /etc/apt/sources.list.d/openstack.list' osutils.run_std(packages_str) osutils.run_std(sources_list) osutils.run_std('apt-get update') osutils.run_std('apt-get -y upgrade') osutils.run_std('apt-get -y dist-upgrade')
def install_python_mysql(): osutils.run_std('apt-get install -y python-mysqldb')
#!/usr/bin/python import patcher import osutils osutils.beroot() osutils.run_std('apt-get install -y bridge-utils vlan') props = {} props["net.ipv4.ip_forward"] = ("0", "1") props["net.ipv4.conf.all.rp_filter"] = (None, "0") props["net.ipv4.conf.default.rp_filter"] = (None, "0") p = patcher.patch_file("/etc/sysctl.conf", props) print("info: /etc/sysctl.conf patched " + str(p)) osutils.run_std('sysctl net.ipv4.ip_forward=1') # Append eth1 to /etc/network/interface # # auto eth1 # iface eth1 inet manual # up ifconfig $IFACE 0.0.0.0 up # up ifconfig $IFACE promisc # # Restart network # osutils.run_std('service networking restart')
#!/usr/bin/python import os import openstack_conf import osutils osutils.beroot() if not openstack_conf.use_quantum: hasNetwork = False if openstack_conf.version == 'essex': hasNetwork = os.system('nova-manage network list') == 0 print('info: exception is ok') else: out = osutils.run('nova-manage network list') cidr = openstack_conf.fixed_range.split('/')[0] print("cidr = " + cidr) hasNetwork = cidr in out if not hasNetwork: print('info: network create %s on %s' % (openstack_conf.fixed_range, openstack_conf.fixed_int) ) osutils.run_std('nova-manage network create private --fixed_range_v4=%s --num_networks=1 --bridge=br100 --bridge_interface=%s --network_size=250 --multi_host=T' % (openstack_conf.fixed_range, openstack_conf.fixed_int) ) floatingOut = osutils.run('nova-manage floating list') if floatingOut.find('No floating') >= 0: print("info: floating create " + openstack_conf.floating_range) osutils.run_std('nova-manage floating create --ip_range=%s' % (openstack_conf.floating_range) )
#!/usr/bin/python import openstack_conf import openstack_pass import patcher import osutils import keystone_utils osutils.beroot() osutils.run_std("mysql -u root -p%s -e 'CREATE DATABASE keystone;'" % (openstack_pass.root_db_pass) ) osutils.run_std("mysql -u root -p%s -e \"GRANT ALL ON keystone.* TO 'keystone'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, '%', openstack_pass.keystone_db_pass) ) osutils.run_std("mysql -u root -p%s -e \"GRANT ALL ON keystone.* TO 'keystone'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, 'localhost', openstack_pass.keystone_db_pass) ) osutils.run_std("mysql -u root -p%s -e \"GRANT ALL ON keystone.* TO 'keystone'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, openstack_pass.controller_host, openstack_pass.keystone_db_pass) ) osutils.run_std('apt-get install -y keystone python-keystone python-keystoneclient') props = {} props['[DEFAULT]bind_host'] = (None, '0.0.0.0') props['[DEFAULT]admin_token'] = ('ADMIN', openstack_pass.admin_token) props['[DEFAULT]verbose'] = (None, openstack_conf.verbose) props['[DEFAULT]debug'] = (None, openstack_conf.debug) props['[DEFAULT]public_port'] = (None, 5000) props['[DEFAULT]admin_port'] = (None, 35357) props['[DEFAULT]compute_port'] = (None, 8774) sql = "mysql://*****:*****@%s:3306/keystone" % (openstack_pass.keystone_db_pass, openstack_pass.controller_host) props['[sql]connection'] = ('sqlite:////var/lib/keystone/keystone.db', sql)
#!/usr/bin/python import openstack_conf import openstack_pass import osutils osutils.beroot() osutils.run_std('apt-get install -y memcached python-memcache') osutils.run_std('apt-get install -y libapache2-mod-wsgi openstack-dashboard') # osutils.run_std('dpkg --purge openstack-dashboard-ubuntu-theme') osutils.run_std('service apache2 restart') if openstack_conf.version == 'essex': print("Open horizon on http://%s" % (openstack_conf.controller_ip) ) else: print("Open horizon on http://%s/horizon" % (openstack_conf.controller_ip) ) print("username = admin") print("password = " + openstack_pass.openstack_pass)
#!/usr/bin/python import os.path import patcher import openstack_conf import openstack_pass import shutil import osutils osutils.beroot() if openstack_conf.my_ip == openstack_conf.controller_ip: # Create database for Nova osutils.run_std("mysql -u root -p%s -e 'CREATE DATABASE nova;'" % (openstack_pass.root_db_pass)) osutils.run_std( "mysql -u root -p%s -e \"GRANT ALL ON nova.* TO 'nova'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, '%', openstack_pass.nova_db_pass)) osutils.run_std( "mysql -u root -p%s -e \"GRANT ALL ON nova.* TO 'nova'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, 'localhost', openstack_pass.nova_db_pass)) osutils.run_std( "mysql -u root -p%s -e \"GRANT ALL ON nova.* TO 'nova'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, openstack_pass.controller_host, openstack_pass.nova_db_pass)) if openstack_conf.my_ip == openstack_conf.controller_ip: packages = 'nova-api nova-cert nova-common nova-compute nova-doc python-nova python-novaclient nova-consoleauth nova-scheduler nova-network' if openstack_conf.version == 'grizzly': packages = packages + ' nova-conductor'
#!/usr/bin/python import openstack_conf import openstack_pass import patcher import osutils import keystone_utils osutils.beroot() osutils.run_std("mysql -u root -p%s -e 'CREATE DATABASE keystone;'" % (openstack_pass.root_db_pass)) osutils.run_std( "mysql -u root -p%s -e \"GRANT ALL ON keystone.* TO 'keystone'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, '%', openstack_pass.keystone_db_pass)) osutils.run_std( "mysql -u root -p%s -e \"GRANT ALL ON keystone.* TO 'keystone'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, 'localhost', openstack_pass.keystone_db_pass)) osutils.run_std( "mysql -u root -p%s -e \"GRANT ALL ON keystone.* TO 'keystone'@'%s' IDENTIFIED BY '%s';\"" % (openstack_pass.root_db_pass, openstack_pass.controller_host, openstack_pass.keystone_db_pass)) osutils.run_std( 'apt-get install -y keystone python-keystone python-keystoneclient') props = {} props['[DEFAULT]bind_host'] = (None, '0.0.0.0') props['[DEFAULT]admin_token'] = ('ADMIN', openstack_pass.admin_token)
#!/usr/bin/python import patcher import openstack_conf import openstack_pass import osutils import keystone_utils osutils.beroot() if not openstack_conf.use_quantum: exit("info: use_quantum False") osutils.run_std('apt-get install -y openvswitch-switch openvswitch-datapath-dkms') listBr = osutils.run('ovs-vsctl list-br') if not 'br-int' in listBr: print('info: add-br br-int') osutils.run_std('ovs-vsctl add-br br-int') if not 'br-ex' in listBr: print('info: add-br br-ex') osutils.run_std('ovs-vsctl add-br br-ex') osutils.run_std('ovs-vsctl br-set-external-id br-ex bridge-id br-ex') listBr = osutils.run('ovs-vsctl list-ports br-int') if not openstack_conf.fixed_int in listBr: print('info: add-port br-int ' + openstack_conf.fixed_int) osutils.run_std('ovs-vsctl add-port br-int ' + openstack_conf.fixed_int) listBr = osutils.run('ovs-vsctl list-ports br-ex')
#!/usr/bin/python import osutils osutils.beroot() osutils.run_std('apt-get install -y nova-objectstore')
#!/usr/bin/python import openstack_conf import openstack_pass import osutils osutils.beroot() osutils.run_std('apt-get install -y memcached python-memcache') osutils.run_std('apt-get install -y libapache2-mod-wsgi openstack-dashboard') # osutils.run_std('dpkg --purge openstack-dashboard-ubuntu-theme') osutils.run_std('service apache2 restart') if openstack_conf.version == 'essex': print("Open horizon on http://%s" % (openstack_conf.controller_ip)) else: print("Open horizon on http://%s/horizon" % (openstack_conf.controller_ip)) print("username = admin") print("password = " + openstack_pass.openstack_pass)
#!/usr/bin/python import openstack_conf import openstack_pass import osutils osutils.beroot() if not openstack_pass.has_creds(): exit("run 'source creds' in your shell"); if openstack_conf.apt_update: osutils.run_std('./aptupdate.py') osutils.run_std('./interfaces.py') osutils.run_std('./ntp.py') if openstack_conf.my_ip == openstack_conf.controller_ip: osutils.run_std('./mysql.py') osutils.run_std('./rabbit.py') osutils.run_std('./keystone.py') osutils.run_std('./glance.py') osutils.run_std('./nova.py') if openstack_conf.my_ip == openstack_conf.controller_ip: osutils.run_std('apt-get install -y dnsmasq') osutils.run_std('./cinder.py') osutils.run_std('./network.py') osutils.run_std('./quantum.py')