def main(argv):
    parser = argparse.ArgumentParser()
    default_machines = ["precise:m1.small:1", "cirros:m1.tiny:1"]
    parser.add_argument("machines", default=default_machines, nargs="*")
    parser.add_argument("--active_wait", default=180)
    parser.add_argument("--cloudinit_wait", default=180)
    parser.add_argument("--ping_wait", default=180)
    options = parser.parse_args()
    machines = mojo_utils.parse_mojo_arg(options, 'machines', multiargs=True)
    active_wait = int(mojo_utils.parse_mojo_arg(options, 'active_wait'))
    cloudinit_wait = int(mojo_utils.parse_mojo_arg(options, 'cloudinit_wait'))
    ping_wait = int(mojo_utils.parse_mojo_arg(options, 'ping_wait'))
    logging.basicConfig(level=logging.INFO)
    overcloud_novarc = mojo_utils.get_overcloud_auth()
    novac = mojo_os_utils.get_nova_client(overcloud_novarc)
    priv_key = mojo_os_utils.create_keypair(novac, 'mojo')
    mojo_os_utils.add_secgroup_rules(novac)
    for instanceset in machines:
        image_name, flavor_name, count = instanceset.split(":")
        mojo_os_utils.boot_and_test(novac,
                                    image_name=image_name,
                                    flavor_name=flavor_name,
                                    number=int(count),
                                    privkey=priv_key,
                                    active_wait=active_wait,
                                    cloudinit_wait=cloudinit_wait,
                                    ping_wait=ping_wait)
Ejemplo n.º 2
0
def main(argv):
    mojo_utils.setup_logging()
    overcloud_novarc = mojo_utils.get_overcloud_auth()
    user_config = mojo_utils.get_mojo_config('keystone_users.yaml')
    os_version = mojo_os_utils.get_current_os_versions('keystone')['keystone']
    # Keystone policy.json shipped the charm with liberty requires a domain
    # scoped token. Bug #1649106
    if os_version == 'liberty':
        scope = 'DOMAIN'
    else:
        scope = 'PROJECT'
    keystone_session = mojo_os_utils.get_keystone_session(overcloud_novarc,
                                                          scope=scope)
    keystone_client = (
        mojo_os_utils.get_keystone_session_client(keystone_session))
    if overcloud_novarc.get('API_VERSION', 2) == 2:
        projects = [user['project'] for user in user_config]
        mojo_os_utils.project_create(keystone_client, projects)
        mojo_os_utils.user_create_v2(keystone_client, user_config)
        # TODO validate this works without adding roles
        # mojo_os_utils.add_users_to_roles(keystone_client, user_config)
    else:
        for user in user_config:
            mojo_os_utils.domain_create(keystone_client, [user['domain']])
            mojo_os_utils.project_create(keystone_client, [user['project']],
                                         user['domain'])
    mojo_os_utils.user_create_v3(keystone_client, user_config)
Ejemplo n.º 3
0
def main(argv):
    mojo_utils.setup_logging()
    session = (
        mojo_os_utils.get_keystone_session(mojo_utils.get_overcloud_auth()))
    glance_client = mojo_os_utils.get_glance_session_client(session)
    current_images = mojo_os_utils.get_images_list(glance_client)
    image_config = mojo_utils.get_mojo_config('images.yaml')
    cache_dir = '/tmp/img_cache'
    for image in image_config.keys():
        if image_config[image]['glance_name'] in current_images:
            logging.warning('Skipping %s it is already in'
                            'glance' % (image_config[image]['glance_name']))
            continue
        image_name = image_config[image]['url'].split('/')[-1]
        if os.path.exists(cache_dir + '/' + image_name):
            local_file = cache_dir + '/' + image_name
        else:
            local_file = mojo_os_utils.download_image(
                image_config[image]['url'])
        mojo_os_utils.upload_image(
            glance_client,
            local_file,
            image_config[image]['glance_name'],
            image_config[image]['is_public'],
            image_config[image]['disk_format'],
            image_config[image]['container_format'])
Ejemplo n.º 4
0
def main(argv):
    logging.basicConfig(level=logging.INFO)
    logging.getLogger("urllib3").setLevel(logging.WARNING)
    # Keystone policy.json shipped the charm with liberty requires a domain
    # scoped token. Bug #1649106
    os_version = mojo_os_utils.get_current_os_versions('keystone')['keystone']
    if os_version == 'liberty':
        scope = 'DOMAIN'
    else:
        scope = 'PROJECT'
    undercloud_novarc = mojo_utils.get_undercloud_auth()
    keystone_session_uc = mojo_os_utils.get_keystone_session(undercloud_novarc,
                                                             scope=scope)
    under_novac = mojo_os_utils.get_nova_session_client(keystone_session_uc)

    overcloud_novarc = mojo_utils.get_overcloud_auth()
    keystone_session_oc = mojo_os_utils.get_keystone_session(overcloud_novarc,
                                                             scope=scope)
    clients = {
        'neutron':
        mojo_os_utils.get_neutron_session_client(keystone_session_oc),
        'nova': mojo_os_utils.get_nova_session_client(keystone_session_oc),
        'glance': mojo_os_utils.get_glance_session_client(keystone_session_oc),
    }
    image_config = mojo_utils.get_mojo_config('images.yaml')
    image_password = image_config['cirros']['password']
    # Look for existing Cirros guest
    server, ip = get_cirros_server(clients, image_password)
    router = (clients['neutron'].list_routers(
        name='provider-router')['routers'][0])
    l3_agents = clients['neutron'].list_l3_agent_hosting_routers(
        router=router['id'])['agents']
    logging.info('Checking there are multiple L3 agents running tenant router')
    if len(l3_agents) != 2:
        raise Exception('Unexpected number of l3 agents')
    for agent in l3_agents:
        gateway_hostname = agent['host']
        gateway_server = under_novac.servers.find(name=gateway_hostname)
        logging.info('Shutting down neutron gateway {} ({})'.format(
            gateway_hostname, gateway_server.id))
        gateway_server.stop()
        if not check_server_state(
                under_novac, 'SHUTOFF', server_name=gateway_hostname):
            raise Exception('Server failed to reach SHUTOFF state')
        logging.info('Neutron gateway %s has shutdown' % (gateway_hostname))
        logging.info('Checking connectivity to cirros guest')
        if not mojo_os_utils.wait_for_ping(ip, 90):
            raise Exception('Cirros guest not responding to ping')
        if not mojo_os_utils.ssh_test(
                'cirros', ip, server.name, password=image_password):
            raise Exception('Cirros guest issh connection failed')
        logging.info('Starting neutron gateway: ' + gateway_hostname)
        gateway_server.start()
        if not check_server_state(
                under_novac, 'ACTIVE', server_name=gateway_hostname):
            raise Exception('Server failed to reach SHUTOFF state')
        if not check_neutron_agent_states(clients['neutron'],
                                          gateway_hostname):
            raise Exception('Server agents failed to reach active state')
Ejemplo n.º 5
0
def main(argv):
    overcloud_novarc = mojo_utils.get_overcloud_auth()
    keystone_client = mojo_os_utils.get_keystone_client(overcloud_novarc)
    user_config = mojo_utils.get_mojo_config('keystone_users.yaml')
    tenants = [user['tenant'] for user in user_config]
    mojo_os_utils.tenant_create(keystone_client, tenants)
    mojo_os_utils.user_create(keystone_client, user_config)
    mojo_os_utils.add_users_to_roles(keystone_client, user_config)
Ejemplo n.º 6
0
def main(argv):
    logging.basicConfig(level=logging.INFO)
    parser = argparse.ArgumentParser()
    parser.add_argument("router", nargs="?")
    options = parser.parse_args()
    router_name = mojo_utils.parse_mojo_arg(options, 'router')
    overcloud_novarc = mojo_utils.get_overcloud_auth()
    neutron_client = mojo_os_utils.get_neutron_client(overcloud_novarc)
    router = neutron_client.list_routers(name=router_name)['routers'][0]['id']
    l3_agent = neutron_client.list_l3_agent_hosting_routers(router=router)
    hosting_machine = l3_agent['agents'][0]['host']
    mojo_utils.delete_machine(hosting_machine)
Ejemplo n.º 7
0
def main(argv):
    mojo_utils.setup_logging()
    parser = argparse.ArgumentParser()
    default_machines = ["cirros:m1.tiny:1"]
    parser.add_argument("machines", default=default_machines, nargs="*")
    parser.add_argument("--active_wait", default=180)
    parser.add_argument("--cloudinit_wait", default=180)
    parser.add_argument("--ping_wait", default=180)
    options = parser.parse_args()
    machines = mojo_utils.parse_mojo_arg(options, 'machines', multiargs=True)
    active_wait = int(mojo_utils.parse_mojo_arg(options, 'active_wait'))
    cloudinit_wait = int(mojo_utils.parse_mojo_arg(options, 'cloudinit_wait'))
    ping_wait = int(mojo_utils.parse_mojo_arg(options, 'ping_wait'))
    overcloud_novarc = mojo_utils.get_overcloud_auth()
    keystone_session = mojo_os_utils.get_keystone_session(overcloud_novarc,
                                                          scope='PROJECT')
    os_version = mojo_os_utils.get_current_os_versions('keystone')['keystone']
    # Keystone policy.json shipped the charm with liberty requires a domain
    # scoped token. Bug #1649106
    if os_version == 'liberty':
        project_query_session = mojo_os_utils.get_keystone_session(
            overcloud_novarc, scope='DOMAIN')
    else:
        project_query_session = keystone_session
    keystonec = mojo_os_utils.get_keystone_session_client(
        project_query_session)
    domain = overcloud_novarc.get('OS_PROJECT_DOMAIN_NAME')
    project_id = mojo_os_utils.get_project_id(
        keystonec,
        'admin',
        api_version=overcloud_novarc['API_VERSION'],
        domain_name=domain)
    novac = mojo_os_utils.get_nova_session_client(keystone_session)
    neutronc = mojo_os_utils.get_neutron_session_client(keystone_session)

    init_flavors(novac)

    priv_key = mojo_os_utils.create_keypair(novac, 'mojo')
    mojo_os_utils.add_neutron_secgroup_rules(neutronc, project_id)
    for server in novac.servers.list():
        novac.servers.delete(server.id)
    for instanceset in machines:
        image_name, flavor_name, count = instanceset.split(":")
        mojo_os_utils.boot_and_test(novac,
                                    neutronc,
                                    image_name=image_name,
                                    flavor_name=flavor_name,
                                    number=int(count),
                                    privkey=priv_key,
                                    active_wait=active_wait,
                                    cloudinit_wait=cloudinit_wait,
                                    ping_wait=ping_wait)
Ejemplo n.º 8
0
def keystone_v3_domain_setup():
    overcloud_novarc = mojo_utils.get_overcloud_auth()
    if overcloud_novarc.get('API_VERSION', 2) == 3:
        keystone_session = mojo_os_utils.get_keystone_session(overcloud_novarc)
        keystone_client = mojo_os_utils.get_keystone_session_client(
            keystone_session)
        mojo_os_utils.project_create(keystone_client, ['admin'],
                                     'admin_domain')
        admin_project_id = mojo_os_utils.get_tenant_id(
            keystone_client,
            'admin',
            api_version=3,
            domain_name='admin_domain')
        role = keystone_client.roles.find(name='admin')
        user = keystone_client.users.find(name='admin')
        keystone_client.roles.grant(role, user=user, project=admin_project_id)
Ejemplo n.º 9
0
def main(argv):
    mojo_utils.setup_logging()
    # Setup client
    overcloud_novarc = mojo_utils.get_overcloud_auth()
    keystone_session = mojo_os_utils.get_keystone_session(overcloud_novarc,
                                                          scope='PROJECT')
    client = mojo_os_utils.get_designate_session_client(keystone_session)
    os_version = mojo_os_utils.get_current_os_versions('keystone')['keystone']

    if os_version >= 'queens':
        designate_api_version = 2
        zone = mojo_os_utils.create_or_return_zone(client, TEST_DOMAIN,
                                                   TEST_DOMAIN_EMAIL)
        rs = mojo_os_utils.create_or_return_recordset(
            client, zone['id'], 'www', 'A', [TEST_RECORD[TEST_WWW_RECORD]])
    else:
        designate_api_version = 1

        # Create test domain and record in test domain
        domain = mojo_os_utils.create_designate_dns_domain(
            client, TEST_DOMAIN, TEST_DOMAIN_EMAIL)
        record = mojo_os_utils.create_designate_dns_record(
            client, domain.id, TEST_WWW_RECORD, "A",
            TEST_RECORD[TEST_WWW_RECORD])

    # Test record is in bind and designate
    mojo_os_utils.check_dns_entry(client,
                                  TEST_RECORD[TEST_WWW_RECORD],
                                  TEST_DOMAIN,
                                  record_name=TEST_WWW_RECORD,
                                  designate_api=designate_api_version)

    mojo_utils.add_unit('designate-bind')

    mojo_os_utils.check_dns_entry(client,
                                  TEST_RECORD[TEST_WWW_RECORD],
                                  TEST_DOMAIN,
                                  record_name=TEST_WWW_RECORD,
                                  designate_api=designate_api_version)

    mojo_utils.delete_oldest('designate-bind')

    mojo_os_utils.check_dns_entry(client,
                                  TEST_RECORD[TEST_WWW_RECORD],
                                  TEST_DOMAIN,
                                  record_name=TEST_WWW_RECORD,
                                  designate_api=designate_api_version)
Ejemplo n.º 10
0
def main(argv):
    logging.basicConfig(level=logging.INFO)
    overcloud_novarc = mojo_utils.get_overcloud_auth()
    glance_client = mojo_os_utils.get_glance_client(overcloud_novarc)
    current_images = mojo_os_utils.get_images_list(glance_client)
    image_config = mojo_utils.get_mojo_config('images.yaml')
    for image in image_config.keys():
        if image_config[image]['glance_name'] in current_images:
            logging.warning('Skipping %s it is already in'
                            'glance' % (image_config[image]['glance_name']))
            continue
        local_file = mojo_os_utils.download_image(image_config[image]['url'])
        mojo_os_utils.upload_image(glance_client, local_file,
                                   image_config[image]['glance_name'],
                                   image_config[image]['is_public'],
                                   image_config[image]['disk_format'],
                                   image_config[image]['container_format'])
Ejemplo n.º 11
0
def main(argv):
    mojo_utils.setup_logging()
    overcloud_novarc = mojo_utils.get_overcloud_auth()
    keystone_session = mojo_os_utils.get_keystone_session(overcloud_novarc)
    aodhc = mojo_os_utils.get_aodh_session_client(keystone_session)
    nova_client = mojo_os_utils.get_nova_session_client(keystone_session)

    servers = nova_client.servers.list()
    assert servers, "No servers available for AODH testing"
    if servers:
        alarm_name = 'mojo_instance_off'
        server = servers[0]
        assert server.status == 'ACTIVE', "Server {} not active".format(
            server.name)
        logging.info('Using server {} for aodh test'.format(server.name))
        server = nova_client.servers.find(name=server.name)
        logging.info('Deleting alarm {} if it exists'.format(alarm_name))
        mojo_os_utils.delete_alarm(aodhc, alarm_name)
        logging.info('Creating alarm {}'.format(alarm_name))
        alarm_def = {
            'type': 'event',
            'name': alarm_name,
            'description': 'Instance powered OFF',
            'alarm_actions': ['log://'],
            'ok_actions': ['log://'],
            'insufficient_data_actions': ['log://'],
            'event_rule': {
                'event_type': 'compute.instance.power_off.*',
                'query': [{'field': 'traits.instance_id',
                           'op': 'eq',
                           'type': 'string',
                           'value': server.id}]}}
        alarm_info = aodhc.alarm.create(alarm_def)
        logging.info('Stopping server {}'.format(server.name))
        server.stop()
        for i in range(10):
            alarm_state = mojo_os_utils.get_alarm_state(
                aodhc,
                alarm_info['alarm_id'])
            if alarm_state == 'alarm':
                logging.info('Alarm triggered')
                break
            else:
                time.sleep(5)
        else:
            raise Exception("Alarm failed to trigger")
Ejemplo n.º 12
0
def main(argv):
    mojo_utils.setup_logging()
    parser = argparse.ArgumentParser()
    parser.add_argument('--peer-application', '-a',
                        help='BGP Peer application name. Default: quagga',
                        default='quagga')
    options = parser.parse_args()

    peer_application_name = mojo_utils.parse_mojo_arg(options,
                                                      'peer_application')
    overcloud_novarc = mojo_utils.get_overcloud_auth()
    os_version = mojo_os_utils.get_current_os_versions('keystone')['keystone']
    # Keystone policy.json shipped the charm with liberty requires a domain
    # scoped token. Bug #1649106
    if os_version == 'liberty':
        scope = 'DOMAIN'
    else:
        scope = 'PROJECT'
    keystone_session = mojo_os_utils.get_keystone_session(overcloud_novarc,
                                                          scope=scope)
    neutronc = mojo_os_utils.get_neutron_session_client(keystone_session)

    # Run show ip route on BGP peer
    peer_unit = mojo_utils.get_juju_units(service=peer_application_name)[0]
    logging.info("Checking routes on BGP peer {}".format(peer_unit))
    routes = mojo_utils.remote_run(peer_unit,
                                   remote_cmd="vtysh -c 'show ip route'")[0]
    logging.debug(routes)

    # Check for expected advertised routes
    private_cidr = neutronc.list_subnets(
        name='private_subnet')['subnets'][0]['cidr']
    floating_ip_cidr = "{}/32".format(
        neutronc.list_floatingips()['floatingips'][0]['floating_ip_address'])
    assert private_cidr in routes, ("Private subnet CIDR, {}, not advertised "
                                    "to BGP peer".format(private_cidr))
    logging.info("Private subnet CIDR, {}, found in routing table"
                 .format(private_cidr))
    assert floating_ip_cidr in routes, ("Floating IP, {}, not advertised "
                                        "to BGP peer".format(floating_ip_cidr))
    logging.info("Floating IP CIDR, {}, found in routing table"
                 .format(floating_ip_cidr))
def main(argv):
    mojo_utils.setup_logging()
    parser = argparse.ArgumentParser()
    parser.add_argument('--peer-application',
                        '-a',
                        help='BGP peer application name. Default: quagga',
                        default='quagga')

    options = parser.parse_args()
    peer_application_name = mojo_utils.parse_mojo_arg(options,
                                                      'peer_application')

    overcloud_novarc = mojo_utils.get_overcloud_auth()
    os_version = mojo_os_utils.get_current_os_versions('keystone')['keystone']
    # Keystone policy.json shipped the charm with liberty requires a domain
    # scoped token. Bug #1649106
    if os_version == 'liberty':
        scope = 'DOMAIN'
    else:
        scope = 'PROJECT'
    keystone_session = mojo_os_utils.get_keystone_session(overcloud_novarc,
                                                          scope=scope)
    neutronc = mojo_os_utils.get_neutron_session_client(keystone_session)

    logging.info("Setting up BGP speaker")
    bgp_speaker = mojo_os_utils.create_bgp_speaker(neutronc, local_as=12345)

    logging.info("Advertising BGP routes")
    # Add networks to bgp speaker
    mojo_os_utils.add_network_to_bgp_speaker(neutronc, bgp_speaker, 'ext_net')
    mojo_os_utils.add_network_to_bgp_speaker(neutronc, bgp_speaker, 'private')
    logging.debug("Advertised routes: {}".format(
        neutronc.list_route_advertised_from_bgp_speaker(bgp_speaker['id'])))

    # Create peer
    logging.info("Setting up BGP peer")
    bgp_peer = mojo_os_utils.create_bgp_peer(neutronc,
                                             peer_application_name,
                                             remote_as=10000)
    # Add peer to bgp speaker
    mojo_os_utils.add_peer_to_bgp_speaker(neutronc, bgp_speaker, bgp_peer)
Ejemplo n.º 14
0
 def get_swiftclient(self):
     keystone_session = mojo_os_utils.get_keystone_session(
         mojo_utils.get_overcloud_auth())
     swift_client = mojo_os_utils.get_swift_session_client(keystone_session)
     return swift_client
Ejemplo n.º 15
0
def setup_sdn(net_topology, net_info):
    overcloud_novarc = mojo_utils.get_overcloud_auth()
    os_version = mojo_os_utils.get_current_os_versions('keystone')['keystone']
    # Keystone policy.json shipped the charm with liberty requires a domain
    # scoped token. Bug #1649106
    if os_version == 'liberty':
        scope = 'DOMAIN'
    else:
        scope = 'PROJECT'
    keystone_session = mojo_os_utils.get_keystone_session(overcloud_novarc,
                                                          scope=scope)
    keystonec = mojo_os_utils.get_keystone_session_client(keystone_session)
    neutronc = mojo_os_utils.get_neutron_session_client(keystone_session)
    # Resolve the project name from the overcloud novarc into a project id
    project_id = mojo_os_utils.get_project_id(
        keystonec, 'admin', api_version=overcloud_novarc['API_VERSION'])
    # Network Setup
    subnetpools = False
    if net_info.get('subnetpool_prefix'):
        subnetpools = True
    # Create the external network
    ext_network = mojo_os_utils.create_external_network(
        neutronc, project_id, net_info.get('dvr_enabled', False),
        net_info['external_net_name'])
    mojo_os_utils.create_external_subnet(neutronc, project_id, ext_network,
                                         net_info['default_gateway'],
                                         net_info['external_net_cidr'],
                                         net_info['start_floating_ip'],
                                         net_info['end_floating_ip'],
                                         net_info['external_subnet_name'])
    # Should this be --enable_snat = False
    provider_router = (mojo_os_utils.create_provider_router(
        neutronc, project_id))
    mojo_os_utils.plug_extnet_into_router(neutronc, provider_router,
                                          ext_network)
    ip_version = net_info.get('ip_version') or 4
    subnetpool = None
    if subnetpools:
        address_scope = mojo_os_utils.create_address_scope(
            neutronc,
            project_id,
            net_info.get('address_scope'),
            ip_version=ip_version)
        subnetpool = mojo_os_utils.create_subnetpool(
            neutronc, project_id, net_info.get('subnetpool_name'),
            net_info.get('subnetpool_prefix'), address_scope)
    project_network = mojo_os_utils.create_project_network(
        neutronc,
        project_id,
        shared=False,
        network_type=net_info['network_type'])
    project_subnet = mojo_os_utils.create_project_subnet(
        neutronc,
        project_id,
        project_network,
        net_info.get('private_net_cidr'),
        subnetpool=subnetpool,
        ip_version=ip_version)
    mojo_os_utils.update_subnet_dns(neutronc, project_subnet,
                                    net_info['external_dns'])
    mojo_os_utils.plug_subnet_into_router(neutronc, net_info['router_name'],
                                          project_network, project_subnet)
Ejemplo n.º 16
0
def main(argv):
    mojo_utils.setup_logging()
    parser = argparse.ArgumentParser()
    parser.add_argument('-r', '--resolver',
                        help='Resolver address. '
                             'Usually designate-bind address.',
                        required=False)
    parser.add_argument('-d', '--domain_name', help='DNS Domain Name. '
                                                    'Must end in a .',
                        default='mojo.serverstack.')
    parser.add_argument('-e', '--email', help='Email address',
                        default='*****@*****.**')
    parser.add_argument('-b', '--bind-service', help='Bind Service Name',
                        default='designate-bind')

    options = parser.parse_args()
    bind_service_name = mojo_utils.parse_mojo_arg(options, 'bind_service')
    resolver = mojo_utils.parse_mojo_arg(options, 'resolver')
    bind_unit = mojo_utils.get_juju_units(service=bind_service_name)[0]
    if not resolver:
        resolver = mojo_utils.get_juju_unit_ip(bind_unit)
    domain_name = mojo_utils.parse_mojo_arg(options, 'domain_name')
    email = mojo_utils.parse_mojo_arg(options, 'email')
    nameserver = 'ns1.{}'.format(domain_name)

    logging.info('Setting up designate {} {}'.format(nameserver, resolver))

    overcloud_novarc = mojo_utils.get_overcloud_auth()
    os_version = mojo_os_utils.get_current_os_versions('keystone')['keystone']
    # Keystone policy.json shipped the charm with liberty requires a domain
    # scoped token. Bug #1649106
    if os_version == 'liberty':
        scope = 'DOMAIN'
    else:
        scope = 'PROJECT'
    keystone_session = mojo_os_utils.get_keystone_session(overcloud_novarc,
                                                          scope=scope)
    neutronc = mojo_os_utils.get_neutron_session_client(keystone_session)

    if os_version >= 'queens':
        designatec = mojo_os_utils.get_designate_session_client(
            keystone_session,
            client_version='2')
        zone = mojo_os_utils.create_or_return_zone(
            designatec,
            domain_name,
            email)
        rs = mojo_os_utils.create_or_return_recordset(
            designatec,
            zone['id'],
            'www',
            'A',
            [resolver])
    else:
        designatec = mojo_os_utils.get_designate_session_client(
            keystone_session,
            client_version='1')
        if not mojo_os_utils.get_designate_server_id(designatec, nameserver):
            logging.info('Creating server {}'.format(nameserver))
            server = Server(name=nameserver)
            server_id = designatec.servers.create(server)
            assert(server_id is not None)
        else:
            logging.info('{} server already exists.'.format(nameserver))

        domain_id = mojo_os_utils.get_designate_domain_id(
            designatec,
            domain_name)
        if not domain_id:
            logging.info('Creating domain {}'.format(domain_name))
            domain = Domain(name=domain_name, email=email)
            domain_id = designatec.domains.create(domain)
            assert(domain_id is not None)
        else:
            logging.info('{} domain already exists.'.format(domain_name))

        if not mojo_os_utils.get_designate_record_id(designatec, domain_id,
                                                     nameserver):
            logging.info('Creating NS record {}'.format(nameserver))
            ns_record = Record(
                name=nameserver,
                type="A",
                data=resolver)
            record_id = designatec.records.create(domain_id, ns_record)
            assert(record_id is not None)
        else:
            logging.info('{} record already exists.'.format(nameserver))

    logging.info('Update network to use domain {}'.format(domain_name))
    net_uuid = mojo_os_utils.get_net_uuid(neutronc, 'private')
    mojo_os_utils.update_network_dns(neutronc, net_uuid, domain_name)