def _setup_node(self, node_id):
    config = self.config
    props = self.config['properties']['configurations']
    logger.debug('_setup_node', config=pprint.pformat(config))
    hostname = settings.HOSTNAME
    urn = (settings.HOST_URN if (not self.urn) else self.urn)
    if node_id:
        r = self.unis.get(('/nodes/' + str(node_id)))
        if (not r):
            logger.warn('_setup_node', msg=('node id %s not found' % node_id))
            r = self.unis.post('/nodes', data={'$schema': settings.SCHEMAS['nodes'], 'name': hostname, 'urn': urn, 'id': node_id})
    if (not node_id):
        r = self.unis.get(('/nodes?urn=' + urn))
        if (r and len(r)):
            r = r[0]
            logger.info('_setup_node', msg=('Found node with our URN and id %s' % r['id']))
        else:
            r = self.unis.post('/nodes', data={'$schema': settings.SCHEMAS['nodes'], 'name': hostname, 'urn': urn})
        if r:
            self.node_id = r['id']
    if r:
        if isinstance(r, list):
            r = r[0]
        config['runningOn'] = {'href': r['selfRef'], 'rel': 'full'}
        self.node_setup = True
    else:
        config['runningOn'] = {'href': ''}
        logger.warn('_setup_node', msg=('Unable to set up BLiPP node in UNIS at %s' % props['unis_url']))
def _setup_node(self, node_id):
    config = self.config
    props = self.config['properties']['configurations']
    logger.debug('_setup_node', config=pprint.pformat(config))
    hostname = settings.HOSTNAME
    urn = (settings.HOST_URN if (not self.urn) else self.urn)
    if node_id:
        r = self.unis.get(('/nodes/' + str(node_id)))
        if (not r):
            logger.warn('_setup_node', msg=('node id %s not found' % node_id))
            r = self.unis.post('/nodes', data={'$schema': settings.SCHEMAS['nodes'], 'name': hostname, 'urn': urn, 'id': node_id})
    if (not node_id):
        r = self.unis.get(('/nodes?urn=' + urn))
        if (r and len(r)):
            r = r[0]
            logger.info('_setup_node', msg=('Found node with our URN and id %s' % r['id']))
        else:
            r = self.unis.post('/nodes', data={'$schema': settings.SCHEMAS['nodes'], 'name': hostname, 'urn': urn})
        if r:
            self.node_id = r['id']
    if r:
        if isinstance(r, list):
            r = r[0]
        config['runningOn'] = {'href': r['selfRef'], 'rel': 'full'}
        self.node_setup = True
    else:
        config['runningOn'] = {'href': }
        logger.warn('_setup_node', msg=('Unable to set up BLiPP node in UNIS at %s' % props['unis_url']))