def service_present(name, service_type, description=None, profile=None, **connection_args):
 ret = {'name': name, 'changes': {}, 'result': True, 'comment': 'Service "{0}" already exists'.format(name)}
 role = __salt__['keystone.service_get'](name=name, profile=profile, **connection_args)
 if ('Error' not in role):
  return ret
 else:
  if __opts__.get('test'):
   ret['result'] = None
   ret['comment'] = 'Service "{0}" will be added'.format(name)
   return ret
  __salt__['keystone.service_create'](name, service_type, description, profile=profile, **connection_args)
  ret['comment'] = 'Service "{0}" has been added'.format(name)
  ret['changes']['Service'] = 'Created'
 return ret

def service_present ( name , service_type , description = None , profile = None , ** connection_args ) : ret = { 'name' : name , 'changes' : { } , 'result' : True , 'comment' : 'Service "{0}" already exists' . format ( name ) } role = __salt__ [ 'keystone.service_get' ] ( name = name , profile = profile , ** connection_args ) if ( 'Error' not in role ) : return ret else : if __opts__ . get ( 'test' ) : ret [ 'result' ] = None ret [ 'comment' ] = 'Service "{0}" will be added' . format ( name ) return ret __salt__ [ 'keystone.service_create' ] ( name , service_type , description , profile = profile , ** connection_args ) ret [ 'comment' ] = 'Service "{0}" has been added' . format ( name ) ret [ 'changes' ] [ 'Service' ] = 'Created' return ret
ensure service present in keystone catalog name the name of the service service_type the type of openstack service description description of the service .