Code Monkey home page Code Monkey logo

huawei-utool's Introduction

utool

HUAWEI utool

HUAWEI utool is a C99 client library that manges HUAWEI servers using iBMC REST APIs.

pre-requirements

utool is based on C99 and built with cmake. So, the compile ENV should have:

  • git
  • CMake>=3.5.0
  • C Compiler
  • OpenSSL(required by libcurl)
  • ipmitool

Compilation

Get source code

please make sure git is ready in your ENV. Clone process may cause a long time according to your network situation.

cd ${your-workspace}
git clone https://github.com/IamFive/huawei-utool.git utool
cd utool

Build curl

The CURL version required is >=7.56.0, the third-party/curl provide along with source code is curl-7_65_0. Please make sure libssl-dev and libssh2-dev is ready before making CURL (the dev package name maybe different in your ENV).

  1. To install libssl-dev
  • ubuntu: sudo apt install libssl-dev
  • RedHat: sudo yum install openssl-devel
  1. To install libssh2-dev
  • ubuntu: sudo apt install libssh2-*-dev
  • RedHat: sudo yum install libssh2-devel
  1. Build CURL
cd ${your-workspace}/utool
cd third-party/curl
./buildconf
./configure --with-ssl --with-libssh2
make

Build Utool

Using cmake to build utool, after make utool-bin script will be generated under build folder.

cd ${workspace}/utool
rm -rf build && mkdir -p build
cd build
cmake .. && make

Install utool

After make done, run sudo make install to install utool to current system.

cd ${workspace}/utool/build
sudo make install

Remember, before using utool, you should make sure libcurl>=7.56.0 has been installed. You can install libcurl through package manager like apt-get, yum or through:

cd ${your-workspace}/utool/third-party/curl
./buildconf
./configure --with-ssl --with-libssh2
make 
sudo make install

After install,

  • utool bin script will be install to /usr/local/bin
  • utool bin script will be install to ${your-workspace}/bin
  • utool lib will be install to /usr/local/lib
  • utool lib will be install to ${your-workspace}/lib
  • utool static lib will be install to /usr/local/lib
  • utool static lib will be install to ${your-workspace}/lib

Try Utool

$ cd ${workspace}/utool/build
$ ./utool-bin --version
{
	"State":	"Success",
	"Message":	["HUAWEI server management command-line tool version v1.0.2"]
}

C99 Example

#include <utool.h>
#include <stdio.h>

int main(int argc, char **argv)
{
char *result = NULL;
char *argv2[] = {
"utool",
"-H", "your-ibmc-host",
"-U", "your-ibmc-username",
"-P", "your-ibmc-password",
"getproduct",
NULL
};

int argc2 = sizeof(argv2) / sizeof(char *);
int ret = utool_main(argc2 - 1, (void *) argv2, &result);
if (result != NULL) {
fprintf(ret == 0 ? stdout : stderr, "%s", result);
free(result);
}
return ret;
}

or

#include <stdio.h>

extern int utool_main(int argc, char *argv[], char **result);

int main(int argc, char **argv)
{
char *result = NULL;
char *argv2[] = {
"utool",
"-H", "your-ibmc-host",
"-U", "your-ibmc-username",
"-P", "your-ibmc-password",
"getproduct",
NULL
};

int argc2 = sizeof(argv2) / sizeof(char *);
int ret = utool_main(argc2 - 1, (void *) argv2, &result);
if (result != NULL) {
fprintf(ret == 0 ? stdout : stderr, "%s", result);
free(result);
}
return ret;
}

reference

huawei-utool's People

Contributors

iamfive avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.