Verified Commit 2f9a1a9a authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

API: Add logic for ADM_tear_down_adhoc_storage()

parent a3dd90c1
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -161,6 +161,14 @@ ADM_deploy_adhoc_storage(ADM_server_t server,
            srv, scord::adhoc_storage{adhoc_storage});
}

ADM_return_t
ADM_tear_down_adhoc_storage(ADM_server_t server,
                            ADM_adhoc_storage_t adhoc_storage) {

    return scord::detail::tear_down_adhoc_storage(
            scord::server{server}, scord::adhoc_storage{adhoc_storage});
}

ADM_return_t
ADM_register_pfs_storage(ADM_server_t server, const char* name,
                         ADM_pfs_storage_type_t type, ADM_pfs_context_t ctx,
+37 −0
Original line number Diff line number Diff line
@@ -479,6 +479,43 @@ deploy_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage) {
    return scord::error_code::other;
}

scord::error_code
tear_down_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage) {

    scord::network::client rpc_client{srv.protocol()};

    const auto rpc_id = ::api::remote_procedure::new_id();

    if(const auto lookup_rv = rpc_client.lookup(srv.address());
       lookup_rv.has_value()) {
        const auto& endp = lookup_rv.value();

        LOGGER_INFO("rpc id: {} name: {} from: {} => "
                    "body: {{adhoc_id: {}}}",
                    rpc_id, std::quoted("ADM_"s + __FUNCTION__),
                    std::quoted(rpc_client.self_address()), adhoc_storage.id());

        if(const auto call_rv =
                   endp.call("ADM_"s + __FUNCTION__, adhoc_storage.id());
           call_rv.has_value()) {

            const scord::network::generic_response resp{call_rv.value()};

            LOGGER_EVAL(resp.error_code(), INFO, ERROR,
                        "rpc id: {} name: {} from: {} <= "
                        "body: {{retval: {}}} [op_id: {}]",
                        rpc_id, std::quoted("ADM_"s + __FUNCTION__),
                        std::quoted(endp.address()), resp.error_code(),
                        resp.op_id());

            return resp.error_code();
        }
    }

    LOGGER_ERROR("rpc call failed");
    return scord::error_code::other;
}

tl::expected<transfer, error_code>
transfer_datasets(const server& srv, const job& job,
                  const std::vector<dataset>& sources,
+3 −0
Original line number Diff line number Diff line
@@ -62,6 +62,9 @@ remove_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage);
scord::error_code
deploy_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage);

scord::error_code
tear_down_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage);

tl::expected<scord::pfs_storage, scord::error_code>
register_pfs_storage(const server& srv, const std::string& name,
                     enum pfs_storage::type type, const pfs_storage::ctx& ctx);
+11 −0
Original line number Diff line number Diff line
@@ -299,6 +299,17 @@ deploy_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage) {
    }
}

void
tear_down_adhoc_storage(const server& srv, const adhoc_storage& adhoc_storage) {

    const auto ec = detail::tear_down_adhoc_storage(srv, adhoc_storage);

    if(!ec) {
        throw std::runtime_error(fmt::format(
                "ADM_deploy_adhoc_storage() error: {}", ec.message()));
    }
}

scord::pfs_storage
register_pfs_storage(const server& srv, const std::string& name,
                     enum pfs_storage::type type, const pfs_storage::ctx& ctx) {
+12 −0
Original line number Diff line number Diff line
@@ -158,6 +158,18 @@ ADM_return_t
ADM_deploy_adhoc_storage(ADM_server_t server,
                         ADM_adhoc_storage_t adhoc_storage);

/**
 * Tear down a previously deployed adhoc storage system instance
 *
 * @param[in] server The server to which the request is directed
 * @param[in] adhoc_storage An ADM_STORAGE referring to the adhoc storage
 * instance of interest.
 * @return Returns ADM_SUCCESS if the remote procedure has completed
 */
ADM_return_t
ADM_tear_down_adhoc_storage(ADM_server_t server,
                            ADM_adhoc_storage_t adhoc_storage);

/**
 * Register a PFS storage tier.
 *
Loading