def METHOD_NAME(bundle, bundle_definition_root, metadata=None):
  try:
    tag = etree.QName(bundle_definition_root.tag)
    schema_version = tag.namespace
    # Ensure namespace exists
    if schema_version not in OOZIE_NAMESPACES:
      raise RuntimeError(_("Tag with namespace %(namespace)s is not valid. Please use one of the following namespaces: %(namespaces)s") % {
        'namespace': bundle_definition_root.tag,
        'namespaces': ', '.join(OOZIE_NAMESPACES)
      })
    # Resolve bundle dependencies and node types and link dependencies
    _set_bundle_properties(bundle, bundle_definition_root, schema_version)
    _set_controls(bundle, bundle_definition_root, schema_version)
    _reconcile_coordinators(bundle, bundle_definition_root, schema_version)
    if metadata:
      _process_metadata(bundle, metadata)
    # Update schema_version
    bundle.schema_version = schema_version
    bundle.save()
  except:
    LOG.exception('failed to import bundle')
    # There was an error importing the bundle so delete every thing associated with it.
    bundle.delete(skip_trash=True)
    raise