def _setup_service(self):
    config = self.config
    props = self.config['properties']['configurations']
    logger.debug('_setup_service', config=pprint.pformat(config))
    r = None
    if config.get('id', None):
        r = self.unis.get(('/services/' + config['id']))
    if (not r):
        logger.warn('_setup_service', msg='service id not specified or not found unis instance ...querying for service')
        rlist = self.unis.get((((('/services?name=' + config.get('name', None)) + '&runningOn.href=') + config['runningOn']['href']) + '&limit=2'))
        if rlist:
            for i in range(len(rlist)):
                r = self.unis.get(('/services/' + rlist[i]['id']))
                if r:
                    logger.info('_setup_service', msg=('%s service found with id %s' % (config['name'], r['id'])))
                    break
        else:
            logger.warn('_setup_service', msg=('no service found by id or querying ...creating new service at %s' % props['unis_url']))
    if (isinstance(r, dict) and r):
        merge_dicts(config, r)
    r = None
    if config.get('id', None):
        r = self.unis.put(('/services/' + config['id']), data=config)
    if (not r):
        r = self.unis.post('/services', data=config)
    if (r and isinstance(r, dict)):
        merge_dicts(config, r)
    if r:
        self.service_setup = True
    else:
        logger.warn('_setup_service', msg='unable to set up service in UNIS')
def _setup_service(self):
    config = self.config
    props = self.config['properties']['configurations']
    logger.debug('_setup_service', config=pprint.pformat(config))
    r = None
    if config.get('id', None):
        r = self.unis.get(('/services/' + config['id']))
    if (not r):
        logger.warn('_setup_service', msg='service id not specified or not found unis instance ...querying for service')
        rlist = self.unis.get((((('/services?name=' + config.get('name', None)) + '&runningOn.href=') + config['runningOn']['href']) + '&limit=2'))
        if rlist:
            for i in range(len(rlist)):
                r = self.unis.get(('/services/' + rlist[i]['id']))
                if r:
                    logger.info('_setup_service', msg=('%s service found with id %s' % (config['name'], r['id'])))
                    break
        else:
            logger.warn('_setup_service', msg=('no service found by id or querying ...creating new service at %s' % props['unis_url']))
    if (isinstance(r, dict) and r):
        merge_dicts(config, r)
    r = None
    if config.get('id', None):
        r = self.unis.put(('/services/' + config['id']), data=config)
    if (not r):
        r = self.unis.post('/services', data=config)
    if (r and isinstance(r, dict)):
        merge_dicts(config, r)
    if r:
        self.service_setup = True
    else:
        logger.warn('_setup_service', msg='unable to set up service in UNIS')