def mustDoOnHost(): selinuxStatus = run("grep -w ^SELINUX /etc/selinux/config") if ("enforcing" in selinuxStatus): sed('/etc/selinux/config', 'SELINUX=enforcing', 'SELINUX=disabled') print( red(" REBOOT ") + green(" REBOOT ") + blue(" REBOOT ") + " REBOOT ") abort("you must reboot") with settings(warn_only=True): fwdstatus = run("systemctl is-active firewalld") if (fwdstatus != "unknown"): msg = 'Stop & Disable firewalld on ' + env.host runCheck(msg, 'systemctl stop firewalld ; systemctl disable firewalld') msg = 'Renaming host to %s' % env['host'] run('hostnamectl set-hostname %s' % env['host']) printMessage("good", msg) logging.info(msg) with settings(warn_only=True): hostsStatus = run('grep controller /etc/hosts') if (hostsStatus.return_code != 0): msg = "updating /etc/hosts" for host in nicDictionary.keys(): newline = '%s\t%s' % (nicDictionary[host]['mgtIPADDR'], host) runCheck(msg, "echo '%s' >> /etc/hosts" % newline)
def setup_cinder_database_on_controller(): mysql_commands = createDatabaseScript("cinder", passwd['CINDER_DBPASS']) msg = 'Create the database' runCheck( msg, 'echo "%s" | mysql -u root -p%s' % (mysql_commands, env_config.passwd['ROOT_SECRET']))
def tdd(): """ Create some test instances """ with prefix(env_config.admin_openrc): for tag in vlans: netid = run( "neutron net-list | grep vlan | awk '/%d/ {print $2}'" % tag) if not netid: print align_n("No vlan network found for tag %d" % tag) sys.exit(1) instanceName = 'test-vlan-%d' % tag msg = 'Launch instance for vlan %d' % tag runCheck( msg, "nova boot " "--flavor m1.tiny " "--image cirros-test " "--nic net-id=%s " "--security-group default " " %s" % (netid, instanceName)) # restart all services # execute(restartServices) time.sleep(20) run('nova list')
def createRing(typeRing,port,IP,deviceName,deviceWeight): # ASSUMES A SINGLE DEVICE ON STORAGE NODE port = str(port) with cd('/etc/swift/'): # verify if ring is already there out = run("swift-ring-builder %s.builder" % (typeRing),quiet=True) if 'does not exist' in out: # ring is not created yet # Create the base *.builder file run("swift-ring-builder %s.builder create 10 3 1" % (typeRing)) # Add node to the ring run("swift-ring-builder %s.builder add r1z1-%s:%s/%s %s" % (typeRing,IP,port,deviceName,deviceWeight)) # rebalance ring run("swift-ring-builder %s.builder rebalance" % (typeRing)) else: print blue("Ring {} already exists. Nothing done".format(typeRing)) run("ls") msg = 'Restart proxy server service' runCheck(msg, 'systemctl restart openstack-swift-proxy.service')
def createInitialRings(): """ Create 3 initial rings as a test """ managementIP = env_config.nicDictionary['compute1']['mgtIPADDR'] deviceLocation = swiftGlusterDir deviceName = "rings" deviceWeight = '100' # deviceName = "/dev/sdd" msg = 'create new directory for the rings' runCheck(msg, 'mkdir -p %s/%s' % (deviceLocation, deviceName)) # create account ring createRing('account',6002,managementIP,deviceName,deviceWeight) # create container ring createRing('container',6001,managementIP,deviceName,deviceWeight) # create object ring createRing('object',6000,managementIP,deviceName,deviceWeight) execute(grabGZfiles) execute(saveGZfiles)
def create_stack(): """ Create a stack on the demo-net (assuming it exists) """ with prefix(env_config.demo_openrc): # Upload the test file to the host put(heat_test_file) msg = "Grab the net id for demo-net" netid = runCheck(msg, "nova net-list | awk '/ demo-net / { print $2 }'") # Create a test stack based on the test file msg = "Create a test stack" runCheck( msg, "heat stack-create -f test-stack.yml " '-P "ImageID=cirros-0.3.3-x86_64;NetID={}" testStack'.format( netid)) output = run("heat stack-list") if "testStack" in output: print(green("Stack created succesfully")) else: print(red("Stack NOT created")) status = 'bad'
def test(): with prefix(env_config.admin_openrc): for tag in vlans: try: netid = run("neutron net-list | grep vlan | awk '/%d/ {print $2}'" % tag) except: print align_n("No vlan network found for tag %d" % tag) raise ValueError instanceName = 'test-vlan-%d' % tag msg = 'Launch instance for vlan %d' % tag try: runCheck(msg, "nova boot " "--flavor m1.tiny " "--image cirros-test " "--nic net-id=%s " "--security-group default " " %s" % (netid, instanceName)) except: run('source neutron_log') time.sleep(15) run('nova list')
def setup_cinder_config_files_on_storage(): CINDER_DBPASS = passwd["CINDER_DBPASS"] CINDER_PASS = passwd["CINDER_PASS"] RABBIT_PASS = passwd["RABBIT_PASS"] STORAGE_MANAGEMENT_IP = env_config.nicDictionary["storage1"]["mgtIPADDR"] install_command = "yum install -y openstack-cinder targetcli python-oslo-db MySQL-python" runCheck("Install packages on storage node", install_command) set_parameter( etc_cinder_config_file, "database", "connection", "mysql://*****:*****@controller/cinder".format(CINDER_DBPASS) ) set_parameter(etc_cinder_config_file, "DEFAULT", "rpc_backend", "rabbit") set_parameter(etc_cinder_config_file, "DEFAULT", "rabbit_host", "controller") set_parameter(etc_cinder_config_file, "DEFAULT", "rabbit_password", RABBIT_PASS) set_parameter(etc_cinder_config_file, "DEFAULT", "auth_strategy", "keystone") set_parameter(etc_cinder_config_file, "keystone_authtoken", "auth_uri", "http://controller:5000/v2.0") set_parameter(etc_cinder_config_file, "keystone_authtoken", "identity_uri", "http://controller:35357") set_parameter(etc_cinder_config_file, "keystone_authtoken", "admin_tenant_name", "service") set_parameter(etc_cinder_config_file, "keystone_authtoken", "admin_user", "cinder") set_parameter(etc_cinder_config_file, "keystone_authtoken", "admin_password", CINDER_PASS) set_parameter(etc_cinder_config_file, "DEFAULT", "my_ip", STORAGE_MANAGEMENT_IP) set_parameter(etc_cinder_config_file, "DEFAULT", "iscsi_helper", "lioadm") set_parameter(etc_cinder_config_file, "DEFAULT", "glance_host", "controller") set_parameter(etc_cinder_config_file, "DEFAULT", "verbose", "True")
def setup_cinder_config_files_on_controller(): installation_command = "yum install -y openstack-cinder python-oslo-db MySQL-python" # installation_command = "yum install -y openstack-cinder python-cinderclient python-oslo-db" runCheck("Install the packages", installation_command) set_parameter( etc_cinder_config_file, "database", "connection", "mysql://*****:*****@controller/cinder" % passwd["CINDER_DBPASS"], ) set_parameter(etc_cinder_config_file, "DEFAULT", "rpc_backend", "rabbit") set_parameter(etc_cinder_config_file, "DEFAULT", "rabbit_host", "controller") set_parameter(etc_cinder_config_file, "DEFAULT", "rabbit_password", passwd["RABBIT_PASS"]) set_parameter(etc_cinder_config_file, "DEFAULT", "auth_strategy", "keystone") set_parameter(etc_cinder_config_file, "keystone_authtoken", "auth_uri", "http://controller:5000/v2.0") set_parameter(etc_cinder_config_file, "keystone_authtoken", "identity_uri", "http://controller:35357") set_parameter(etc_cinder_config_file, "keystone_authtoken", "admin_tenant_name", "service") set_parameter(etc_cinder_config_file, "keystone_authtoken", "admin_user", "cinder") set_parameter(etc_cinder_config_file, "keystone_authtoken", "admin_password", passwd["CINDER_PASS"]) set_parameter(etc_cinder_config_file, "DEFAULT", "my_ip", env_config.nicDictionary["controller"]["mgtIPADDR"]) set_parameter(etc_cinder_config_file, "DEFAULT", "glance_host", "controller") # new line set_parameter(etc_cinder_config_file, "DEFAULT", "verbose", "True")
def start_glance_services(): msg = "Enable glance services" runCheck(msg, "systemctl enable openstack-glance-api.service " "openstack-glance-registry.service") msg = "Start glance services" runCheck(msg, "systemctl start openstack-glance-api.service " "openstack-glance-registry.service")
def tdd(): """ Create some test instances """ with prefix(env_config.admin_openrc): for tag in vlans: netid = run("neutron net-list | grep vlan | awk '/%d/ {print $2}'" % tag) if not netid: print align_n("No vlan network found for tag %d" % tag) sys.exit(1) instanceName = 'test-vlan-%d' % tag msg = 'Launch instance for vlan %d' % tag runCheck(msg, "nova boot " "--flavor m1.tiny " "--image cirros-test " "--nic net-id=%s " "--security-group default " " %s" % (netid, instanceName)) # restart all services # execute(restartServices) time.sleep(20) run('nova list')
def network_deploy(): # edit sysctl.conf # make a backup backupConfFile(sysctl_conf, backupSuffix) set_parameter(sysctl_conf, "''", 'net.ipv4.ip_forward', '1') set_parameter(sysctl_conf, "''", 'net.ipv4.conf.all.rp_filter', '0') set_parameter(sysctl_conf, "''", 'net.ipv4.conf.default.rp_filter', '0') msg = "Implement changes on sysctl" runCheck( msg, "sysctl --system" ) # for more info visit: http://www.commandlinefu.com/commands/view/11891/reload-all-sysctl-variables-without-reboot installPackagesNetwork() # configuration configure_the_Networking_common_components() configure_ML2_plug_in_network() configure_Layer3_agent() configure_DHCP_agent() configure_metadata_agent() configure_Open_vSwitch_service() # finalize installation # The Networking service initialization scripts expect a symbolic link /etc/neutron/plugin.ini # pointing to the ML2 plug-in configuration file, /etc/neutron/plugins/ml2/ml2_conf.ini. # If this symbolic link does not exist, create it if 'plugin.ini' not in run('ls /etc/neutron'): msg = "Create symbolic link to ml2 conf file" runCheck( msg, 'ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini' ) # Due to a packaging bug, the Open vSwitch agent initialization script explicitly looks for # the Open vSwitch plug-in configuration file rather than a symbolic link /etc/neutron/plugin.ini pointing to the ML2 # plug-in configuration file. Run the following commands to resolve this issue: run("cp /usr/lib/systemd/system/neutron-openvswitch-agent.service " + \ "/usr/lib/systemd/system/neutron-openvswitch-agent.service.orig") run("sed -i 's,plugins/openvswitch/ovs_neutron_plugin.ini,plugin.ini,g' " + \ "/usr/lib/systemd/system/neutron-openvswitch-agent.service") # initialize services msg = "Enable neutron services" run("systemctl enable neutron-openvswitch-agent.service neutron-l3-agent.service " + \ "neutron-dhcp-agent.service neutron-metadata-agent.service " + \ "neutron-ovs-cleanup.service") msg = "Start neutron services" run("systemctl start neutron-openvswitch-agent.service neutron-l3-agent.service " + \ "neutron-dhcp-agent.service neutron-metadata-agent.service")
def test(): with prefix(env_config.admin_openrc): for tag in vlans: try: netid = run( "neutron net-list | grep vlan | awk '/%d/ {print $2}'" % tag) except: print align_n("No vlan network found for tag %d" % tag) raise ValueError instanceName = 'test-vlan-%d' % tag msg = 'Launch instance for vlan %d' % tag try: runCheck( msg, "nova boot " "--flavor m1.tiny " "--image cirros-test " "--nic net-id=%s " "--security-group default " " %s" % (netid, instanceName)) except: run('source neutron_log') time.sleep(15) run('nova list')
def createRing(typeRing, port, IP, deviceName, deviceWeight): # ASSUMES A SINGLE DEVICE ON STORAGE NODE port = str(port) with cd('/etc/swift/'): # verify if ring is already there out = run("swift-ring-builder %s.builder" % (typeRing), quiet=True) if 'does not exist' in out: # ring is not created yet # Create the base *.builder file run("swift-ring-builder %s.builder create 10 3 1" % (typeRing)) # Add node to the ring run("swift-ring-builder %s.builder add r1z1-%s:%s/%s %s" % (typeRing, IP, port, deviceName, deviceWeight)) # rebalance ring run("swift-ring-builder %s.builder rebalance" % (typeRing)) else: print blue("Ring {} already exists. Nothing done".format(typeRing)) run("ls") msg = 'Restart proxy server service' runCheck(msg, 'systemctl restart openstack-swift-proxy.service')
def createInitialRings(): """ Create 3 initial rings as a test """ managementIP = env_config.nicDictionary['compute1']['mgtIPADDR'] deviceLocation = swiftGlusterDir deviceName = "rings" deviceWeight = '100' # deviceName = "/dev/sdd" msg = 'create new directory for the rings' runCheck(msg, 'mkdir -p %s/%s' % (deviceLocation, deviceName)) # create account ring createRing('account', 6002, managementIP, deviceName, deviceWeight) # create container ring createRing('container', 6001, managementIP, deviceName, deviceWeight) # create object ring createRing('object', 6000, managementIP, deviceName, deviceWeight) execute(grabGZfiles) execute(saveGZfiles)
def setup_heat_config_files(HEAT_PASS, HEAT_DBPASS, RABBIT_PASS): msg = 'Install packages' runCheck( msg, "yum install -y openstack-heat-api openstack-heat-api-cfn openstack-heat-engine python-heatclient" ) set_parameter(etc_heat_config_file, 'database', 'connection', 'mysql://*****:*****@controller/heat'.format(HEAT_DBPASS)) set_parameter(etc_heat_config_file, 'DEFAULT', 'rpc_backend', 'rabbit') set_parameter(etc_heat_config_file, 'DEFAULT', 'rabbit_host', 'controller') set_parameter(etc_heat_config_file, 'DEFAULT', 'rabbit_password', RABBIT_PASS) set_parameter(etc_heat_config_file, 'keystone_authtoken', 'auth_uri', 'http://controller:5000/v2.0') set_parameter(etc_heat_config_file, 'keystone_authtoken', 'identity_uri', 'http://controller:35357') set_parameter(etc_heat_config_file, 'keystone_authtoken', 'admin_tenant_name', 'service') set_parameter(etc_heat_config_file, 'keystone_authtoken', 'admin_user', 'heat') set_parameter(etc_heat_config_file, 'keystone_authtoken', 'admin_password', HEAT_PASS) set_parameter(etc_heat_config_file, 'ec2authtoken', 'auth_uri', 'http://controller:5000/v2.0') set_parameter(etc_heat_config_file, 'DEFAULT', 'heat_metadata_server_url', 'http://controller:8000') set_parameter(etc_heat_config_file, 'DEFAULT', 'heat_waitcondition_server_url', 'http://controller:8000/v1/waitcondition') set_parameter(etc_heat_config_file, 'DEFAULT', 'verbose', 'True')
def installPackagesCompute(): msg = "Install Neutron packages on " + env.host runCheck(msg, "yum -y install " "openstack-neutron-ml2 " "openstack-neutron-openvswitch", )
def install_packages_on_compute(): # Install packages msg = "Install OpenStack Ceilometer packages" runCheck( msg, "yum install -y openstack-ceilometer-compute python-ceilometerclient python-pecan" )
def setup_mongo_on_controller(): CONTROLLER_IP = env_config.nicDictionary['controller']['mgtIPADDR'] run("yum install -y mongodb-server mongodb") confFile = "/etc/mongod.conf" sed_command = """sed -i 's/bind_ip = 127.0.0.1/bind_ip = {}/g' {}""".format( CONTROLLER_IP, confFile) runCheck('set bind_ip', sed_command) # bind_ip_in_conf = run("cat {} | grep bind_ip | awk '// {print $3}'".format(confFile), quiet=True) # if CONTROLLER_IP == bind_ip_in_conf: bind_ip_in_conf = run("cat {} | grep bind_ip".format(confFile), quiet=True) if CONTROLLER_IP in bind_ip_in_conf: print(blue("bind_ip setup to " + CONTROLLER_IP)) else: print(red("weird cuz bind_ip is " + bind_ip_in_conf)) sed_command = """sed -i 's/#smallfiles = true/smallfiles = true/g' {}""".format( confFile) runCheck('set smallfiles = true', sed_command) smallfiles_in_conf = run("cat {} | grep smallfiles".format(confFile), quiet=True) if "smallfiles = true" in smallfiles_in_conf and "#smallfiles = true" not in smallfiles_in_conf: print(blue("smallfiles setup to " + smallfiles_in_conf)) else: print(red("weird cuz smallfiles is " + smallfiles_in_conf)) runCheck('Enable mongo', 'systemctl enable mongod.service') runCheck('Start mongo', 'systemctl start mongod.service') runCheck('Restart mongo', 'systemctl restart mongod.service')
def controller_deploy(): execute(create_neutron_database) execute(setup_keystone_controller) execute(installPackagesController) execute(configure_networking_server_component) configure_ML2_plugin_general() execute(configure_nova_to_use_neutron) # The Networking service initialization scripts expect a symbolic link /etc/neutron/plugin.ini # pointing to the ML2 plug-in configuration file, /etc/neutron/plugins/ml2/ml2_conf.ini. # If this symbolic link does not exist, create it if 'plugin.ini' not in run('ls /etc/neutron'): msg = "Create symbolic link to ml2 conf file" runCheck(msg, 'ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini') msg = "Populate the database for neutron" runCheck(msg, 'su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf ' + \ '--config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade juno" neutron') # Restart nova msg = "Restart Nova services" runCheck(msg, 'systemctl restart openstack-nova-api.service openstack-nova-scheduler.service' + \ ' openstack-nova-conductor.service') msg = "Enable Neutron service" runCheck(msg, 'systemctl enable neutron-server.service') msg = "Enable Neutron service" runCheck(msg, 'systemctl start neutron-server.service') execute(restart_nova_controller)
def olddestroy_cinder_volume(): with prefix(env_config.admin_openrc): runCheck('Delete volume', 'cinder delete myvol') runCheck( 'Stop cinder', 'for i in api scheduler volume; do sudo service openstack-cinder-${i} stop; done' )
def mounter(VOLUME): runCheck('Making mount point', 'mkdir -p /mnt/gluster/{}'.format(VOLUME)) if run('mount | grep {} | grep /mnt/gluster/{}'.format(VOLUME, VOLUME), warn_only=True).return_code: runCheck( 'Mounting mount point', 'mount -t glusterfs {}:/{} /mnt/gluster/{}/'.format( env.host, VOLUME, VOLUME))
def oldcinderVolumeCreate(): with prefix(env_config.admin_openrc): runCheck('Create a Cinder volume', 'cinder create --display_name myvol 10') #with settings(warn_only=True): if runCheck('Check to see if volume is created', 'cinder list | grep -i available'): print(green('Volume created'))
def startServicesController(): msg = 'Start the Object Storage proxy service on the controller node' runCheck( msg, "systemctl enable openstack-swift-proxy.service memcached.service") msg = 'Enable the Object Storage proxy service on the controller node' runCheck( msg, "systemctl start openstack-swift-proxy.service memcached.service")
def make_nfs_directories(): runCheck("Make nfs cinder directory", "mkdir %s" % nfs_share) runCheck("Make nfs swift directory", "mkdir /home/swift") runCheck("Setup exports file", "echo '%s 192.168.1.0/24(rw,sync)'>/etc/exports" % nfs_share) runCheck("Continue setting up exports file", "echo '/home/swift 192.168.1.0/24(rw,sync)'>>/etc/exports") runCheck("Change cinder NFS file permissions", "chown -R 65534:65534 %s/" % nfs_share)
def connectBridgeAndInterface(tag): """ Given a VLAN tag, connect the corresponding bridge and virtual interface """ br = bridge[tag] interface = virtualInterfaces[tag] msg = 'Connect %s and %s' % (br, interface) runCheck(msg, "ovs-vsctl add-port %s %s" % (br, interface))
def start_cinder_services_on_controller(): services = ["openstack-cinder-api", "openstack-cinder-scheduler", "openstack-cinder-volume", "target"] for service in services: msg = "Enable %s service" % service runCheck(msg, "systemctl enable %s.service" % service) msg = "Start %s service" % service runCheck(msg, "systemctl start %s.service" % service)
def removeBridges(): delete = ['br-ex'] for br in delete: if br in run("ovs-vsctl list-br"): msg = 'Delete bridge ' + br runCheck(msg, "ovs-vsctl del-br " + br) else: print blue('No bridge called ' + br)
def createRouter(): "Create a virtual router for the VLANs" router = 'router01' if router in run('neutron router-list'): print blue('Router %s already created' % router) else: msg = 'Create virtual router' runCheck(msg, 'neutron router-create ' + router)
def installPackagesController(): msg = "Install Neutron packages on controller" runCheck( msg, 'yum -y install ' 'openstack-neutron ' 'openstack-neutron-ml2 ' 'python-neutronclient ' 'which')
def setup_nova_database_on_controller(): NOVA_DBPASS = passwd['NOVA_DBPASS'] mysql_commands = createDatabaseScript('nova',NOVA_DBPASS) msg = "Create database for Nova" runCheck(msg, 'echo "' + mysql_commands + '" | mysql -u root -p' + env_config.passwd['ROOT_SECRET'])
def installPackagesController(): msg = "Install Neutron packages on controller" runCheck(msg, 'yum -y install ' 'openstack-neutron ' 'openstack-neutron-ml2 ' 'python-neutronclient ' 'which')
def installPackagesNetwork(): msg = "Install Neutron packages on network" runCheck(msg, "yum -y install " "openstack-neutron " "openstack-neutron-ml2 " "openstack-neutron-openvswitch", )
def setup_heat_database(HEAT_DBPASS): mysql_commands = createDatabaseScript('heat', HEAT_DBPASS) msg = 'Create database for heat' runCheck( msg, 'echo "{}" | mysql -u root -p{}'.format( mysql_commands, env_config.passwd['ROOT_SECRET']))
def removePort(port): "Given a port name, remove it using the OVS CLI" # Check if the port exists if ('Port ' + port) in run('ovs-vsctl show ', quiet=True): msg = 'Remove port ' + port runCheck(msg, 'ovs-vsctl del-port ' + port) else: print 'No port named ' + port
def installRabbitMQ(): msg = "install rabbitmq-server erlang-sd_notify" runCheck(msg, 'yum -y install rabbitmq-server erlang-sd_notify') run('systemctl enable rabbitmq-server.service') run('systemctl start rabbitmq-server.service') run('systemctl restart rabbitmq-server.service') msg = "Changing rabbit guest password " runCheck(msg, 'rabbitmqctl change_password guest %s' % passwd['RABBIT_PASS'])
def setup_glance_database(): GLANCE_DBPASS=passwd['GLANCE_DBPASS'] mysql_commands = createDatabaseScript('glance',GLANCE_DBPASS) msg = "Create database for keystone" runCheck(msg, 'echo "' + mysql_commands + '" | mysql -u root -p"%s" ' % env_config.passwd['ROOT_SECRET']) run(' mysql -u root -p"%s" -e "select host, user, password from user where user=\'glance\'" mysql' % env_config.passwd['ROOT_SECRET'])
def start_glance_services(): msg = "Enable glance services" runCheck( msg, "systemctl enable openstack-glance-api.service " "openstack-glance-registry.service") msg = "Start glance services" runCheck( msg, "systemctl start openstack-glance-api.service " "openstack-glance-registry.service")
def installPackagesNetwork(): msg = "Install Neutron packages on network" runCheck( msg, "yum -y install " "openstack-neutron " "openstack-neutron-ml2 " "openstack-neutron-openvswitch", )
def finalize_installation(): # Configure SELinux # We don't use that # runCheck(msg, "setsebool -P httpd_can_network_connect on") # Due to a packaging bug, the dashboard CSS fails to load properly. # The following command fixes this issue: msg = "Set ownership on the openstack-dashboard/static file" runCheck(msg, "chown -R apache:apache /usr/share/openstack-dashboard/static")
def oldrestartCinder(): runCheck( 'Restart Cinder services', 'for i in api scheduler volume; do sudo service openstack-cinder-${i} start; done' ) runCheck( 'Check logs', "tail -50 /var/log/cinder/volume.log | egrep -i '(ERROR|WARNING|CRITICAL)'" )
def mount(volume): runCheck('Make mount point', 'mkdir -p /mnt/gluster/{}'.format(volume)) if run("mount | grep '{}' | grep /mnt/gluster/{}".format(volume, volume), warn_only=True).return_code: runCheck('Mount mount point', 'mount -t glusterfs {}:/{} /mnt/gluster/{}'.format( env.host, volume, volume)) append('/etc/fstab', '%s:/%s /mnt/gluster/%s glusterfs log-file=/root/%s.log,rw 0 0'%( env.host, volume, volume, volume))
def change_cinder_files(): runCheck( 'Change cinder.conf file', "crudini --set '/etc/cinder/cinder.conf' 'DEFAULT' 'volume_driver' 'cinder.volume.drivers.glusterfs.GlusterfsDriver'" ) runCheck( 'Change cinder.conf file', "crudini --set '/etc/cinder/cinder.conf' 'DEFAULT' 'glusterfs_shares_config' '/etc/cinder/shares.conf'" )
def test(): runCheck('Make mount point', 'mkdir -p /mnt/gluster/{}'.format(VOLUME)) if run("mount | grep '{}' | grep /mnt/gluster/{}".format(VOLUME, VOLUME), warn_only=True).return_code: runCheck('Mount mount point', 'mount -t glusterfs {}:/{} /mnt/gluster/{}'.format( env.host, VOLUME, VOLUME)) append('/etc/fstab', '%s:/%s /mnt/gluster/%s fuse.glusterfs rw,relatime,user_id=0,group_id=0,default_permissions,allow_other,max_read=131072 0 0'%( env.host, VOLUME, VOLUME))
def mount(): runCheck('Make mount point', 'mkdir -p /mnt/gluster') if run("mount | grep '{}' | grep /mnt/gluster".format(gluster_volume), warn_only=True).return_code: runCheck('Mount mount point', 'mount -t glusterfs {}:/{} /mnt/gluster'.format( env.host, gluster_volume)) append('/etc/fstab', '%s:/%s /mnt/gluster glusterfs log-file=/root/%s.log,rw,backupvolfile-server=%s 0 0'%( env.host, gluster_volume, gluster_volume, backup_volume_file_server))
def installPackagesCompute(): msg = "Install Neutron packages on " + env.host runCheck( msg, "yum -y install " "openstack-neutron-ml2 " "openstack-neutron-openvswitch", )
def defineDestination(): msg = 'Make a backup of keystone.conf' runCheck(msg, "cp %s %s.backup" % (confFile, confFile)) set_parameter(confFile, 'ldap', 'url', 'ldap://localhost') set_parameter(confFile, 'ldap', 'user', 'dc=Manager,dc=example,dc=org') set_parameter(confFile, 'ldap', 'password', '34ldappass43') set_parameter(confFile, 'ldap', 'suffix', 'dc=example,dc=org') set_parameter(confFile, 'ldap', 'use_dumb_member', 'False') set_parameter(confFile, 'ldap', 'allow_subtree_delete', 'False')
def createDemoNet(): with prefix(env_config.demo_openrc): if 'demo-net' in run('neutron net-list'): print blue('Demo-net already created') else: msg = 'Create initial demo tenant network on network node' runCheck(msg, 'neutron net-create demo-net') msg = 'Restart Neutron service' runCheck(msg, 'systemctl restart neutron-server.service')
def deployNIC(): config_file = '' print env.host if (nicDictionary[env.host]['tnlDEVICE']!=''): config_file += "DEVICE=" +nicDictionary[env.host]['tnlDEVICE'] + '\n' config_file += "IPADDR=" +nicDictionary[env.host]['tnlIPADDR'] + '\n' config_file += "NETMASK=" +nicDictionary[env.host]['tnlNETMASK'] + '\n' config_file_name = '/etc/sysconfig/network-scripts/ifcfg-' + nicDictionary[env.host]['tnlDEVICE'] msg = 'Set up NIC with conf file %s' % nicDictionary[env.host]['tnlDEVICE'] runCheck(msg, 'echo -e "%s" > %s' % (config_file,config_file_name))
def saveOpenrcFiles(): "Save the admin-openrc and demo-openrc files in the hosts" contents = env_config.admin_openrc msg = 'Put admin-openrc.sh in ' + env.host runCheck(msg, "echo '{}' >/root/admin-openrc.sh".format(contents)) contents = env_config.demo_openrc msg = 'Put demo-openrc.sh in ' + env.host runCheck(msg, "echo '{}' >/root/demo-openrc.sh".format(contents))
def makeBridge(tag): """ Given a VLAN tag, create its corresponding bridge """ br= bridge[tag] if br in run('ovs-vsctl list-br'): print blue('Bridge %s already created' % br) return msg = 'Create bridge %s ' % br runCheck(msg, "ovs-vsctl add-br %s" % br)
def createSubnets(): "Create Neutron subnets for each VLAN" with prefix(credentials): for tag, cidr in vlans.items(): netName = 'vlan' + str(tag) subnetName = 'vlansub' + str(tag) msg = 'Create subnet ' + subnetName runCheck(msg, 'neutron subnet-create %s --name %s --dns-nameserver %s %s' % (netName, subnetName, dns, cidr))
def saveOpenrcFiles(): "Save the admin-openrc and demo-openrc files in the hosts" contents = env_config.admin_openrc msg = 'Put admin-openrc.sh in '+env.host runCheck(msg, "echo '{}' >/root/admin-openrc.sh".format(contents)) contents = env_config.demo_openrc msg = 'Put demo-openrc.sh in '+env.host runCheck(msg, "echo '{}' >/root/demo-openrc.sh".format(contents))
def network_deploy(): # edit sysctl.conf # make a backup backupConfFile(sysctl_conf, backupSuffix) set_parameter(sysctl_conf,"''",'net.ipv4.ip_forward','1') set_parameter(sysctl_conf,"''",'net.ipv4.conf.all.rp_filter','0') set_parameter(sysctl_conf,"''",'net.ipv4.conf.default.rp_filter','0') msg = "Implement changes on sysctl" runCheck(msg, "sysctl --system") # for more info visit: http://www.commandlinefu.com/commands/view/11891/reload-all-sysctl-variables-without-reboot installPackagesNetwork() # configuration configure_the_Networking_common_components() configure_ML2_plug_in_network() configure_Layer3_agent() configure_DHCP_agent() configure_metadata_agent() configure_Open_vSwitch_service() # finalize installation # The Networking service initialization scripts expect a symbolic link /etc/neutron/plugin.ini # pointing to the ML2 plug-in configuration file, /etc/neutron/plugins/ml2/ml2_conf.ini. # If this symbolic link does not exist, create it if 'plugin.ini' not in run('ls /etc/neutron'): msg = "Create symbolic link to ml2 conf file" runCheck(msg, 'ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini') # Due to a packaging bug, the Open vSwitch agent initialization script explicitly looks for # the Open vSwitch plug-in configuration file rather than a symbolic link /etc/neutron/plugin.ini pointing to the ML2 # plug-in configuration file. Run the following commands to resolve this issue: run("cp /usr/lib/systemd/system/neutron-openvswitch-agent.service " + \ "/usr/lib/systemd/system/neutron-openvswitch-agent.service.orig") run("sed -i 's,plugins/openvswitch/ovs_neutron_plugin.ini,plugin.ini,g' " + \ "/usr/lib/systemd/system/neutron-openvswitch-agent.service") # initialize services msg = "Enable neutron services" run("systemctl enable neutron-openvswitch-agent.service neutron-l3-agent.service " + \ "neutron-dhcp-agent.service neutron-metadata-agent.service " + \ "neutron-ovs-cleanup.service") msg = "Start neutron services" run("systemctl start neutron-openvswitch-agent.service neutron-l3-agent.service " + \ "neutron-dhcp-agent.service neutron-metadata-agent.service")