Пример #1
0
def prepareManagementServer(mgmt_host):
    """
    Prepare the mgmt server for a marvin test run
    """
    if _isPortListening(host=mgmt_host, port=22, timeout=10) \
            and _isPortListening(host=mgmt_host, port=3306, timeout=10) \
            and _isPortListening(host=mgmt_host, port=8080, timeout=300):
        delay(120) #introduce dumb delay
        mgmt_ip = macinfo[mgmt_host]["address"]
        mgmt_pass = macinfo[mgmt_host]["password"]
        with contextlib.closing(sshClient.SshClient(mgmt_ip, 22, "root", mgmt_pass)) as ssh:
            # Open up 8096 for Marvin initial signup and register
            ssh.execute("mysql -ucloud -pcloud -Dcloud -e\"update configuration set value=8096 where name like 'integr%'\"")
            ssh.execute("service cloudstack-management restart")
    else:
        raise Exception("Reqd services (ssh, mysql) on management server are not up. Aborting")

    if _isPortListening(host=mgmt_host, port=8096, timeout=300):
        logging.info("All reqd services are up on the management server %s"%mgmt_host)
        testManagementServer(mgmt_host)
        return
    else:
        with contextlib.closing(sshClient.SshClient(mgmt_ip, 22, "root", mgmt_pass)) as ssh:
            # Force kill java process
            ssh.execute("killall -9 java; service cloudstack-management start")

    if _isPortListening(host=mgmt_host, port=8096, timeout=300):
        logging.info("All reqd services are up on the management server %s"%mgmt_host)
        testManagementServer(mgmt_host)
        return
    else:
        raise Exception("Reqd service for integration port on management server %s is not open. Aborting"%mgmt_host)
Пример #2
0
def testManagementServer(mgmt_host):
    """
    Test that the cloudstack service is up
    """
    #TODO: Add user registration step
    mgmt_ip = macinfo[mgmt_host]["address"]
    mgmt_pass = macinfo[mgmt_host]["password"]
    with contextlib.closing(sshClient.SshClient(mgmt_ip, 22, "root", mgmt_pass)) as ssh:
        isManagementServiceStable(ssh, timeout=60)
Пример #3
0
def configureManagementServer(mgmt_host):
    """
    We currently configure all mgmt servers on a single xen HV. In the future
    replace this by launching instances via the API on a IaaS cloud using
    desired template
    """
    mgmt_vm = macinfo[mgmt_host]
    mgmt_ip = macinfo[mgmt_host]["address"]

    #Remove and re-add cobbler system
    bash("cobbler system remove --name=%s" % mgmt_host)
    bash("cobbler system add --name=%s --hostname=%s --mac-address=%s \
         --netboot-enabled=yes --enable-gpxe=no \
         --profile=%s --server=%s --gateway=%s" %
         (mgmt_host, mgmt_host, mgmt_vm["ethernet"], mgmt_host,
          cobblerHomeResolve(mgmt_ip,
                             param='cblrgw'), cobblerHomeResolve(mgmt_ip)))
    bash("cobbler sync")

    #Revoke all certs from puppetmaster
    bash("puppet cert clean %s.%s" % (mgmt_host, DOMAIN))

    #Start VM on xenserver
    xenssh = \
    sshClient.SshClient(macinfo["infraxen"]["address"],
                                    22, "root",
                                    macinfo["infraxen"]["password"])

    logging.debug("bash vm-uninstall.sh -n %s" % (mgmt_host))
    xenssh.execute("xe vm-uninstall force=true vm=%s" % mgmt_host)
    logging.debug("bash vm-start.sh -n %s -m %s" %
                  (mgmt_host, mgmt_vm["ethernet"]))
    out = xenssh.execute("bash vm-start.sh -n %s -m %s" %
                         (mgmt_host, mgmt_vm["ethernet"]))

    logging.info("started mgmt server with uuid: %s. Waiting for services .." %
                 out)
    return mgmt_host
Пример #4
0
    parser = OptionParser()
    parser.add_option(
        "-c",
        "--config",
        action="store",
        default="xen.cfg",
        dest="config",
        help="the path where the server configurations is stored")
    (options, args) = parser.parse_args()

    if options.config is None:
        raise

    cscfg = configGenerator.getSetupConfig(options.config)
    mgmt_server = cscfg.mgtSvr[0].mgtSvrIp
    ssh = sshClient.SshClient(mgmt_server, 22, "root", "password")
    ssh.execute("service cloudstack-management restart")

    #Telnet wait until api port is open
    tn = None
    timeout = 120
    while timeout > 0:
        try:
            tn = telnetlib.Telnet(mgmt_server, 8096, timeout=120)
            break
        except Exception:
            delay(1)
            timeout = timeout - 1
    if tn is None:
        raise socket.error("Unable to reach API port")