install::xml::action::mount-existing (public)

 install::xml::action::mount-existing node

Defined in packages/acs-tcl/tcl/install-procs.tcl

Mounts an existing package on a specified node.

<mount-existing package-id="package-id mount-point="url" />

Parameters:
node

Partial Call Graph (max 5 caller/called nodes):
%3 apm_attribute_value apm_attribute_value (public) apm_package_id_from_key apm_package_id_from_key (public) install::xml::util::get_id install::xml::util::get_id (public) site_node::get site_node::get (public) site_node::get_from_url site_node::get_from_url (public) install::xml::action::mount-existing install::xml::action::mount-existing install::xml::action::mount-existing->apm_attribute_value install::xml::action::mount-existing->apm_package_id_from_key install::xml::action::mount-existing->install::xml::util::get_id install::xml::action::mount-existing->site_node::get install::xml::action::mount-existing->site_node::get_from_url

Testcases:
No testcase defined.
Source code:
    set package_id [apm_attribute_value -default "" $node package-id]
    set package_key [apm_attribute_value -default "" $node package-key]
    set mount_point [apm_attribute_value -default "" $node mount-point]

    set out [list]

    # Remove double slashes
    regsub -all -- {//} $mount_point "/" mount_point
    set mount_point [string trim $mount_point " /"]

    if {[string is space $mount_point] || $mount_point eq "/"} {
        array set site_node [site_node::get -url "/"]

        if {$site_node(object_id) ne ""} {
            ns_log Error "A package is already mounted at '$mount_point', ignoring mount command"
            lappend out "A package is already mounted at '$mount_point', ignoring mount command"
            set node_id ""
        }
    } else {
        set leaf_url $mount_point
        set parent_url ""
        regexp {(.*)/([^/]*)$} $mount_point match parent_url leaf_url

        set parent_id [site_node::get_node_id -url "/$parent_url"]

        # technically this isn't safe - between us checking that the node exists
        # and using it, the node may have been deleted.
        # We could "select for update" but since it's in a memory cache anyway,
        # it won't help us very much!
        # Instead we just press on and if there's an error handle it at the top level.

        # create the node and reget iff it doesn't exist
        if { [catch { array set site_node [site_node::get_from_url -exact -url "/$mount_point"] } error] } {
            set node_id [site_node::new -name $leaf_url -parent_id $parent_id]
            array set site_node [site_node::get_from_url -exact -url "/$mount_point"]
        }

        # There now definitely a node with that path
        if {$site_node(object_id) eq ""} {
            # no package mounted - good!
            set node_id $site_node(node_id)
        } else {
            ns_log Error "A package is already mounted at '$mount_point', ignoring mount command"
            lappend out "A package is already mounted at '$mount_point', ignoring mount command"
            set node_id ""
        }
    }

    if {$node_id ne ""} {
        lappend out "Mounting existing package $package_id at /$mount_point"

        if {$package_id ne ""} {
            set package_id [install::xml::util::get_id $package_id]
        } elseif {$package_key ne ""} {
            set package_id [apm_package_id_from_key $package_key]
        }

        set package_id [site_node::mount  -node_id $node_id  -object_id $package_id]
    }

    return $out
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: