Erlang wrapper around Libcloud.
It was tested with the 21a0d069d0a138ab42ce4403ab553c7fc3e4bbb6 commit of the Libcloud repository.
Install Python 3. It is recommended to use virtualenv.
Install Libcloud from Libcloud repository:
$ git clone git@github.com:apache/libcloud.git
$ 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 git@github.com:esl/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.
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 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
andMy_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">>}]).
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
I cannot use elibcloud on Mac OS X because I get the "No CA Certificates were found in CA_CERTS_PATH" run-time error. How can I solve this?
On Mac OS X, I have fixed this by installing curl-ca-bundle
. You can install it using brew
.
brew install curl-ca-bundle