Example #1
0
def test_create_hosts():
    br = Branch.get_unique(sess, 'ny-prod', compel=True)
    dns_dmn = DnsDomain.get_unique(sess, 'one-nyp.ms.com', compel=True)
    stat = Status.get_unique(sess, 'build', compel=True)
    os = sess.query(OperatingSystem).filter(Archetype.name == 'vmhost').first()
    assert os, 'No OS in %s' % func_name()

    pers = sess.query(Personality).select_from(
        join(Personality, Archetype)).filter(
        and_(Archetype.name=='vmhost', Personality.name=='generic')).one()

    sess.autoflush=False

    for i in xrange(NUM_HOSTS):
        machine = m_factory.next()
        vm_host = Host(machine=machine, name='%s%s' % (HOST_NAME, i),
                       dns_domain=dns_dmn, branch=br, personality=pers,
                       status=stat, operating_system=os)
        add(sess, vm_host)

    sess.autoflush=True

    commit(sess)

    hosts = sess.query(Host).filter(
        Host.name.like(HOST_NAME+'%')).all()
    assert len(hosts) is NUM_HOSTS
    print 'created %s hosts'% len(hosts)
Example #2
0
def test_create_hosts():
    br = Branch.get_unique(sess, 'ny-prod', compel=True)
    dns_dmn = DnsDomain.get_unique(sess, 'one-nyp.ms.com', compel=True)
    stat = Status.get_unique(sess, 'build', compel=True)
    os = sess.query(OperatingSystem).filter(Archetype.name == 'vmhost').first()
    assert os, 'No OS in %s' % func_name()

    pers = sess.query(Personality).select_from(join(
        Personality, Archetype)).filter(
            and_(Archetype.name == 'vmhost',
                 Personality.name == 'generic')).one()

    sess.autoflush = False

    for i in xrange(NUM_HOSTS):
        machine = m_factory.next()
        vm_host = Host(machine=machine,
                       name='%s%s' % (HOST_NAME, i),
                       dns_domain=dns_dmn,
                       branch=br,
                       personality=pers,
                       status=stat,
                       operating_system=os)
        add(sess, vm_host)

    sess.autoflush = True

    commit(sess)

    hosts = sess.query(Host).filter(Host.name.like(HOST_NAME + '%')).all()
    assert len(hosts) is NUM_HOSTS
    print 'created %s hosts' % len(hosts)
Example #3
0
ms.version.addpkg('ipaddr', '2.1.9')
from ipaddr import IPv4Address as IPAddr

from nose.tools import eq_

NUM_MACHINES = 2
DNAME = 'ms.com'
DNSENV = 'internal'
SHORT_NAME_PREFIX = 'aqdb-test-host-'
MACHINE_NAME_PREFIX = 'test_machine_'

sess = DbFactory().Session()
assert sess, 'No session in %s' % func_name()

#TODO: factor out assert_type(obj, cls, func_name) the isinstance calls
STATUS = Status.get_unique(sess, 'ready')
assert isinstance(STATUS, Status), 'No ready status @ %s' % func_name()

DOMAIN = Domain.get_unique(sess, 'ny-prod')
assert isinstance(DOMAIN, Domain), 'no ny-prod domain @ %s' % func_name()

ARCH = Archetype.get_unique(sess, 'aquilon')
assert isinstance(ARCH, Archetype), 'No archetype @ %s' % func_name()

OS = OperatingSystem.get_unique(sess,
                                name='linux',
                                version='5.0.1-x86_64',
                                archetype=ARCH)
assert isinstance(OS, OperatingSystem), 'No os @ %s' % func_name()

PRSNLTY = Personality.get_unique(sess, name='generic', archetype=ARCH)
Example #4
0
ms.version.addpkg('ipaddr', '2.1.9')
from ipaddr import IPv4Address as IPAddr

from nose.tools import eq_

NUM_MACHINES = 2
DNAME = 'ms.com'
DNSENV = 'internal'
SHORT_NAME_PREFIX = 'aqdb-test-host-'
MACHINE_NAME_PREFIX = 'test_machine_'

sess = DbFactory().Session()
assert sess, 'No session in %s' % func_name()

#TODO: factor out assert_type(obj, cls, func_name) the isinstance calls
STATUS = Status.get_unique(sess, 'ready')
assert isinstance(STATUS, Status), 'No ready status @ %s' % func_name()

DOMAIN = Domain.get_unique(sess, 'ny-prod')
assert isinstance(DOMAIN, Domain), 'no ny-prod domain @ %s' % func_name()

ARCH = Archetype.get_unique(sess, 'aquilon')
assert isinstance(ARCH, Archetype), 'No archetype @ %s' % func_name()

OS = OperatingSystem.get_unique(sess, name='linux', version='5.0.1-x86_64',
                                archetype=ARCH)
assert isinstance(OS, OperatingSystem), 'No os @ %s' % func_name()

PRSNLTY = Personality.get_unique(sess, name='generic', archetype=ARCH)
assert isinstance(PRSNLTY, Personality), 'no personality @ %s' % func_name()