コード例 #1
0
ファイル: fabfile.py プロジェクト: cloudsecninja1975/orizuru
def stage7_container_midonet_api():
    metadata = Config(os.environ["CONFIGFILE"])

    if cuisine.file_exists("/tmp/.%s.lck" % sys._getframe().f_code.co_name):
        return

    zk = []

    for zkhost in sorted(metadata.roles['container_zookeeper']):
        zk.append("{'ip' => '%s', 'port' => '2181'}" % metadata.containers[zkhost]['ip'])

    args = {}

    args['zk_servers'] = "[%s]" % ",".join(zk)
    args['keystone_auth'] = "true"
    args['vtep'] = "true"

    #
    # slice and dice the password cache so we can access it in python
    #
    passwords = {}
    with open(os.environ["PASSWORDCACHE"]) as passwordcache:
        for line in passwordcache:
            name, var = line.partition("=")[::2]
            passwords[name] = str(var).rstrip('\n')

    #
    # this is supposed to be the outer ip, not the container ip, remember HATEOAS
    #
    args['api_ip'] = "'%s'" % metadata.servers[metadata.roles["midonet_api"][0]]["ip"]
    args['api_port'] = "'8081'"

    args['keystone_host'] = "'%s'" % metadata.containers[metadata.roles["container_openstack_keystone"][0]]["ip"]
    args['keystone_port'] = "'35357'"
    args['keystone_admin_token'] = "'%s'" % passwords["export ADMIN_TOKEN"]
    args['keystone_tenant_name'] = "'admin'"

    Puppet.apply('midonet::midonet_api', args, metadata)

    #
    # in case mock auth was installed:
    #
    run("""

sed -i 's,org.midonet.api.auth.MockAuthService,org.midonet.cluster.auth.MockAuthService,g;' /usr/share/midonet-api/WEB-INF/web.xml

""")

    #
    # wait for the api to come up
    #
    puts(green("please wait for midonet-api to come up, this can take a long time!"))
    run("""

wget -SO- -- http://%s:8081/midonet-api/; echo

""" % metadata.servers[metadata.roles["midonet_api"][0]]["ip"])

    cuisine.file_write("/tmp/.%s.lck" % sys._getframe().f_code.co_name, "xoxo")
コード例 #2
0
ファイル: fabfile.py プロジェクト: BinhLPhan/orizuru
def stage7_install_midonet_agent():
    metadata = Config(os.environ["CONFIGFILE"])

    if cuisine.file_exists("/tmp/.%s.lck" % sys._getframe().f_code.co_name):
        return

    puts(green("installing MidoNet agent on %s" % env.host_string))

    zk = []

    zkc = []

    for zkhost in sorted(metadata.roles['container_zookeeper']):
        zk.append("{'ip' => '%s', 'port' => '2181'}" %
                  metadata.containers[zkhost]['ip'])
        zkc.append("%s:2181" % metadata.containers[zkhost]['ip'])

    cs = []

    csc = []

    for cshost in sorted(metadata.roles['container_cassandra']):
        cs.append("'%s'" % metadata.containers[cshost]['ip'])
        csc.append("%s" % metadata.containers[cshost]['ip'])

    args = {}

    args['zk_servers'] = "[%s]" % ",".join(zk)
    args['cassandra_seeds'] = "[%s]" % ",".join(cs)

    Puppet.apply('midonet::midonet_agent', args, metadata)

    #
    # the midolman.conf that comes with the puppet module is hopelessly broken, we replace it here
    #
    run("""

ZK="%s"
CS="%s"
CS_COUNT="%s"

cat >/etc/midolman/midolman.conf<<EOF

[zookeeper]
zookeeper_hosts = ${ZK}
session_timeout = 30000
midolman_root_key = /midonet/v1
session_gracetime = 30000

[cassandra]
servers = ${CS}
replication_factor = ${CS_COUNT}
cluster = midonet
EOF

""" % (",".join(zkc), ",".join(csc), len(csc)))

    cuisine.file_write("/tmp/.%s.lck" % sys._getframe().f_code.co_name, "xoxo")
コード例 #3
0
ファイル: fabfile.py プロジェクト: BinhLPhan/orizuru
def stage7_container_zookeeper():
    metadata = Config(os.environ["CONFIGFILE"])

    if cuisine.file_exists("/tmp/.%s.lck" % sys._getframe().f_code.co_name):
        return

    puts(green("installing zookeeper on %s" % env.host_string))

    zk = []

    zkid = 1
    myid = 1

    for zkhost in sorted(metadata.roles["container_zookeeper"]):
        zk.append("{'id' => '%s', 'host' => '%s'}" %
                  (zkid, metadata.containers[zkhost]['ip']))

        if env.host_string == zkhost:
            # then this is our id
            myid = zkid

        zkid = zkid + 1

    args = {}

    args['servers'] = "[%s]" % ",".join(zk)
    args['server_id'] = "%s" % myid

    Puppet.apply('midonet::zookeeper', args, metadata)

    run("service zookeeper stop; service zookeeper start")

    Daemon.poll('org.apache.zookeeper.server.quorum', 600)

    for zkhost in sorted(metadata.roles['container_zookeeper']):
        run("""
IP="%s"

echo ruok | nc "${IP}" 2181 | grep imok

""" % metadata.containers[zkhost]['ip'])

    #
    # TODO status check for 'not serving requests'
    #

    cuisine.file_write("/tmp/.%s.lck" % sys._getframe().f_code.co_name, "xoxo")
コード例 #4
0
ファイル: fabfile.py プロジェクト: cloudsecninja1975/orizuru
def stage7_container_zookeeper():
    metadata = Config(os.environ["CONFIGFILE"])

    if cuisine.file_exists("/tmp/.%s.lck" % sys._getframe().f_code.co_name):
        return

    puts(green("installing zookeeper on %s" % env.host_string))

    zk = []

    zkid = 1
    myid = 1

    for zkhost in sorted(metadata.roles["container_zookeeper"]):
        zk.append("{'id' => '%s', 'host' => '%s'}" % (zkid, metadata.containers[zkhost]['ip']))

        if env.host_string == zkhost:
            # then this is our id
            myid = zkid

        zkid = zkid + 1

    args = {}

    args['servers'] = "[%s]" % ",".join(zk)
    args['server_id'] = "%s" % myid

    Puppet.apply('midonet::zookeeper', args, metadata)

    run("service zookeeper stop; service zookeeper start")

    Daemon.poll('org.apache.zookeeper.server.quorum', 600)

    for zkhost in sorted(metadata.roles['container_zookeeper']):
        run("""
IP="%s"

echo ruok | nc "${IP}" 2181 | grep imok

""" % metadata.containers[zkhost]['ip'])

    #
    # TODO status check for 'not serving requests'
    #

    cuisine.file_write("/tmp/.%s.lck" % sys._getframe().f_code.co_name, "xoxo")
コード例 #5
0
ファイル: fabfile.py プロジェクト: cloudsecninja1975/orizuru
def stage7_container_cassandra():
    metadata = Config(os.environ["CONFIGFILE"])

    if cuisine.file_exists("/tmp/.%s.lck" % sys._getframe().f_code.co_name):
        return

    puts(green("installing cassandra on %s" % env.host_string))

    cs = []

    for cshost in metadata.roles['container_cassandra']:
        cs.append("'%s'" % metadata.containers[cshost]['ip'])

    args = {}

    args['seeds'] = "[%s]" % ",".join(cs)
    args['seed_address'] = "'%s'" % metadata.containers[env.host_string]['ip']

    Puppet.apply('midonet::cassandra', args, metadata)

    Daemon.poll('org.apache.cassandra.service.CassandraDaemon', 600)

    cuisine.file_write("/tmp/.%s.lck" % sys._getframe().f_code.co_name, "xoxo")
コード例 #6
0
ファイル: fabfile.py プロジェクト: BinhLPhan/orizuru
def stage7_container_cassandra():
    metadata = Config(os.environ["CONFIGFILE"])

    if cuisine.file_exists("/tmp/.%s.lck" % sys._getframe().f_code.co_name):
        return

    puts(green("installing cassandra on %s" % env.host_string))

    cs = []

    for cshost in metadata.roles['container_cassandra']:
        cs.append("'%s'" % metadata.containers[cshost]['ip'])

    args = {}

    args['seeds'] = "[%s]" % ",".join(cs)
    args['seed_address'] = "'%s'" % metadata.containers[env.host_string]['ip']

    Puppet.apply('midonet::cassandra', args, metadata)

    Daemon.poll('org.apache.cassandra.service.CassandraDaemon', 600)

    cuisine.file_write("/tmp/.%s.lck" % sys._getframe().f_code.co_name, "xoxo")
コード例 #7
0
ファイル: fabfile.py プロジェクト: cloudsecninja1975/orizuru
def stage7_install_midonet_agent():
    metadata = Config(os.environ["CONFIGFILE"])

    if cuisine.file_exists("/tmp/.%s.lck" % sys._getframe().f_code.co_name):
        return

    puts(green("installing MidoNet agent on %s" % env.host_string))

    zk = []

    zkc = []

    for zkhost in sorted(metadata.roles['container_zookeeper']):
        zk.append("{'ip' => '%s', 'port' => '2181'}" % metadata.containers[zkhost]['ip'])
        zkc.append("%s:2181" % metadata.containers[zkhost]['ip'])

    cs = []

    csc = []

    for cshost in sorted(metadata.roles['container_cassandra']):
        cs.append("'%s'" % metadata.containers[cshost]['ip'])
        csc.append("%s" % metadata.containers[cshost]['ip'])

    args = {}

    args['zk_servers'] = "[%s]" % ",".join(zk)
    args['cassandra_seeds'] = "[%s]" % ",".join(cs)

    Puppet.apply('midonet::midonet_agent', args, metadata)

    #
    # the midolman.conf that comes with the puppet module is hopelessly broken, we replace it here
    #
    run("""

ZK="%s"
CS="%s"
CS_COUNT="%s"

cat >/etc/midolman/midolman.conf<<EOF

[zookeeper]
zookeeper_hosts = ${ZK}
session_timeout = 30000
midolman_root_key = /midonet/v1
session_gracetime = 30000

[cassandra]
servers = ${CS}
replication_factor = ${CS_COUNT}
cluster = midonet
EOF

""" % (
    ",".join(zkc),
    ",".join(csc),
    len(csc)
    ))

    cuisine.file_write("/tmp/.%s.lck" % sys._getframe().f_code.co_name, "xoxo")
コード例 #8
0
ファイル: fabfile.py プロジェクト: BinhLPhan/orizuru
def stage7_container_midonet_api():
    metadata = Config(os.environ["CONFIGFILE"])

    if cuisine.file_exists("/tmp/.%s.lck" % sys._getframe().f_code.co_name):
        return

    zk = []

    for zkhost in sorted(metadata.roles['container_zookeeper']):
        zk.append("{'ip' => '%s', 'port' => '2181'}" %
                  metadata.containers[zkhost]['ip'])

    args = {}

    args['zk_servers'] = "[%s]" % ",".join(zk)
    args['keystone_auth'] = "true"
    args['vtep'] = "true"

    #
    # slice and dice the password cache so we can access it in python
    #
    passwords = {}
    with open(os.environ["PASSWORDCACHE"]) as passwordcache:
        for line in passwordcache:
            name, var = line.partition("=")[::2]
            passwords[name] = str(var).rstrip('\n')

    #
    # this is supposed to be the outer ip, not the container ip, remember HATEOAS
    #
    args['api_ip'] = "'%s'" % metadata.servers[metadata.roles["midonet_api"]
                                               [0]]["ip"]
    args['api_port'] = "'8081'"

    args['keystone_host'] = "'%s'" % metadata.containers[
        metadata.roles["container_openstack_keystone"][0]]["ip"]
    args['keystone_port'] = "'35357'"
    args['keystone_admin_token'] = "'%s'" % passwords["export ADMIN_TOKEN"]
    args['keystone_tenant_name'] = "'admin'"

    Puppet.apply('midonet::midonet_api', args, metadata)

    #
    # in case mock auth was installed:
    #
    run("""

sed -i 's,org.midonet.api.auth.MockAuthService,org.midonet.cluster.auth.MockAuthService,g;' /usr/share/midonet-api/WEB-INF/web.xml

""")

    #
    # wait for the api to come up
    #
    puts(
        green(
            "please wait for midonet-api to come up, this can take a long time!"
        ))
    run("""

wget -SO- -- http://%s:8081/midonet-api/; echo

""" % metadata.servers[metadata.roles["midonet_api"][0]]["ip"])

    cuisine.file_write("/tmp/.%s.lck" % sys._getframe().f_code.co_name, "xoxo")