def keystone_create_service_tenant():
    os.environ["OS_SERVICE_TOKEN"] = admin_token
    os.environ["OS_SERVICE_ENDPOINT"] = "http://controller:35357/v2.0"
    (status, output) = commands.getstatusoutput("keystone tenant-list")
    if status != 0:
       raise NameError(output)
    if(output.find("service") > 0):
        return
    common.command('keystone tenant-create --name=service --description="Service Tenant"')
def keystone_create_admin_user():
    os.environ["OS_SERVICE_TOKEN"] = admin_token
    os.environ["OS_SERVICE_ENDPOINT"] = "http://controller:35357/v2.0"
    (status, output) = commands.getstatusoutput("keystone user-list")
    if status != 0:
       raise NameError(output)
    if(output.find("admin") > 0):
        return
    common.command('keystone user-create --name=admin --pass=ADMIN_PASS --email=ADMIN_EMAIL')
    common.command('keystone role-create --name=admin')
    common.command('keystone tenant-create --name=admin --description="Admin Tenant"')
    common.command('keystone user-role-add --user=admin --tenant=admin --role=admin')
    common.command('keystone user-role-add --user=admin --role=_member_ --tenant=admin')
def def_service_endpoint():
    os.environ["OS_SERVICE_TOKEN"] = admin_token
    os.environ["OS_SERVICE_ENDPOINT"] = "http://controller:35357/v2.0"
    (status, output) = commands.getstatusoutput("keystone service-list")
    if status != 0:
       raise NameError(output)
    if(output.find("keystone") > 0):
        return
    common.command('keystone service-create --name=keystone --type=identity --description="OpenStack Identity"')
    common.command('keystone endpoint-create ' +  
                   "  --service-id=$(keystone service-list | awk '/ identity / {print $2}')  " + 
                   "  --publicurl=http://controller:5000/v2.0 " + 
                   "  --internalurl=http://controller:5000/v2.0 " + 
                   "  --adminurl=http://controller:35357/v2.0")
Esempio n. 4
0
def react(t, irc):
    command, message = common.command(common.type(t))
    args = message['args']
    sender = common.senderFormat(message['from'], "nick")
    if command == None:
        return False
    if command.lower() != "weather":
        return False
    if len(args) == 0:
        location = getSavedData(sender)
    else:
        location = " ".join(args)
        putSavedData(sender, location)
    if location == False:
        if message["to"].split("!")[0] != common.conf.read()["nick"]:
            common.say(
                message['to'],
                "Sorry, I don't know where you live. Try \"{0}weather <location>\""
                .format(common.conf.read()['commands']['commandPrefix']), irc)
        else:
            common.say(
                common.senderFormat(message["from"], "nick"),
                "Sorry, I don't know where you live. Try \"{0}weather <location>\""
                .format(common.conf.read()['commands']['commandPrefix']), irc)
    else:
        if message["to"].split("!")[0] != common.conf.read()["nick"]:
            common.say(message['to'], stringFromLocation(location), irc)
        else:
            common.say(common.senderFormat(message["from"], "nick"),
                       stringFromLocation(location), irc)
Esempio n. 5
0
def handle_followers_response(res):
    if "next_cursor" in res["result"] and res["result"]["next_cursor"] != 0:
        command(
            "get", "followers/ids", {
                "user_id": res["metadata"]["user_id"],
                "stringify_ids": True,
                "cursor": res["result"]["next_cursor"]
            }, "followers", res["metadata"])

    if "ids" not in res["result"]:
        return True

    for follower in res["result"]["ids"]:
        nest_level = res["metadata"]["nest_level"] + 1
        process_user(follower, res["metadata"]["user_id"],
                     res["metadata"]["top_level_followee"], nest_level,
                     nest_level >= int(sys.argv[1]))
    conn.commit()
    return True
Esempio n. 6
0
def react(input, irc):
    command, message = common.command(common.type(input))  # dict
    if command == None:
        return
    elif command == "":
        textReact(message, irc)
    elif command == "sr" or command == "simpleresponse":
        srEdit(message, irc)
    else:
        commandReact(command, message, irc)
    print "stopping \"simpleResponse\""
Esempio n. 7
0
def react(input,irc):
	command,message = common.command(common.type(input)) # dict
	if command == None:
		return
	elif command == "":
		textReact(message,irc)
	elif command == "sr" or command == "simpleresponse":
		srEdit(message,irc)
	else:
		commandReact(command,message,irc)
	print "stopping \"simpleResponse\""
def mysql_install(bind_addr):
  common.command('zypper -n install mysql-client mysql  python-mysql')
  common.ini_update('/etc/my.cnf', 'mysqld', 'bind-address', bind_addr)
  common.ini_update('/etc/my.cnf', 'mysqld', 'default-storage-engine', 'innodb')
  common.ini_update('/etc/my.cnf', 'mysqld', 'innodb_file_per_table', None)
  common.ini_update('/etc/my.cnf', 'mysqld', 'collation-server', 'utf8_general_ci')
  common.ini_update('/etc/my.cnf', 'mysqld', 'init-connect', "'SET NAMES utf8'")
  common.ini_update('/etc/my.cnf', 'mysqld', 'character-set-server', 'utf8')
 
  common.command('service mysql start')
  common.command('chkconfig mysql on') 

  common.command('mysql_install_db') 
  change_root_passwd() #instead mysql_secure_installation
Esempio n. 9
0
def process_user(uid,
                 follower_of=None,
                 top_level_followee=None,
                 nest_level=0,
                 no_followers=False):
    cur.execute(
        "insert into metadata (uid, follower_of, top_level_followee, nest_level) values (%s, %s, %s, %s) on conflict (uid) do update set nest_level = least(metadata.nest_level, excluded.nest_level)",
        (uid, follower_of, top_level_followee, nest_level))
    if follower_of:
        cur.execute(
            "insert into followers (follower_uid, folowee_uid) values (%s, %s) on conflict (follower_uid, folowee_uid) do nothing",
            (uid, follower_of))
    if aggregate("users", uid) >= 100:
        users = get_aggregate("users", 100)
        command("post", "users/lookup", {"user_id": ",".join(users)}, "users")
    if not no_followers:
        command("get", "followers/ids", {
            "user_id": uid,
            "stringify_ids": True
        }, "followers", {
            "user_id": uid,
            "top_level_followee": top_level_followee,
            "nest_level": nest_level
        })
    command(
        "get", "statuses/user_timeline", {
            "user_id": uid,
            "trim_user": True,
            "count": 200,
            "include_rts": True,
            "exclude_replies": False
        }, "tweets", {"user_id": uid})
Esempio n. 10
0
def react(t,irc):
    command,message = common.command(common.type(t))
    args = message['args']
    sender = common.senderFormat(message['from'],"nick")
    if command == None:
        return False
    if command.lower() != "weather":
        return False
    if len(args) == 0:
        location = getSavedData(sender)
    else:
        location = " ".join(args)
        putSavedData(sender,location)
    if location == False:
        if message["to"].split("!")[0] != common.conf.read()["nick"]:
            common.say(message['to'],"Sorry, I don't know where you live. Try \"{0}weather <location>\"".format(common.conf.read()['commands']['commandPrefix'])  ,  irc)
        else:
            common.say(common.senderFormat(message["from"],"nick"),"Sorry, I don't know where you live. Try \"{0}weather <location>\"".format(common.conf.read()['commands']['commandPrefix']),irc)
    else:
        if message["to"].split("!")[0] != common.conf.read()["nick"]:
            common.say(message['to'],stringFromLocation(location),irc)
        else:
            common.say(common.senderFormat(message["from"],"nick"),stringFromLocation(location),irc)
def cinder_block_install(vol_disk, my_ip):
   #1. vg create
   common.command('pvdisplay  | grep -q ' + vol_disk + ' || pvcreate '  + vol_disk)
   common.command('vgdisplay  | grep -q  cinder-volumes || vgcreate cinder-volumes ' + vol_disk)
   #4. package
   common.command('zypper -n install openstack-cinder-volume tgt')

   #5. configure cinder.conf
   common.command('openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone')
   common.command('openstack-config --set /etc/cinder/cinder.conf keystone_authtoken  auth_uri http://controller:5000')
   common.command('openstack-config --set /etc/cinder/cinder.conf keystone_authtoken  auth_host controller')
   common.command('openstack-config --set /etc/cinder/cinder.conf keystone_authtoken  auth_protocol http')
   common.command('openstack-config --set /etc/cinder/cinder.conf keystone_authtoken  auth_port 35357')
   common.command('openstack-config --set /etc/cinder/cinder.conf keystone_authtoken  admin_user cinder')
   common.command('openstack-config --set /etc/cinder/cinder.conf keystone_authtoken  admin_tenant_name service')
   common.command('openstack-config --set /etc/cinder/cinder.conf keystone_authtoken   admin_password CINDER_PASS')

   #6. rabbitmq
   common.command('openstack-config --set /etc/cinder/cinder.conf  DEFAULT rpc_backend rabbit')
   common.command('openstack-config --set /etc/cinder/cinder.conf  DEFAULT rabbit_host controller')
   common.command('openstack-config --set /etc/cinder/cinder.conf  DEFAULT rabbit_port 5672')
   common.command('openstack-config --set /etc/cinder/cinder.conf  DEFAULT rabbit_password guest')

   #7. db connection
   common.command('openstack-config --set /etc/cinder/cinder.conf   database connection mysql://cinder:CINDER_DBPASS@controller/cinder')

   #8. my ip
   MANAGEMENT_INTERFACE_IP_ADDRESS = my_ip
   common.command('openstack-config --set /etc/cinder/cinder.conf   DEFAULT my_ip ' + MANAGEMENT_INTERFACE_IP_ADDRESS)

   #9. use glance 
   common.command('openstack-config --set /etc/cinder/cinder.conf    DEFAULT glance_host controller')

   #10. use tgtadm iSCSI service
   common.command('openstack-config --set /etc/cinder/cinder.conf   DEFAULT iscsi_helper tgtadm')

   #+++
   common.command('mkdir -p /etc/tgt/conf.d/')
   common.command(" echo 'include /var/lib/cinder/volumes/ *' > /etc/tgt/conf.d/cinder.conf")
   common.command(" echo 'include /etc/tgt/conf.d/cinder.conf' >> /etc/tgt/targets.conf")
   common.command(" echo 'default-driver iscsi' >> /etc/tgt/targets.conf")
    
   #11. start service
   common.command('service openstack-cinder-volume start')
   common.command('service tgtd start')
   common.command('chkconfig openstack-cinder-volume on')
   common.command('chkconfig tgtd on')
parent_path = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(parent_path)

from common import conn, cur, get_response, ack_response, nack_response, get_raw, command, get_raw_nb

c = statsd.StatsClient('localhost', 8125, prefix='user_processor')

while True:
    logging.info("Waiting for requests in 'users_to_download' queue...")
    meta, screen_name = get_raw("users_to_download")
    with c.timer("valid_jobs"):
        logging.info("Got request for user=%s, requesting info from Twitter...", screen_name)

        params = { "screen_name": screen_name }
        q = command("get", "users/show", params, "user_details")
        meta_user, resp = get_response("user_details")
        twid = resp["result"]["id_str"]
        cur.execute("insert into users (twid, screen_name) values (%s, %s) returning id", (twid, screen_name))
        uid = cur.fetchone()[0]
        conn.commit()

        ack_response(meta_user)
        
        # start job for downloading user tweets
        params = { "user_id": twid, "count": 200, "trim_user": "******", "include_rts": "false" }
        metadata = { "user_id": uid, "params": params, "collected": 0, "hashtags": {} }
        command("get", "statuses/user_timeline", params, "user_tweets", metadata=metadata)

        # start job for downloading friends
        params = { "user_id": twid, "count": 5000, "stringify_ids": True }
Esempio n. 13
0
                uid = cur.fetchone()[0]
                params = {
                    "user_id": user_id,
                    "count": 200,
                    "trim_user": "******",
                    "include_rts": "false"
                }
                metadata = {
                    "params": params,
                    "collected": 0,
                    "hashtags": {},
                    "user_id": uid
                }
                command("get",
                        "statuses/user_timeline",
                        params,
                        "user_tweets",
                        metadata=metadata)

                if resp["metadata"]["parent_level"] <= 1:
                    params = {
                        "user_id": user_id,
                        "count": 5000,
                        "stringify_ids": True
                    }
                    metadata = {
                        "params": params,
                        "parent": user_id,
                        "parent_level": resp["metadata"]["parent_level"] + 1
                    }
                    command("get",
def neutron_compute_install():
    #1.1 
    common.command('cp /local/scratch/shared/installation_script/lib/conf/sysctl.conf  /etc/sysctl.conf')
    common.command('sysctl -p')
    #2 pakcage
    common.command('zypper -n  install openstack-neutron-openvswitch-agent')
    #3.1 nutron  common
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT   auth_strategy keystone')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  auth_uri http://controller:5000')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  auth_host controller')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  auth_protocol http')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  auth_port 35357')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  admin_tenant_name service')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  admin_user neutron')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  admin_password NEUTRON_PASS')

    #3.1 rabbit
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT  rpc_backend neutron.openstack.common.rpc.impl_kombu')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT   rabbit_host controller')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT  rabbit_userid guest')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT  rabbit_password guest')
 
    #3.3 ML2
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT  core_plugin neutron.plugins.ml2.plugin.Ml2Plugin')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT  service_plugins neutron.services.l3_router.l3_router_plugin.L3RouterPlugin')

    #4 congiure ML2 to use ovs ang gre
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers gre')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2  tenant_network_types gre')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2  mechanism_drivers openvswitch')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_gre   tunnel_id_ranges 1:1000')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ovs   local_ip 10.0.0.31')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ovs  tunnel_type gre')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ovs   enable_tunneling True')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup ' + 
                      ' firewall_driver neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver' )
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup   enable_security_group True')

    #5.  congireu ovs
    common.command('service openvswitch-switch start')
    common.command('chkconfig openvswitch-switch on')
    common.command('ovs-vsctl --may-exist add-br br-int')

    #7. finalize installation
    """
    /etc/sysconfig/neutron 
    NEUTRON_PLUGIN_CONF="/etc/neutron/plugins/ml2/ml2_conf.ini"
    """
    common.command('service openstack-neutron-openvswitch-agent start')
    common.command('chkconfig openstack-neutron-openvswitch-agent on')
def dashboar_install():
    #1.install package
    common.command('zypper -n install memcached python-python-memcached apache2-mod_wsgi openstack-dashboard openstack-dashboard-test')
Esempio n. 16
0
def heat_install():
    #1.install package
    common.command('zypper -n install openstack-heat-api openstack-heat-api-cfn openstack-heat-engine')
    #2.db interface 
    common.command('openstack-config --set /etc/heat/heat.conf database connection mysql://heat:HEAT_DBPASS@controller/heat')
    
    #3.create db 
    mysql_cfg.add_database("controller", 'heat', 'heat', 'HEAT_DBPASS')

    #4.use rabbitmq
    common.command("openstack-config --set /etc/heat/heat.conf DEFAULT rabbit_host controller")
    common.command("openstack-config --set /etc/heat/heat.conf DEFAULT rabbit_password guest")

    
    #5. add keystone user 
    keystone_cfg.user_add_or_update('heat', 'HEAT_PASS')
    keystone_cfg.user_role_add_or_update('heat', 'service', 'admin')
    #6. configure heat.conf
    common.command('openstack-config --set /etc/heat/heat.conf keystone_authtoken auth_host controller')
    common.command('openstack-config --set /etc/heat/heat.conf keystone_authtoken auth_port  35357')
    common.command('openstack-config --set /etc/heat/heat.conf keystone_authtoken auth_protocol  http')
    common.command('openstack-config --set /etc/heat/heat.conf keystone_authtoken auth_uri  http://controller:5000/v2.0')
    common.command('openstack-config --set /etc/heat/heat.conf keystone_authtoken admin_tenant_name  service')
    common.command('openstack-config --set /etc/heat/heat.conf keystone_authtoken admin_user  heat')
    common.command('openstack-config --set /etc/heat/heat.conf keystone_authtoken admin_password  HEAT_PASS')

    common.command('openstack-config --set /etc/heat/heat.conf ec2authtoken auth_uri  http://controller:5000/v2.0')
   
 
    #7.rgister service end endpoint 
    keystone_cfg.service_create("heat", "orchestration", "Orchestration")
  
    keystone_cfg.endpoint_create_or_update("heat",  "http://controller:8004/v1/%\(tenant_id\)s",
                                                    "http://controller:8004/v1/%\(tenant_id\)s",
                                                    "http://controller:8004/v1/%\(tenant_id\)s")



    keystone_cfg.service_create("heat-cfn", "cloudformation", "Orchestration CloudFormation")
    keystone_cfg.endpoint_create_or_update("heat-cfn", "http://controller:8000/v1",
                                                       "http://controller:8000/v1", 
                                                       "http://controller:8000/v1")


    #8.create role heat_stack_user
    keystone_cfg.role_create("heat_stack_user")
    #9.metadate and waitcondition server
    common.command("openstack-config --set /etc/heat/heat.conf DEFAULT heat_metadata_server_url http://10.0.0.11:8000")
    common.command("openstack-config --set /etc/heat/heat.conf DEFAULT heat_waitcondition_server_url http://10.0.0.11:8000/v1/waitcondition")

    #10. start server
    common.command("service openstack-heat-api start")
    common.command("service openstack-heat-api-cfn start")
    common.command("service openstack-heat-engine start")
    common.command("chkconfig openstack-heat-api on")
    common.command("chkconfig openstack-heat-api-cfn on")
    common.command("chkconfig openstack-heat-engine on")
Esempio n. 17
0
def nova_controller_install(mysql_host):
    #1.install package
    common.command("zypper -n install openstack-nova-api " +
                                     "openstack-nova-scheduler " +
                                     "openstack-nova-cert " + 
                                     "openstack-nova-conductor " +
                                     "openstack-nova-console " + 
                                     "openstack-nova-consoleauth " + 
                                     "openstack-nova-novncproxy " + 
                                     "python-novaclient")
    #2. config db interface
    common.command('openstack-config --set /etc/nova/nova.conf ' + 
                   'database connection mysql://nova:NOVA_DBPASS@%s/nova'%(mysql_host))
 
    #3. use rabbitmq
    common.command('openstack-config --set /etc/nova/nova.conf ' + 
                   'DEFAULT rpc_backend nova.rpc.impl_kombu')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT rabbit_host controller')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT rabbit_password guest')

    #4. set the listen ip, also vnc
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT my_ip 10.0.0.11')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT vncserver_listen 10.0.0.11')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT vncserver_proxyclient_address 10.0.0.11')

    #5. add db
    mysql_cfg.add_database(mysql_host,'nova', 'nova', 'NOVA_DBPASS')
    
    #6. add keystone user
    keystone_cfg.user_add_or_update('nova', 'NOVA_PASS')
    keystone_cfg.user_role_add_or_update('nova', 'service', 'admin')

    #7. config to use keystone authtoken
    common.command(' openstack-config --set /etc/nova/nova.conf DEFAULT auth_strategy keystone')
    common.command(' openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_uri http://controller:5000')
    common.command(' openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_host controller')
    common.command(' openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_protocol http')
    common.command(' openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_port 35357')
    common.command(' openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_user nova')
    common.command(' openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_tenant_name service')
    common.command(' openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_password NOVA_PASS')

    #8 create keystone service and endpoint
    keystone_cfg.service_create("nova", "compute", "OpenStack Compute")
    keystone_cfg.endpoint_create_or_update( "nova",
                   "http://controller:8774/v2/%\(tenant_id\)s  ",
                   "http://controller:8774/v2/%\(tenant_id\)s " ,
                   "http://controller:8774/v2/%\(tenant_id\)s ")

    #9 start service 
    common.command(' service openstack-nova-api start')
    common.command(' service openstack-nova-cert start')
    common.command(' service openstack-nova-consoleauth start')
    common.command(' service openstack-nova-scheduler start')
    common.command(' service openstack-nova-conductor start')
    common.command(' service openstack-nova-novncproxy start')
    common.command(' chkconfig openstack-nova-api on')
    common.command(' chkconfig openstack-nova-cert on')
    common.command(' chkconfig openstack-nova-consoleauth on')
    common.command(' chkconfig openstack-nova-scheduler on')
    common.command(' chkconfig openstack-nova-conductor on')
    common.command(' chkconfig openstack-nova-novncproxy on')
Esempio n. 18
0
def nova_computer_install(mysql_host, glance_host, keystone_host, rabbit_host, bind_ip):
    #1 package
    common.command('zypper -n install openstack-nova-compute kvm openstack-utils')
   
    #2. config db  and use keystone auth 
    common.command(' openstack-config --set /etc/nova/nova.conf database connection mysql://nova:NOVA_DBPASS@%s/nova'%(mysql_host))
    common.command(' openstack-config --set /etc/nova/nova.conf DEFAULT auth_strategy keystone')
    common.command(' openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_uri http://%s:5000'%(keystone_host))
    common.command(' openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_host %s'%(keystone_host))
    common.command(' openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_protocol http')
    common.command(' openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_port 35357')
    common.command(' openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_user nova')
    common.command(' openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_tenant_name service')
    common.command(' openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_password NOVA_PASS')

    #3. to use rabbitmq
    common.command(' openstack-config --set /etc/nova/nova.conf  DEFAULT rpc_backend nova.rpc.impl_kombu')
    common.command(' openstack-config --set /etc/nova/nova.conf DEFAULT rabbit_host %s'%(rabbit_host))
    common.command(' openstack-config --set /etc/nova/nova.conf DEFAULT rabbit_password guest ')

    #4. bind ip, to provide remote console
    common.command(' openstack-config --set /etc/nova/nova.conf DEFAULT my_ip %s'%(bind_ip))
    common.command(' openstack-config --set /etc/nova/nova.conf DEFAULT vnc_enabled True')
    common.command(' openstack-config --set /etc/nova/nova.conf DEFAULT vncserver_listen 0.0.0.0')
    common.command(' openstack-config --set /etc/nova/nova.conf DEFAULT vncserver_proxyclient_address %s'%(bind_ip))
    common.command(' openstack-config --set /etc/nova/nova.conf DEFAULT novncproxy_base_url http://controller:6080/vnc_auto.html')

    #5. the host of image service
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT glance_host %s'%(glance_host))

    #6.hypervisor type
    (status, output) = commands.getstatusoutput("egrep  -c '(vmx|svm)' /proc/cpuinfo")  
    if status != 0:
       raise NameError(output)
    virt_type = "kvm"
    if output == "0" :
        virt_type = "qemu"
    common.command('openstack-config --set /etc/nova/nova.conf libvirt virt_type ' + virt_type)

    #+++ congiure use neutron
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  network_api_class nova.network.neutronv2.api.API')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  neutron_url http://controller:9696')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  neutron_auth_strategy keystone')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  neutron_admin_tenant_name service')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  neutron_admin_username neutron')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  neutron_admin_password NEUTRON_PASS')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  neutron_admin_auth_url http://controller:35357/v2.0')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT ' +
                      '  linuxnet_interface_driver nova.network.linux_net.LinuxOVSInterfaceDriver')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT ' + 
                     'firewall_driver nova.virt.firewall.NoopFirewallDriver')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT   security_group_api neutron')
  

    #7 start service
    common.command(' service libvirtd start')
    common.command(' service openstack-nova-compute start')
    common.command(' chkconfig libvirtd on')
    common.command(' chkconfig openstack-nova-compute on')
def rabbit_install():
  #4. install rabbitmq server,  with user and password guest/guest
  common.command('zypper -n install rabbitmq-server')
  common.command('service rabbitmq-server start')
  common.command('rabbitmqctl change_password guest guest ')
  common.command('chkconfig rabbitmq-server on')
def cinder_controller_install(mysql_host):
   #1.packge 
   common.command('zypper -n  install  openstack-cinder-api openstack-cinder-scheduler')
  
   #2, db interface
   common.command('openstack-config --set /etc/cinder/cinder.conf  database connection mysql://cinder:CINDER_DBPASS@%s/cinder'%(mysql_host))

   #3. create db
   mysql_cfg.add_database(mysql_host,'cinder', 'cinder', 'CINDER_DBPASS')
   
   #4. keystone user
   keystone_cfg.user_add_or_update('cinder', 'CINDER_PASS')
   keystone_cfg.user_role_add_or_update('cinder', 'service', 'admin')
   

   #5.cinder.conf 
   common.command('openstack-config --set /etc/cinder/cinder.conf DEFAULT  auth_strategy keystone')
   common.command('openstack-config --set /etc/cinder/cinder.conf keystone_authtoken  auth_uri http://controller:5000')
   common.command('openstack-config --set /etc/cinder/cinder.conf keystone_authtoken  auth_host controller')
   common.command('openstack-config --set /etc/cinder/cinder.conf keystone_authtoken  auth_protocol http')
   common.command('openstack-config --set /etc/cinder/cinder.conf keystone_authtoken  auth_port 35357')
   common.command('openstack-config --set /etc/cinder/cinder.conf keystone_authtoken  admin_user cinder')
   common.command('openstack-config --set /etc/cinder/cinder.conf keystone_authtoken  admin_tenant_name service')
   common.command('openstack-config --set /etc/cinder/cinder.conf keystone_authtoken  admin_password CINDER_PASS')

   #6. use rabbitmq
   common.command('openstack-config --set /etc/cinder/cinder.conf  DEFAULT rpc_backend rabbit')
   common.command('openstack-config --set /etc/cinder/cinder.conf  DEFAULT rabbit_host controller')
   common.command('openstack-config --set /etc/cinder/cinder.conf  DEFAULT rabbit_port 5672')
   common.command('openstack-config --set /etc/cinder/cinder.conf  DEFAULT rabbit_password guest')

   #7. keystone service and endpoint
   keystone_cfg.service_create('cinder', 'volume', "OpenStack Block Storage")
   keystone_cfg.endpoint_create_or_update('cinder', 'http://controller:8776/v1/%\(tenant_id\)s', 
                                                    'http://controller:8776/v1/%\(tenant_id\)s',
                                                    'http://controller:8776/v1/%\(tenant_id\)s')

   #7. keystone service and endpoint  v2
   keystone_cfg.service_create('cinderv2', 'volumev2', "OpenStack Block Storage")
   keystone_cfg.endpoint_create_or_update('cinderv2', 'http://controller:8776/v2/%\(tenant_id\)s', 
                                                    'http://controller:8776/v2/%\(tenant_id\)s',
                                                    'http://controller:8776/v2/%\(tenant_id\)s')

   common.command('service openstack-cinder-api start')
   common.command('service openstack-cinder-scheduler start')
   common.command('chkconfig openstack-cinder-api on')
   common.command('chkconfig openstack-cinder-scheduler on')
def neutron_network_install():
    #1. config sysctl.conf
    common.command('cp /local/scratch/shared/openstack_script/installation/lib/conf/sysctl.conf  /etc/sysctl.conf')
    common.command('sysctl -p')
    #2. package
    common.command('zypper -n install openstack-neutron-openvswitch-agent openstack-neutron-l3-agent openstack-neutron-dhcp-agent openstack-neutron-metadata-agent')

    #configure nuetorn common compontens
    #3.1 use keyston auth
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT  auth_strategy keystone')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  auth_uri http://controller:5000')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  auth_host controller')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  auth_protocol http')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  auth_port 35357')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  admin_tenant_name service')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  admin_user neutron')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  admin_password NEUTRON_PASS')

    #3.2 use rabbitmq
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT  rpc_backend neutron.openstack.common.rpc.impl_kombu ')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT  rabbit_host controller')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT  rabbit_userid guest')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT  rabbit_password guest')

    #3.3 use ML2
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT  core_plugin neutron.plugins.ml2.plugin.Ml2Plugin')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT  service_plugins neutron.services.l3_router.l3_router_plugin.L3RouterPlugin')

    #4 Configure L3 agent
    common.command('openstack-config --set /etc/neutron/l3_agent.ini DEFAULT  interface_driver neutron.agent.linux.interface.OVSInterfaceDriver')
    common.command('openstack-config --set /etc/neutron/l3_agent.ini DEFAULT  use_namespaces True')


    #5.1 DHCP agent
    common.command('openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT interface_driver neutron.agent.linux.interface.OVSInterfaceDriver')
    common.command('openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT dhcp_driver neutron.agent.linux.dhcp.Dnsmasq')
    common.command('openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT use_namespaces True')
    #5.2 
    common.command('openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT  dnsmasq_config_file /etc/neutron/dnsmasq-neutron.conf')
 
    common.command('echo "dhcp-option-force=26,1454" > /etc/neutron/dnsmasq-neutron.conf')
    commands.getstatusoutput('killall dnsmasq')

    #5. Metadata agenet
    common.command('openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT auth_url http://controller:5000/v2.0')
    common.command('openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT auth_region regionOne')
    common.command('openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT admin_tenant_name service')
    common.command('openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT admin_user neutron')
    common.command('openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT admin_password NEUTRON_PASS')
    common.command('openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT nova_metadata_ip controller')
    common.command('openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT metadata_proxy_shared_secret ' + METADATA_SECRET)

    #6. Config ML2
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2  type_drivers gre')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2  tenant_network_types gre')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2  mechanism_drivers openvswitch')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_gre  tunnel_id_ranges 1:1000')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ovs  local_ip 10.0.1.21')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ovs   tunnel_type gre')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ovs   enable_tunneling True')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup ' + 
                     " firewall_driver neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver")
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup   enable_security_group True')


    #7. config OVS
    common.command('service openvswitch-switch start')
    common.command('chkconfig openvswitch-switch on')
    common.command('ovs-vsctl --may-exist add-br br-int')
    common.command('ovs-vsctl --may-exist add-br br-ex')
    common.command('ovs-vsctl --may-exist  add-port br-ex eth2')
    common.command('ethtool -K eth2 gro off')


    #8.finalize the installation
    """
    /etc/sysconfig/neutron 
    NEUTRON_PLUGIN_CONF="/etc/neutron/plugins/ml2/ml2_conf.ini"
    """
    common.command('service openstack-neutron-openvswitch-agent start')
    common.command('service openstack-neutron-l3-agent start')
    common.command('service openstack-neutron-dhcp-agent start')
    common.command('service openstack-neutron-metadata-agent start')
    common.command('chkconfig openstack-neutron-openvswitch-agent on')
    common.command('chkconfig openstack-neutron-l3-agent on')
    common.command('chkconfig openstack-neutron-dhcp-agent on')
    common.command('chkconfig openstack-neutron-metadata-agent on')
def glance_install():
    common.command('zypper -n install openstack-glance python-glanceclient')
    common.command('openstack-config --set /etc/glance/glance-api.conf database  connection mysql://glance:GLANCE_DBPASS@controller/glance')
    common.command('openstack-config --set /etc/glance/glance-registry.conf database  connection mysql://glance:GLANCE_DBPASS@controller/glance')
    mysql_init.add_database('glance', 'glance', 'GLANCE_DBPASS')
def neutron_controller_install(mysql_host):
    #1. create db
    mysql_cfg.add_database(mysql_host,'neutron', 'neutron', 'NEUTRON_DBPASS')
    #2. create keysteon user ..
    keystone_cfg.user_add_or_update('neutron', 'NEUTRON_PASS')
    keystone_cfg.user_role_add_or_update('neutron', 'service', 'admin')
    keystone_cfg.service_create('neutron', 'network', "OpenStack Networking")  
    keystone_cfg.endpoint_create_or_update('neutron',
                   "http://*****:*****@%s/neutron '%(mysql_host))
   
    #4.2 use keystone auth 
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  auth_uri http://controller:5000')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  auth_host controller')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  auth_protocol http')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  auth_port 35357')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  admin_tenant_name service')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  admin_user neutron')
    common.command('openstack-config --set /etc/neutron/neutron.conf keystone_authtoken  admin_password NEUTRON_PASS')

    #4.3 use rabbitmq
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT   rpc_backend neutron.openstack.common.rpc.impl_kombu')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT   rabbit_host controller')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT   rabbit_userid guest')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT   rabbit_password guest')

    #4.4 nova api interface, so neutron can notify nova about network topoloy changes
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT   notify_nova_on_port_status_changes True')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT   notify_nova_on_port_data_changes True')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT   nova_url http://controller:8774/v2')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT   nova_admin_username nova')
    common.command("openstack-config --set /etc/neutron/neutron.conf DEFAULT   nova_admin_tenant_id $(source /local/scratch/shared/installation_script/lib/admin-openrc.sh && keystone tenant-list | awk '/ service / { print $2 }')")
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT   nova_admin_password NOVA_PASS')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT   nova_admin_auth_url http://controller:35357/v2.0')


    #4.5 use ML2
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT   core_plugin neutron.plugins.ml2.plugin.Ml2Plugin')
    common.command('openstack-config --set /etc/neutron/neutron.conf DEFAULT   service_plugins neutron.services.l3_router.l3_router_plugin.L3RouterPlugin')

    
    #5  configure ML2 plugin
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2   type_drivers gre')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2   tenant_network_types gre')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2   mechanism_drivers openvswitch')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_gre   tunnel_id_ranges 1:1000')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup  firewall_driver neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver')
    common.command('openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup   enable_security_group True')


    #6 configure nova to use neutron
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  network_api_class nova.network.neutronv2.api.API')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  neutron_url http://controller:9696')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  neutron_auth_strategy keystone')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  neutron_admin_tenant_name service')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  neutron_admin_username neutron')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  neutron_admin_password NEUTRON_PASS')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  neutron_admin_auth_url http://controller:35357/v2.0')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  linuxnet_interface_driver nova.network.linux_net.LinuxOVSInterfaceDriver')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  firewall_driver nova.virt.firewall.NoopFirewallDriver')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  security_group_api neutron')



    #++ configure the  metadat secret
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  service_neutron_metadata_proxy true')
    common.command('openstack-config --set /etc/nova/nova.conf DEFAULT  neutron_metadata_proxy_shared_secret ' +  METADATA_SECRET)

    #7. finialize installation
    """
    /etc/sysconfig/neutron 
    NEUTRON_PLUGIN_CONF="/etc/neutron/plugins/ml2/ml2_conf.ini"
    """

    common.command('service openstack-nova-api restart')
    common.command('service openstack-nova-scheduler restart')
    common.command('service openstack-nova-conductor restart')


    common.command('service openstack-neutron start')
    common.command('chkconfig openstack-neutron on')
def keystone_install():
  #5. install identity service (keystone)
  common.command('zypper -n install  openstack-keystone python-keystoneclient openstack-utils')
  common.command('openstack-config --set /etc/keystone/keystone.conf ' +  
                 ' database connection mysql://keystone:KEYSTONE_DBPASS@controller/keystone')
  mysql_init.add_database("keystone", "keystone", "KEYSTONE_DBPASS")
  #(status, output) = commands.getstatusoutput("openssl rand 10|hexdump  -e '1/1 " + '"%.2x"' + "'")
  #if status != 0:
  #  raise NameError("openssl rand failed")
  common.command('openstack-config --set /etc/keystone/keystone.conf DEFAULT admin_token ' + admin_token)
  common.command('keystone-manage pki_setup --keystone-user keystone --keystone-group keystone')
  common.command('chown -R keystone:keystone /etc/keystone/ssl')
  common.command('chmod -R o-rwx /etc/keystone/ssl')
  common.command('service openstack-keystone restart')
  common.command('chkconfig openstack-keystone on')
  common.command('bash -c ' + '"' +  "(crontab -l -u keystone 2>&1 | grep -q token_flush) || " +  
                              "echo '@hourly /usr/bin/keystone-manage token_flush >/var/log/keystone/keystone-tokenflush.log 2>&1' " + 
                              " >> /var/spool/cron/tabs/keystone"  + '"' )
def glance_install(mysql_host):
    #1.install package
    common.command('zypper -n install openstack-glance python-glanceclient')
    #2 config db 
    mysql_cfg.add_database(mysql_host, 'glance', 'glance', 'GLANCE_DBPASS')
    
    conn = "mysql://*****:*****@%s/glance"%('GLANCE_DBPASS',mysql_host)
    common.command('openstack-config --set /etc/glance/glance-api.conf database  connection ' + conn)
    common.command('openstack-config --set /etc/glance/glance-registry.conf database  connection ' + conn)
    #3. add keystone user 
    keystone_cfg.user_add_or_update('glance', 'GLANCE_PASS')
    keystone_cfg.user_role_add_or_update('glance', 'service', 'admin')
    #4. add 
    common.command(" openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  auth_uri http://controller:5000" )
    common.command(" openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  auth_host controller")
    common.command(" openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  auth_port 35357")
    common.command(" openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  auth_protocol http")
    common.command(" openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  admin_tenant_name service")
    common.command(" openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  admin_user glance")
    common.command(" openstack-config --set /etc/glance/glance-api.conf keystone_authtoken  admin_password GLANCE_PASS")
    common.command(" openstack-config --set /etc/glance/glance-api.conf paste_deploy    flavor keystone")
    common.command(" openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken  auth_uri http://controller:5000")
    common.command(" openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken   auth_host controller")
    common.command(" openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken   auth_port 35357")
    common.command(" openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken  " +
                  "  auth_protocol http")
    common.command(" openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken  " +
                   "  admin_tenant_name service")
    common.command(" openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken  " +
                   "  admin_user glance")
    common.command(" openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken  " +
                   "  admin_password GLANCE_PASS")
    common.command(" openstack-config --set /etc/glance/glance-registry.conf paste_deploy  " +
                   "  flavor keystone")

  
    keystone_cfg.service_create("glance", "image", "OpenStack Image Service")
  
    keystone_cfg.endpoint_create_or_update("glance", "http://controller:9292", "http://controller:9292", "http://controller:9292")


    common.command(" service openstack-glance-api restart")
    common.command(" service openstack-glance-registry restart")
    common.command(" chkconfig openstack-glance-api on")
    common.command(" chkconfig openstack-glance-registry on")
Esempio n. 26
0
                        tweets_with_both = hashtags_relations.tweets_with_both + %(c)s
                """, {
                        "h1": h1,
                        "h2": h2,
                        "c": count
                    })

        logging.info("Processed %s (+%s) tweets for uid %s" %
                     (metadata["collected"], len(resp["result"]) - 1, log_id))

        if len(resp["result"]) > 1:
            params = {"max_id": metadata["max_id"]}
            params.update(metadata["params"])
            command("get",
                    "statuses/user_timeline",
                    params,
                    "user_tweets",
                    metadata=metadata)
            logging.info("Requesting next page of tweets for uid %s", log_id)
        else:
            for h, c in metadata["hashtags"].items():
                cur.execute(
                    "insert into user_hashtags (uid, hashtag, number_of_tweets) values (%s, %s, %s) on conflict do nothing",
                    (metadata["user_id"], h, c))
            cur.execute("update users set finished_tweets = 't' where id = %s",
                        (metadata["user_id"], ))
            logging.info("Finished fetching tweets for uid %s", log_id)

        with c.timer("pgcommit"):
            conn.commit()
        ack_response(meta)