Commit d1474618 authored by Alberto Miranda's avatar Alberto Miranda ♨️
Browse files

Rename CTLAPI functions with prefix nornsctl_

parent eca2f5b9
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -88,35 +88,35 @@ void norns_job_init(norns_job_t* job, const char** hosts, size_t nhosts,
                    norns_job_limit_t** limits, size_t nlimits) __THROW;

/* Check if the urd daemon is running */
norns_error_t norns_ping() __THROW;
norns_error_t nornsctl_ping() __THROW;

/* Send a command to the daemon (e.g. stop accepting new tasks) */
//norns_error_t norns_command();

/* Register a batch job into the system */
norns_error_t norns_register_job(uint32_t jobid, norns_job_t* job) __THROW;
norns_error_t nornsctl_register_job(uint32_t jobid, norns_job_t* job) __THROW;

/* Update an existing batch job */
/* XXX: At the moment this invalidates all registered processes for this job */
norns_error_t norns_update_job(uint32_t jobid, norns_job_t* job) __THROW;
norns_error_t nornsctl_update_job(uint32_t jobid, norns_job_t* job) __THROW;

/* Remove a batch job from the system */
norns_error_t norns_unregister_job(uint32_t jobid) __THROW;
norns_error_t nornsctl_unregister_job(uint32_t jobid) __THROW;

/* Add a process to a registered batch job */
norns_error_t norns_add_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW;
norns_error_t nornsctl_add_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW;

/* Remove a process from a registered batch job */
norns_error_t norns_remove_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW;
norns_error_t nornsctl_remove_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) __THROW;

/* Register a namespace in the local norns server */
norns_error_t norns_register_namespace(const char* nsid, norns_backend_t* backend) __THROW;
norns_error_t nornsctl_register_namespace(const char* nsid, norns_backend_t* backend) __THROW;

/* Update an existing namespace in the local norns server */
norns_error_t norns_update_namespace(const char* nsid, norns_backend_t* backend) __THROW;
norns_error_t nornsctl_update_namespace(const char* nsid, norns_backend_t* backend) __THROW;

/* Unregister a namespace from the local norns server */
norns_error_t norns_unregister_namespace(const char* nsid) __THROW;
norns_error_t nornsctl_unregister_namespace(const char* nsid) __THROW;

/* Return a string describing the error number */
char* norns_strerror(norns_error_t errnum) __THROW;
+9 −9
Original line number Diff line number Diff line
@@ -120,13 +120,13 @@ libnornsctl_reload_config_file(void) {

/* Control API */
norns_error_t
norns_ping() {
nornsctl_ping() {
    return send_ping_request();
}

/* Register and describe a batch job */
norns_error_t 
norns_register_job(uint32_t jobid, norns_job_t* job) {
nornsctl_register_job(uint32_t jobid, norns_job_t* job) {

    if(!validate_job(job)) {
        return NORNS_EBADARGS;
@@ -137,7 +137,7 @@ norns_register_job(uint32_t jobid, norns_job_t* job) {

/* Update an existing batch job */
norns_error_t 
norns_update_job(uint32_t jobid, norns_job_t* job) {
nornsctl_update_job(uint32_t jobid, norns_job_t* job) {

    if(!validate_job(job)) {
        return NORNS_EBADARGS;
@@ -149,27 +149,27 @@ norns_update_job(uint32_t jobid, norns_job_t* job) {

/* Remove a batch job from the system */
norns_error_t 
norns_unregister_job(uint32_t jobid) {
nornsctl_unregister_job(uint32_t jobid) {
    return send_job_request(NORNS_JOB_UNREGISTER, jobid, NULL);
}


/* Add a process to a registered batch job */
norns_error_t 
norns_add_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) {
nornsctl_add_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) {
    return send_process_request(NORNS_PROCESS_ADD, jobid, uid, gid, pid);
}


/* Remove a process from a registered batch job */
norns_error_t 
norns_remove_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) {
nornsctl_remove_process(uint32_t jobid, uid_t uid, gid_t gid, pid_t pid) {
    return send_process_request(NORNS_PROCESS_REMOVE, jobid, uid, gid, pid);
}

/* Register a namespace in the local norns server */
norns_error_t 
norns_register_namespace(const char* nsid, norns_backend_t* backend) {
nornsctl_register_namespace(const char* nsid, norns_backend_t* backend) {

    if(nsid == NULL || (strncmp(nsid, "", 1) == 0) || 
       !validate_namespace(backend)) {
@@ -181,7 +181,7 @@ norns_register_namespace(const char* nsid, norns_backend_t* backend) {

/* Update a namespace in the local norns server */
norns_error_t 
norns_update_namespace(const char* nsid, norns_backend_t* backend) {
nornsctl_update_namespace(const char* nsid, norns_backend_t* backend) {

    return NORNS_ENOTSUPPORTED;

@@ -193,7 +193,7 @@ norns_update_namespace(const char* nsid, norns_backend_t* backend) {

/* Unregister a namespace from the local norns server */
norns_error_t 
norns_unregister_namespace(const char* nsid) {
nornsctl_unregister_namespace(const char* nsid) {

    if(nsid == NULL) {
        return NORNS_EBADARGS;
+4 −4
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
#include "test-env.hpp"
#include "catch.hpp"

SCENARIO("register job", "[api::norns_register_job]") {
SCENARIO("register job", "[api::nornsctl_register_job]") {
    GIVEN("a running urd instance") {

        test_env env;
@@ -41,7 +41,7 @@ SCENARIO("register job", "[api::norns_register_job]") {

            const uint32_t jobid = 42;

            int rv = norns_register_job(jobid, &job);
            int rv = nornsctl_register_job(jobid, &job);

            THEN("NORNS_EBADARGS is returned") {
                REQUIRE(rv == NORNS_EBADARGS);
@@ -65,7 +65,7 @@ SCENARIO("register job", "[api::norns_register_job]") {

            const uint32_t jobid = 42;

            int rv = norns_register_job(jobid, &job);
            int rv = nornsctl_register_job(jobid, &job);

            THEN("NORNS_SUCCESS is returned") {
                REQUIRE(rv == NORNS_SUCCESS);
@@ -94,7 +94,7 @@ SCENARIO("register job", "[api::norns_register_job]") {

            const uint32_t jobid = 42;

            int rv = norns_register_job(jobid, &job);
            int rv = nornsctl_register_job(jobid, &job);

            THEN("NORNS_ECONNFAILED is returned") {
                REQUIRE(rv == NORNS_ECONNFAILED);
+10 −10
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
#include "test-env.hpp"
#include "catch.hpp"

SCENARIO("unregister job", "[api::norns_unregister_job]") {
SCENARIO("unregister job", "[api::nornsctl_unregister_job]") {
    GIVEN("a running urd instance") {

        test_env env;
@@ -39,7 +39,7 @@ SCENARIO("unregister job", "[api::norns_unregister_job]") {

            const uint32_t jobid = 42;

            int rv = norns_unregister_job(jobid);
            int rv = nornsctl_unregister_job(jobid);

            THEN("NORNS_ENOSUCHJOB is returned") {
                REQUIRE(rv == NORNS_ENOSUCHJOB);
@@ -48,7 +48,7 @@ SCENARIO("unregister job", "[api::norns_unregister_job]") {

        WHEN("a registered job is unregistered") {

            /* valid information for norns_register_job */
            /* valid information for nornsctl_register_job */
            const char* test_hosts[] = { "host00", "host01" };
            const size_t test_nhosts = sizeof(test_hosts) / sizeof(test_hosts[0]);

@@ -62,11 +62,11 @@ SCENARIO("unregister job", "[api::norns_unregister_job]") {
            norns_job_t job = NORNS_JOB(test_hosts, test_nhosts, test_lims, test_nlims);
            const uint32_t jobid = 42;

            int rv = norns_register_job(jobid, &job);
            int rv = nornsctl_register_job(jobid, &job);

            REQUIRE(rv == NORNS_SUCCESS);

            rv = norns_unregister_job(jobid);
            rv = nornsctl_unregister_job(jobid);

            THEN("NORNS_SUCCESS is returned") {
                REQUIRE(rv == NORNS_SUCCESS);
@@ -75,7 +75,7 @@ SCENARIO("unregister job", "[api::norns_unregister_job]") {

        WHEN("a registered job is updated and unregistered") {

            /* valid information for norns_register_job */
            /* valid information for nornsctl_register_job */
            const char* test_hosts1[] = { "host00", "host01" };
            const char* test_hosts2[] = { "host02", "host03", "host04" };
            const size_t test_nhosts1 = sizeof(test_hosts1) / sizeof(test_hosts1[0]);
@@ -95,15 +95,15 @@ SCENARIO("unregister job", "[api::norns_unregister_job]") {
            norns_job_t job2 = NORNS_JOB(test_hosts2, test_nhosts2, test_backends2, test_nbackends2);
            const uint32_t jobid = 42;

            int rv = norns_register_job(jobid, &job1);
            int rv = nornsctl_register_job(jobid, &job1);

            REQUIRE(rv == NORNS_SUCCESS);

            rv = norns_update_job(jobid, &job2);
            rv = nornsctl_update_job(jobid, &job2);

            REQUIRE(rv == NORNS_SUCCESS);

            rv = norns_unregister_job(jobid);
            rv = nornsctl_unregister_job(jobid);

            THEN("NORNS_SUCCESS is returned") {
                REQUIRE(rv == NORNS_SUCCESS);
@@ -119,7 +119,7 @@ SCENARIO("unregister job", "[api::norns_unregister_job]") {

            const uint32_t jobid = 42;

            int rv = norns_unregister_job(jobid);
            int rv = nornsctl_unregister_job(jobid);

            THEN("NORNS_ECONNFAILED is returned") {
                REQUIRE(rv == NORNS_ECONNFAILED);
+10 −10
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
#include "test-env.hpp"
#include "catch.hpp"

SCENARIO("update job", "[api::norns_update_job]") {
SCENARIO("update job", "[api::nornsctl_update_job]") {
    GIVEN("a running urd instance") {

        test_env env;
@@ -40,7 +40,7 @@ SCENARIO("update job", "[api::norns_update_job]") {
            norns_job_t job = NORNS_JOB(NULL, 0, NULL, 0);
            const uint32_t jobid = 42;

            int rv = norns_update_job(jobid, &job);
            int rv = nornsctl_update_job(jobid, &job);

            THEN("NORNS_EBADARGS is returned") {
                REQUIRE(rv == NORNS_EBADARGS);
@@ -62,7 +62,7 @@ SCENARIO("update job", "[api::norns_update_job]") {
            norns_job_t job = NORNS_JOB(test_hosts, test_nhosts, test_lims, test_nlims);
            const uint32_t jobid = 42;

            int rv = norns_update_job(jobid, &job);
            int rv = nornsctl_update_job(jobid, &job);

            THEN("NORNS_ENOSUCHJOB is returned") {
                REQUIRE(rv == NORNS_ENOSUCHJOB);
@@ -71,7 +71,7 @@ SCENARIO("update job", "[api::norns_update_job]") {

        WHEN("a registered job is updated with invalid information") {

            /* valid information for norns_register_job */
            /* valid information for nornsctl_register_job */
            const char* test_hosts[] = { "host00", "host01" };
            const size_t test_nhosts = sizeof(test_hosts) / sizeof(test_hosts[0]);

@@ -86,11 +86,11 @@ SCENARIO("update job", "[api::norns_update_job]") {
            norns_job_t job2 = NORNS_JOB(NULL, 0, NULL, 0);
            const uint32_t jobid = 42;

            int rv = norns_register_job(jobid, &job1);
            int rv = nornsctl_register_job(jobid, &job1);

            REQUIRE(rv == NORNS_SUCCESS);

            rv = norns_update_job(jobid, &job2);
            rv = nornsctl_update_job(jobid, &job2);

            THEN("NORNS_EBADARGS is returned") {
                REQUIRE(rv == NORNS_EBADARGS);
@@ -99,7 +99,7 @@ SCENARIO("update job", "[api::norns_update_job]") {

        WHEN("a registered job is updated with valid information") {

            /* valid information for norns_register_job */
            /* valid information for nornsctl_register_job */
            const char* test_hosts1[] = { "host00", "host01" };
            const char* test_hosts2[] = { "host02", "host03", "host04" };
            const size_t test_nhosts1 = sizeof(test_hosts1) / sizeof(test_hosts1[0]);
@@ -119,11 +119,11 @@ SCENARIO("update job", "[api::norns_update_job]") {
            norns_job_t job2 = NORNS_JOB(test_hosts2, test_nhosts2, test_backends2, test_nbackends2);
            const uint32_t jobid = 42;

            int rv = norns_register_job(jobid, &job1);
            int rv = nornsctl_register_job(jobid, &job1);

            REQUIRE(rv == NORNS_SUCCESS);

            rv = norns_update_job(jobid, &job2);
            rv = nornsctl_update_job(jobid, &job2);

            THEN("NORNS_SUCCESS is returned") {
                REQUIRE(rv == NORNS_SUCCESS);
@@ -152,7 +152,7 @@ SCENARIO("update job", "[api::norns_update_job]") {

            const uint32_t jobid = 42;

            int rv = norns_update_job(jobid, &job);
            int rv = nornsctl_update_job(jobid, &job);

            THEN("NORNS_ECONNFAILED is returned") {
                REQUIRE(rv == NORNS_ECONNFAILED);
Loading