OPENSTACK-API Development

Source: Internet
Author: User
Tags cloud computing platforms

Introduction of two Openstack-api (Java edition)--jcoulds && openstack4j

Jclouds1. Introduction

Jclouds-This API provides a portable abstraction layer for cloud computing environments and cloud specification features that support cloud computing platforms such as Amazon, VMWare, Azure, and OpenStack, which are currently supported for OpenStack, Nova, Cinder, API interfaces such as glance, Neutron, Keystone, and Swift, but Ceilometer API interfaces are not supported.

2. Use with the JAR package

Official documents-Highly recommended
http://jclouds.apache.org/guides/openstack/

Jcloudsjar package use maven install download management can;

3. For example
Importcom. Google. Common. Collect. Immutableset;Importcom. Google. Common. IO. Closeables;Importcom. Google. Inject. Module;import org. Jclouds. Contextbuilder;import org. Jclouds. Logging. SLF4j. config. SLF4JLoggingModule;import org. Jclouds. OpenStack. Nova. V2_0. Novaapi;import org. Jclouds. OpenStack. Nova. V2_0. Domain. Server;import org. Jclouds. OpenStack. Nova. V2_0. Features. Serverapi;Import Java. IO. Closeable;Import Java. IO. IOException;Import Java. Util. Set;public class Jcloudsnova implements closeable {private final Novaapi Novaapi;Private finalSet<String> regions;public static void Main (string[] args) throws IOException {Jcloudsnova Jcloudsnova = new Jcloudsnova ();try {Jcloudsnova. Listservers();Jcloudsnova. Close();} catch (Exception e) {E. Printstacktrace();} finally {Jcloudsnova. Close();}} public Jcloudsnova () {iterable<module> modules = immutableset.<module>of (new Slf4jloggingmod Ule ());String Provider ="Openstack-nova";String identity ="Demo:demo";//Project Administrators and usersString credential ="Devstack";//user PasswordNovaapi = Contextbuilder. Newbuilder(provider). Endpoint("http://xxx.xxx.xxx.xxx:5000/v2.0/")//api Address. Credentials(Identity, credential). Modules(modules). Buildapi(Novaapi. Class);Regions = Novaapi. Getconfiguredregions();private void Listservers () {for (String region:regions) {Serverapi Serverapi = Novaapi. Getserverapi(region);System. out. println("Servers in"+ region);for (Server Server:serverapi. Listindetail(). Concat()) {System. out. println("  "+ server);}}} public void Close () throws IOException {Closeables. Close(Novaapi, True);}}
4. Test results:

More stable, and API documentation is full, teach good understanding;

Openstack4j1. Introduction

Web-api for OpenStack, including Keystone, Nova, Neutron, Glance, Cinder
, Swift, Ceilometer, Heat API support, update fast, there is a problem need to contact GitHub in a timely manner can be resolved.

2. Use with the JAR package

Official Document--http://www.openstack4j.com/learn/
http://www.openstack4j.com/javadoc/
Openstack4j-jar package using the provided Openstack4j-2.0.1-withdeps-sources.jar can be, note that the use of the best JDK is more than 1.7, jdk1.7 best. Java EE 5 or Java EE 6 are available. (with MyEclipse, the JDK version is 1.6, which makes it easy to report version 51 errors.) )

3. For example:
List<string> openstacknetworklist=new arraylist<string> ();Openstacknetworklist. Add("Df6effa2-a1b5-400a-8ab1-457673591aa1");String Openstackimageid =""String openstackflavorid="";String Openstackservername ="";String Openstackzone ="Nova:compute2";Servercreate sc = Builders. Server(). Name(Openstackservername). Flavor(Openstackflavorid). Image(Openstackimageid). Networks(openstacknetworklist). Availabilityzone(Openstackzone). Build();Boot the Server osclient os = osfactory. Builder(). Endpoint("http://x.x.x.x:5000/v2.0/"). Credentials("XXX","XXX"). Tenantname("XXX"). Authenticate();Server server = OS. Compute(). Servers(). Boot(SC);
4. Use effect

API is easy to use, and supports ceilometer and heat, recommended.

Openstack-api Development

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.