Commit 515d0124 authored by Greg Williams's avatar Greg Williams
Browse files

Adding kinetic_admin_client for admin/setup operations

parent 547b7b27
Loading
Loading
Loading
Loading
+58 −62
Original line number Diff line number Diff line
@@ -13,8 +13,9 @@ PUB_INC = ./include
CC ?= gcc
OPTIMIZE = -O3
SYSTEM_TEST_HOST ?= \"localhost\"
CLUSTER_VERSION ?= 0
WARN = -Wall -Wextra -Wstrict-prototypes -Wcast-align -pedantic -Wno-missing-field-initializers -Werror=strict-prototypes
CDEFS += -D_POSIX_C_SOURCE=199309L -D_C99_SOURCE=1 -DSYSTEM_TEST_HOST=${SYSTEM_TEST_HOST}
CDEFS += -D_POSIX_C_SOURCE=199309L -D_C99_SOURCE=1 -DSYSTEM_TEST_HOST=\"${SYSTEM_TEST_HOST}\" -DCLUSTER_VERSION=${CLUSTER_VERSION}
CFLAGS += -std=c99 -fPIC -g $(WARN) $(CDEFS) $(OPTIMIZE)
LDFLAGS += -lm -lcrypto -lssl -lpthread

@@ -23,17 +24,14 @@ LDFLAGS += -lm -lcrypto -lssl -lpthread
#===============================================================================

PROJECT = kinetic-c-client

PREFIX ?= /usr/local
LIBDIR ?= /lib

LIB_DIR = ./src/lib
VENDOR = ./vendor
PROTOBUFC = $(VENDOR)/protobuf-c
SOCKET99 = $(VENDOR)/socket99
VERSION_FILE = ./config/VERSION
VERSION = ${shell head -n1 $(VERSION_FILE)}

KINETIC_LIB_NAME = $(PROJECT).$(VERSION)
KINETIC_LIB = $(BIN_DIR)/lib$(KINETIC_LIB_NAME).a
LIB_INCS = -I$(LIB_DIR) -I$(PUB_INC) -I$(PROTOBUFC) -I$(SOCKET99) -I$(VENDOR)
@@ -63,10 +61,11 @@ LIB_OBJS = \

KINETIC_LIB_OTHER_DEPS = Makefile Rakefile $(VERSION_FILE)


default: makedirs $(KINETIC_LIB)

makedirs:
	@echo; mkdir -p ./bin/examples &> /dev/null; mkdir -p ./bin/systest &> /dev/null; mkdir -p ./out &> /dev/null
	@echo; mkdir -p ./bin/examples &> /dev/null; mkdir -p ./bin/unit &> /dev/null; mkdir -p ./bin/systest &> /dev/null; mkdir -p ./out &> /dev/null

all: default test system_tests run examples

@@ -112,24 +111,6 @@ ci: uninstall all install
	@echo


#-------------------------------------------------------------------------------
# Test Support
#-------------------------------------------------------------------------------

test: Rakefile $(LIB_OBJS)
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Testing $(PROJECT)
	@echo --------------------------------------------------------------------------------
	bundle install
	bundle exec rake test_all

JAVA_HOME ?= /usr
JAVA_BIN = $(JAVA_HOME)/bin/java

.PHONY: test


#-------------------------------------------------------------------------------
# Static and Dynamic Library Build Support
#-------------------------------------------------------------------------------
@@ -207,6 +188,57 @@ stop_simulator:
.PHONY: update_simulator erase_simulator stop_simulator


#===============================================================================
# Unity Test Framework Support
#===============================================================================
UNITY_INC = ./vendor/unity/src
UNITY_SRC = ./vendor/unity/src/unity.c

test: Rakefile $(LIB_OBJS)
	@echo
	@echo --------------------------------------------------------------------------------
	@echo Testing $(PROJECT)
	@echo --------------------------------------------------------------------------------
	bundle install
	bundle exec rake test_all


#===============================================================================
# CMock Tests
#===============================================================================

UNIT_SRC = ./test/unit
UNIT_OUT = $(BIN_DIR)/unit
UNIT_LDFLAGS += -lm -l ssl $(KINETIC_LIB) -l crypto -l pthread
UNIT_WARN = -Wall -Wextra -Wstrict-prototypes -pedantic -Wno-missing-field-initializers -Werror=strict-prototypes
UNIT_CFLAGS += -std=c99 -fPIC -g $(UNIT_WARN) $(CDEFS) $(OPTIMIZE) -DTEST

unit_sources = $(wildcard $(UNIT_SRC)/*.c)
unit_executables = $(patsubst $(UNIT_SRC)/%.c,$(UNIT_OUT)/run_%,$(unit_sources))
unit_results = $(patsubst $(UNIT_OUT)/run_%,$(UNIT_OUT)/%.log,$(unit_executables))
unit_passfiles = $(patsubst $(UNIT_OUT)/run_%,$(UNIT_OUT)/%.testpass,$(unit_executables))
unit_names = $(patsubst $(UNIT_OUT)/run_%,%,$(unit_executables))

list_unit_tests:
	echo $(unit_names)

$(UNIT_OUT)/%_runner.c: $(UNIT_SRC)/%.c
	./test/support/generate_unit_runner.sh $< > $@

$(UNIT_OUT)/run_%: $(UNIT_SRC)/%.c $(UNIT_OUT)/%_runner.c $(KINETIC_LIB)
	@echo
	@echo ================================================================================
	@echo System test: '$<'
	@echo --------------------------------------------------------------------------------
	$(CC) -o $@ $< $(word 2,$^) ./test/support/unit_unit_fixture.c $(UNITY_SRC) $(UNIT_CFLAGS) $(LIB_INCS) -I$(UNITY_INC) -I./test/support $(UNIT_LDFLAGS) $(KINETIC_LIB)

$(UNIT_OUT)/%.testpass : $(UNIT_OUT)/run_%
	./scripts/runSystemTest.sh $*

$(unit_names) : % : $(UNIT_OUT)/%.testpass

unit_tests: start_simulator $(unit_passfiles)


#===============================================================================
# System Tests
@@ -217,8 +249,6 @@ SYSTEST_OUT = $(BIN_DIR)/systest
SYSTEST_LDFLAGS += -lm -l ssl $(KINETIC_LIB) -l crypto -l pthread
SYSTEST_WARN = -Wall -Wextra -Wstrict-prototypes -pedantic -Wno-missing-field-initializers -Werror=strict-prototypes
SYSTEST_CFLAGS += -std=c99 -fPIC -g $(SYSTEST_WARN) $(CDEFS) $(OPTIMIZE) -DTEST
UNITY_INC = ./vendor/unity/src
UNITY_SRC = ./vendor/unity/src/unity.c

systest_sources = $(wildcard $(SYSTEST_SRC)/*.c)
systest_executables = $(patsubst $(SYSTEST_SRC)/%.c,$(SYSTEST_OUT)/run_%,$(systest_sources))
@@ -243,22 +273,8 @@ $(SYSTEST_OUT)/%.testpass : $(SYSTEST_OUT)/run_%
	./scripts/runSystemTest.sh $*

$(systest_names) : % : $(SYSTEST_OUT)/%.testpass

# system_tests: start_simulator $(systest_results)
system_tests: start_simulator $(systest_passfiles)


# run_systest_%: $(SYSTEST_OUT)/%
# 	@echo
# 	@echo ================================================================================
# 	@echo Executing system test: '$<'
# 	@echo --------------------------------------------------------------------------------;
# 	$<
# 	@echo ================================================================================
# 	@echo
# 	./vendor/kinetic-simulator/stopSimulator.sh
# run_systest_%: start_simulator

# valgrind_systest_%: $(SYSTEST_OUT)/%
# 	@echo
# 	@echo ================================================================================
@@ -268,27 +284,6 @@ system_tests: start_simulator $(systest_passfiles)
# 	@echo ================================================================================
# 	@echo

# setup_system_tests: $(systest_executables) \
# 	build_system_tests

# system_tests: setup_system_tests \
# 	start_simulator \
# 	run_example_write_file_blocking \
# 	run_example_write_file_blocking_threads \
# 	run_example_write_file_nonblocking \
# 	run_example_write_file_nonblocking_threads \
# 	stop_simulator

# valgrind_system_tests: setup_system_tests \
# 	start_simulator \
# 	valgrind_example_write_file_blocking \
# 	valgrind_example_write_file_blocking_threads \
# 	valgrind_example_write_file_nonblocking \
# 	valgrind_example_write_file_nonblocking_threads \
# 	stop_simulator




#===============================================================================
# Test Utility Build Support
@@ -319,6 +314,8 @@ build: $(KINETIC_LIB) $(KINETIC_SO_DEV) utility
# Support for Simulator and Exection of Test Utility
#-------------------------------------------------------------------------------
# JAVA=$(JAVA_HOME)/bin/java
JAVA_HOME ?= /usr
JAVA_BIN = $(JAVA_HOME)/bin/java
SIM_JARS_PREFIX = vendor/kinetic-java/kinetic-simulator-0.7.0.2-kinetic-proto-2.0.6-SNAPSHOT
CLASSPATH = $(JAVA_HOME)/lib/tools.jar:$(SIM_JARS_PREFIX)-jar-with-dependencies.jar:$(SIM_JARS_PREFIX)-sources.jar:$(SIM_JARS_PREFIX).jar
SIM_RUNNER = com.seagate.kinetic.simulator.internal.SimulatorRunner
@@ -337,6 +334,7 @@ run: $(UTIL_EXEC) start_simulator
	@echo Test Utility integration tests w/ kinetic-c lib passed!
	@echo


#===============================================================================
# Standalone Example Executables
#===============================================================================
@@ -344,8 +342,6 @@ run: $(UTIL_EXEC) start_simulator
EXAMPLE_SRC = ./src/examples
EXAMPLE_LDFLAGS += -lm -l ssl $(KINETIC_LIB) -l crypto -l pthread
EXAMPLES = write_file_blocking
VALGRIND = valgrind
VALGRIND_ARGS = --track-origins=yes #--leak-check=full

example_sources = $(wildcard $(EXAMPLE_SRC)/*.c)
example_executables = $(patsubst $(EXAMPLE_SRC)/%.c,$(BIN_DIR)/examples/%,$(example_sources))
+18 −0
Original line number Diff line number Diff line
* > yum update
* > yum install gcc kernel-devel vim emacs clang curl net-tools tcpdump git java python lua ruby rubygems bundler openssl openssl-devel valgrind doxygen
* > visudo # enable 'wheel' group and add greg/job/scott to root access
* > useradd --groups wheel greg
* > useradd --groups wheel job
* > useradd --groups wheel scott
* > mkdir git
* > cd git
* > git clone --recursive git@github.com:Seagate/kinetic-c.git
* > cd kinetic-c
* > git checkout develop
* > git pull
* > git submodule update --init
* > gem install bundler
* > bundle install
* > make
* > make clean
* > make all
+0 −1
Original line number Diff line number Diff line
@@ -36,7 +36,6 @@
:defines:
  :commmon: &common_defines
    - TEST
    - SYSTEM_TEST_HOST=\"<%= ENV.fetch('SYSTEM_TEST_HOST', 'localhost') %>\"
  :test:
    - *common_defines
  :test_preprocess:
+126 −0
Original line number Diff line number Diff line
/*
* kinetic-c
* Copyright (C) 2014 Seagate Technology.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#ifndef _KINETIC_ADMIN_CLIENT_H
#define _KINETIC_ADMIN_CLIENT_H

#include "kinetic_types.h"

/**
 * Initializes the Kinetic API and configures logging destination.
 *
 * @param log_file (path to log file, 'stdout' to log to STDOUT, NULL to disable logging)
 * @param log_level Logging level (-1:none, 0:error, 1:info, 2:verbose, 3:full)
 */
void KineticAdminClient_Init(const char* log_file, int log_level);

/**
 * @brief Performs shutdown/cleanup of the kinetic-c client lib
 */
void KineticAdminClient_Shutdown(void);

/**
 * @brief Initializes the Kinetic API, configures logging destination, establishes a
 * connection to the specified Kinetic Device, and establishes a session.
 *
 * @param session   Configured KineticSession to connect
 *  .config           `KineticSessionConfig` structure which must be configured
 *                    by the client prior to creating the device connection.
 *    .host             Host name or IP address to connect to
 *    .port             Port to establish socket connection on
 *    .clusterVersion   Cluster version to use for the session
 *    .identity         Identity to use for the session
 *    .hmacKey          Key to use for HMAC calculations (NULL-terminated string)
 *  .connection     Pointer to dynamically allocated connection which will be
 *                  populated upon establishment of a connection.
 *
 * @return          Returns the resulting `KineticStatus`, and `session->connection`
 *                  will be populated with a session instance pointer upon success.
 *                  The client should call KineticAdminClient_DestroyConnection() in
 *                  order to shutdown a connection and cleanup resources when
 *                  done using a KineticSession.
 */
KineticStatus KineticAdminClient_CreateConnection(KineticSession * const session);

/**
 * @brief Closes the connection to a host.
 *
 * @param session   The connected `KineticSession` to close. The connection
 *                  instance will be freed by this call after closing the
 *                  connection.
 *
 * @return          Returns the resulting KineticStatus.
 */
KineticStatus KineticAdminClient_DestroyConnection(KineticSession * const session);

/**
 * @brief Executes a GETLOG command to retrieve specific configuration and/or
 * operational data from the Kinetic Device.
 *
 * @param session       The connected KineticSession to use for the operation
 * @param type          KineticLogDataType specifying data type to retrieve.
 * @param info          KineticDeviceInfo pointer, which will be assigned to
 *                      a dynamically allocated structure populated with
 *                      the requested data, if successful. The client should
 *                      call free() on this pointer in order to free the root
 *                      and any nested structures.
 * @param closure       Optional closure. If specified, operation will be
 *                      executed in asynchronous mode, and closure callback
 *                      will be called upon completion in another thread.
 *
 * @return              Returns 0 upon success, -1 or the Kinetic status code
 *                      upon failure
 */
KineticStatus KineticAdminClient_GetLog(KineticSession const * const session,
                                   KineticDeviceInfo_Type type,
                                   KineticDeviceInfo** info,
                                   KineticCompletionClosure* closure);

// def setClusterVersion(self, *args, **kwargs):

// def updateFirmware(self, *args, **kwargs):

// @withPin @requiresSsl
// def unlock(self, *args, **kwargs):

// @withPin @requiresSsl
// def lock(self, *args, **kwargs):

// @withPin @requiresSsl
// def erase(self, *args, **kwargs):

// @withPin @requiresSsl
// def instantSecureErase(self, *args, **kwargs):

// @requiresSsl
// Set the access control lists to lock users out of different permissions.
// Arguments: aclList -> A list of ACL (Access Control List) objects.
// def setSecurity(self, *args, **kwargs):

/**
 * @brief Executes an InstantSecureErase command to erase all data from the Kinetic device.
 *
 * @param session       The connected KineticSession to use for the operation.
 *
 * @return              Returns the resulting KineticStatus.
 */
KineticStatus KineticAdminClient_InstantSecureErase(KineticSession const * const session);

#endif // _KINETIC_ADMIN_CLIENT_H
+0 −32
Original line number Diff line number Diff line
@@ -199,29 +199,6 @@ KineticStatus KineticClient_GetKeyRange(KineticSession const * const session,
                                        KineticKeyRange* range, ByteBufferArray* keys,
                                        KineticCompletionClosure* closure);

/**
 * @brief Executes a GETLOG command to retrieve specific configuration and/or
 * operational data from the Kinetic Device.
 *
 * @param session       The connected KineticSession to use for the operation
 * @param type          KineticLogDataType specifying data type to retrieve.
 * @param info          KineticDeviceInfo pointer, which will be assigned to
 *                      a dynamically allocated structure populated with
 *                      the requested data, if successful. The client should
 *                      call free() on this pointer in order to free the root
 *                      and any nested structures.
 * @param closure       Optional closure. If specified, operation will be
 *                      executed in asynchronous mode, and closure callback
 *                      will be called upon completion in another thread.
 *
 * @return              Returns 0 upon success, -1 or the Kinetic status code
 *                      upon failure
 */
KineticStatus KineticClient_GetLog(KineticSession const * const session,
                                   KineticDeviceInfo_Type type,
                                   KineticDeviceInfo** info,
                                   KineticCompletionClosure* closure);

/**
 * @brief Executes a PEER2PEERPUSH operation allows a client to instruct a Kinetic
 * Device to copy a set of keys (and associated value and metadata) to another
@@ -246,13 +223,4 @@ KineticStatus KineticClient_P2POperation(KineticSession const * const session,
                                         KineticP2P_Operation* const p2pOp,
                                         KineticCompletionClosure* closure);

/**
 * @brief Executes an InstantSecureErase command to erase all data from the Kinetic device.
 *
 * @param session       The connected KineticSession to use for the operation.
 *
 * @return              Returns the resulting KineticStatus.
 */
KineticStatus KineticClient_InstantSecureErase(KineticSession const * const session);

#endif // _KINETIC_CLIENT_H
Loading