Giter VIP home page Giter VIP logo

elibcloud's Introduction

elibcloud

Erlang wrapper around Libcloud.

It was tested with the 4da5771708b185725f26e60287e554b0416e8030 commit of the hcs42/libcloud.

Installation

Install Python 3. It is recommended to use virtualenv.

Install Libcloud:

$ git clone https://github.com/hcs42/libcloud.git
$ git checkout 4da5771708b185725f26e60287e554b0416e8030
$ cd libcloud
$ pip install -e .

When starting your Erlang node, make sure that the first python3 executable in the PATH is the same as the one that has Libcloud installed.

Clone elibcloud and start it from the shell:

$ git clone https://github.com/hcs42/elibcloud.git
$ cd elibcloud
$ make
$ erl -pa ../elibcloud/ebin -pa deps/goldrush/ebin -pa deps/jsx/ebin -pa deps/lager/ebin
> application:start(syntax_tools).
> application:start(compiler).
> application:start(goldrush).
> application:start(lager).

Try elibcloud with a DUMMY provider, which will print the details of a dummy node:

1> {ok, Cred} = elibcloud:create_credentials(
                      _Provider = "DUMMY",
                      _UserName = "something",
                      _Password = "something").
{ok,[{<<"provider">>,<<"DUMMY">>},
     {<<"userName">>,<<"something">>},
     {<<"password">>,<<"something">>},
     {<<"extra">>,[{}]}]}

2> elibcloud:list_nodes(Cred).
{ok,[[{<<"state">>,<<"RUNNING">>},
      {<<"image">>,null},
      {<<"public_ips">>,[<<"127.0.0.1">>]},
      {<<"size">>,null},
      {<<"id">>,<<"1">>},
      {<<"private_ips">>,[]},
      {<<"extra">>,[{<<"foo">>,<<"bar">>}]},
      {<<"name">>,<<"dummy-1">>}],
     [{<<"state">>,<<"RUNNING">>},
      {<<"image">>,null},
      {<<"public_ips">>,[<<"127.0.0.1">>]},
      {<<"size">>,null},
      {<<"id">>,<<"2">>},
      {<<"private_ips">>,[]},
      {<<"extra">>,[{<<"foo">>,<<"bar">>}]},
      {<<"name">>,<<"dummy-2">>}]]}

For using elibcloud in a project, you can add it as a rebar dependency.

Usage

To use elibcloud, first you need to create a "credentials" term which contains the details of your provider and account.

When you call a function that performs that operation, you then always pass the credentials term (e.g. by invoking list_nodes(Cred)).

Creating credentials

Creating Amazon EC2 credentials:

{ok, Cred} = elibcloud:create_credentials(
               _Provider = "EC2",
               _UserName = "My_Access_Key_ID",
               _Password = "My_Secret_Access_Key")
  • Replace My_Access_Key_ID and My_Secret_Access_Key with the API key and API code generated on the Amazon EC2 web dashboard: click on your user name, select Security Credentials, open Access Keys and use the keys there (or generate new ones).

Creating HP Cloud credentials:

{ok, Cred} = elibcloud:create_credentials(
               _Provider = "OPENSTACK_HP",
               _UserName = "My_username",
               _Password = "My_password",
               _Extra = [{<<"ex_force_auth_url">>, <<"https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens">>},
                         {<<"ex_force_auth_version">>, <<"2.0_password">>},
                         {<<"ex_tenant_name">>, <<"My_project_name">>},
                         {<<"ex_force_service_name">>, <<"Compute">>},
                         {<<"ex_force_service_region">>, <<"region-b.geo-1">>}]);
  • Replace My_project_name with the number in the URL after you log in to the HP Cloud dashboard.

Creating Rackspace credentials using the general OPENSTACK provider of Libcloud:

{ok, Cred} = elibcloud:create_credentials(
               _Provider = "OPENSTACK_RACKSPACE",
               _UserName = "My_username",
               _Password = "My_password",
               _Extra = [{<<"ex_force_auth_url">>, <<"https://lon.identity.api.rackspacecloud.com/v2.0/tokens">>},
                         {<<"ex_force_auth_version">>, <<"2.0_password">>},
                         {<<"ex_tenant_name">>, <<"My_tenant_name">>},
                         {<<"ex_force_service_name">>, <<"cloudServersOpenStack">>},
                         {<<"ex_force_service_region">>, <<"LON">>}]);
  • Replace My_tenant_name with the number in the URL after you log in to the Rackspace dashboard.

Creating Rackspace credentials using the RACKSPACE provider of Libcloud:

{ok, Cred} = elibcloud:create_credentials(
               _Provider = "RACKSPACE",
               _UserName = "My_username",
               _Password = "My_password",
               _Extra = [{<<"region">>, <<"lon">>}]).

Features

See the edoc documentation of the exported functions in src/elibcloud.erl for reference.

Supported providers:

  • Amazon EC2
  • HP Cloud
  • Rackspace

Nodes:

  • List nodes
  • Get node
  • Create node (i.e. provision a virtual machine instance)
  • Destroy node

Key pairs:

  • Get key pair
  • Import key pair from string/file
  • Delete key pair

Security groups:

  • List security groups
  • Create a security group
  • Delete a security group
  • Create security rules

elibcloud's People

Contributors

hcs42 avatar

Watchers

 avatar  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.