Skip to content

Commit ecbd9ed

Browse files
author
Jessica
committed
CLOUDSTACK-4334. Documentation for how to write an object store plugin.
1 parent 9a6f2de commit ecbd9ed

2 files changed

Lines changed: 126 additions & 0 deletions

File tree

‎docs/en-US/Developers_Guide.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
<xi:include href="whats-new.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
5151
<xi:include href="api-calls.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
5252
<xi:include href="working-with-usage-data.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
53+
<xi:include href="storage-plugins.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
5354
<xi:include href="working-with-documentation.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
5455
<xi:include href="tools.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
5556
<xi:include href="event-types.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />

‎docs/en-US/storage-plugins.xml‎

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?xml version='1.0' encoding='utf-8' ?>
2+
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "file:///C:/Program%20Files%20(x86)/Publican/DocBook_DTD/docbookx.dtd" [
3+
<!ENTITY % BOOK_ENTITIES SYSTEM "cloudstack.ent">
4+
%BOOK_ENTITIES;
5+
]>
6+
<chapter id="storage-plugins">
7+
<title>Writing a Storage Plugin</title>
8+
<para>This section gives an outline of how to implement a plugin
9+
to integrate a third-party storage provider.
10+
For details and an example, you will need to read the code.</para>
11+
<note>
12+
<para>Example code is available at:
13+
plugins/storage/volume/sample</para>
14+
</note>
15+
<para/>
16+
<para>Third party storage providers can integrate with &PRODUCT; to provide
17+
either primary storage or secondary storage.
18+
For example, &PRODUCT; provides plugins for
19+
Amazon Simple Storage Service (S3) or OpenStack
20+
Object Storage (Swift). Additional third party object storages can be integrated with &PRODUCT;
21+
by writing plugin software that uses the object storage plugin framework.
22+
Several new interfaces are available so that
23+
storage providers can develop vendor-specific plugins based on well-defined
24+
contracts that can be seamlessly managed by &PRODUCT;.</para>
25+
<para>Artifacts such as templates, ISOs and snapshots are kept in storage which &PRODUCT;
26+
refers to as secondary storage. To improve scalability and performance, as when a number
27+
of hosts access secondary storage concurrently, object storage can be used for secondary
28+
storage. Object storage can also provide built-in high availability capability. When using
29+
object storage, access to secondary storage data can be made available across multiple
30+
zones in a region. This is a huge benefit, as it is no longer necessary to copy templates,
31+
snapshots etc. across zones as would be needed in an environment
32+
using only zone-based NFS storage.</para>
33+
<para>The user enables a storage plugin through the UI.
34+
A new dialog box choice is offered to select the storage
35+
provider. Depending on the provider you select, additional input fields may appear so that
36+
you can provide the additional details required by that provider, such as a user name and
37+
password for a third-party storage account.
38+
</para>
39+
<section id="storage-plugin-steps">
40+
<title>Overview of How to Write a Storage Plugin</title>
41+
<para>To add a third-party storage option to &PRODUCT;, implement the following interfaces in Java:</para>
42+
<itemizedlist>
43+
<listitem><para>DataStoreDriver</para></listitem>
44+
<listitem><para>DataStoreLifecycle</para></listitem>
45+
<listitem><para>DataStoreProvider</para></listitem>
46+
<listitem><para>In addition to implementing the interfaces, you have to hardcode your plugin's required additional
47+
input fields into the code for the Add Secondary Storage
48+
or Add Primary Storage dialog box.</para></listitem>
49+
<listitem><para>Place your .jar file in plugins/storage/volume/ or plugins/storage/image/.</para></listitem>
50+
<listitem><para>Edit /client/tomcatconf/componentContext.xml.in.</para></listitem>
51+
<listitem><para>Edit client/pom.xml.</para></listitem>
52+
</itemizedlist>
53+
</section>
54+
<section id="datastoredriver">
55+
<title>Implementing DataStoreDriver</title>
56+
<para>DataStoreDriver contains the code that &PRODUCT; will use to provision the object store, when needed.</para>
57+
<para>You must implement the following methods:</para>
58+
<itemizedlist>
59+
<listitem><para>getTO()</para></listitem>
60+
<listitem><para>getStoreTO()</para></listitem>
61+
<listitem><para>createAsync()</para></listitem>
62+
<listitem><para>deleteAsync()</para></listitem>
63+
</itemizedlist>
64+
<para>The following methods are optional:</para>
65+
<itemizedlist>
66+
<listitem><para>resize()</para></listitem>
67+
<listitem><para>canCopy() is optional. If you set it to true, then you must implement copyAsync().</para></listitem>
68+
</itemizedlist>
69+
</section>
70+
<section id="datastorelifecycle">
71+
<title>Implementing DataStoreLifecycle</title>
72+
<para>DataStoreLifecycle contains the code to manage the storage operations for ongoing use of the storage.
73+
Several operations are needed, like create, maintenance mode, delete, etc.</para>
74+
<para>You must implement the following methods:</para>
75+
<itemizedlist>
76+
<listitem><para>initialize()</para></listitem>
77+
<listitem><para>maintain()</para></listitem>
78+
<listitem><para>cancelMaintain()</para></listitem>
79+
<listitem><para>deleteDataStore()</para></listitem>
80+
<listitem><para>Implement one of the attach*() methods depending on what scope you want the storage to have: attachHost(), attachCluster(), or attachZone().</para></listitem>
81+
</itemizedlist>
82+
</section>
83+
<section id="datastoreprovider">
84+
<title>Implementing DataStoreProvider</title>
85+
<para>DataStoreProvider contains the main code of the data store.</para>
86+
<para>You must implement the following methods:</para>
87+
<itemizedlist>
88+
<listitem><para>getDatastoreLifeCycle()</para></listitem>
89+
<listitem><para>getDataStoreDriver()</para></listitem>
90+
<listitem><para>getTypes(). Returns one or more types of storage for which this data store provider can be used.
91+
For secondary object storage, return IMAGE, and for a Secondary Staging Store, return ImageCache.</para></listitem>
92+
<listitem><para>configure(). First initialize the lifecycle implementation and the driver implementation,
93+
then call registerDriver() to register the new object store provider instance with &PRODUCT;.</para></listitem>
94+
<listitem><para>getName(). Returns the unique name of your provider; for example,
95+
this can be used to get the name to display in the UI.</para></listitem>
96+
</itemizedlist>
97+
<para>The following methods are optional:</para>
98+
<itemizedlist>
99+
<listitem><para>getHostListener() is optional; it's for monitoring the status of the host.</para></listitem>
100+
</itemizedlist>
101+
</section>
102+
<section id="storage-plugin-code-location">
103+
<title>Place the .jar File in the Right Directory</title>
104+
<para>For a secondary storage plugin, place your .jar file here:</para>
105+
<programlisting>plugins/storage/image/</programlisting>
106+
<para>For a primary storage plugin, place your .jar file here:</para>
107+
<programlisting>plugins/storage/volume/</programlisting>
108+
</section>
109+
<section id="storage-plugin-componentcontext-xml">
110+
<title>Edit Configuration Files</title>
111+
<para>First, edit the following file tell &PRODUCT; to include your .jar file.
112+
Add a line to this file to tell the &PRODUCT; Management Server that it now has a dependency on your code:</para>
113+
<programlisting>client/pom.xml</programlisting>
114+
<para>Place some facts about your code in the following file so &PRODUCT; can run it:</para>
115+
<programlisting>/client/tomcatconf/componentContext.xml.in</programlisting>
116+
<para>In the section “Deployment configurations of various adapters,” add this:</para>
117+
<programlisting>&lt;bean&gt;id=”some unique ID” class=”package name of your implementation of DataStoreProvider”&lt;/bean&gt;</programlisting>
118+
<para>In the section “Storage Providers,” add this:</para>
119+
<programlisting>&lt;property name=”providers”&gt;
120+
&lt;ref local=”same ID from the bean tag's id attribute”&gt;
121+
&lt;/property&gt;</programlisting>
122+
123+
</section>
124+
125+
</chapter>

0 commit comments

Comments
 (0)