]> xenbits.xensource.com Git - libvirt.git/commitdiff
secret: add Ceph secret type
authorSage Weil <sage@newdream.net>
Fri, 28 Oct 2011 17:30:45 +0000 (11:30 -0600)
committerEric Blake <eblake@redhat.com>
Fri, 28 Oct 2011 17:34:17 +0000 (11:34 -0600)
Add a new secret type to store a Ceph authentication key. The name
is simply an identifier for easy human reference.

The xml looks like this:

<secret ephemeral='no' private='no'>
 <uuid>0a81f5b2-8403-7b23-c8d6-21ccc2f80d6f</uuid>
 <usage type='ceph'>
   <name>mycluster_admin</name>
 </usage>
</secret>

Signed-off-by: Sage Weil <sage@newdream.net>
Signed-off-by: Josh Durgin <josh.durgin@dreamhost.net>
docs/formatsecret.html.in
docs/schemas/secret.rng
include/libvirt/libvirt.h.in
src/conf/secret_conf.c
src/conf/secret_conf.h
src/secret/secret_driver.c

index 63a1f2a85351d6da6198c994accd2695de73391f..01aff2d0edd0dfd046503e79fe45fa87bcbf6ba0 100644 (file)
@@ -39,8 +39,8 @@
       <dd>
         Specifies what this secret is used for.  A mandatory
         <code>type</code> attribute specifies the usage category, currently
-        only <code>volume</code> is defined.  Specific usage categories are
-        described below.
+        only <code>volume</code> and <code>ceph</code> are defined.
+        Specific usage categories are described below.
       </dd>
     </dl>
 
       this secret is associated with.
     </p>
 
+    <h3>Usage type "ceph"</h3>
+
+    <p>
+      This secret is associated with a Ceph RBD (rados block device).
+      The <code>&lt;usage type='ceph'&gt;</code> element must contain
+      a single <code>name</code> element that specifies a usage name
+      for the secret.  The Ceph secret can then be used by UUID or by
+      this usage name via the <code>&lt;auth&gt;</code> element of
+      a <a href="domain.html#elementsDisks">disk
+      device</a>. <span class="since">Since 0.9.7</span>.
+    </p>
+
     <h2><a name="example">Example</a></h2>
 
     <pre>
index 80270aef875abfaa0e331dfb4c89ef959d341b32..8e7714b92f3b012a0e07c6449353c5f10df7a2e7 100644 (file)
@@ -37,6 +37,7 @@
           <element name='usage'>
             <choice>
               <ref name='usagevolume'/>
+              <ref name='usageceph'/>
               <!-- More choices later -->
             </choice>
           </element>
     </element>
   </define>
 
+  <define name='usageceph'>
+    <attribute name='type'>
+      <value>ceph</value>
+    </attribute>
+    <element name='name'>
+      <text/>
+    </element>
+  </define>
+
   <define name="UUID">
     <choice>
       <data type="string">
index c51c7c5a6a47550a143936a5dc19c589bf497757..92a14a8492052238a2e8dcd31b356e5a585e277b 100644 (file)
@@ -2381,7 +2381,14 @@ typedef virSecret *virSecretPtr;
 typedef enum {
     VIR_SECRET_USAGE_TYPE_NONE = 0,
     VIR_SECRET_USAGE_TYPE_VOLUME = 1,
-    /* Expect more owner types later... */
+    VIR_SECRET_USAGE_TYPE_CEPH = 2,
+
+    /*
+     * NB: this enum value will increase over time as new events are
+     * added to the libvirt API. It reflects the last secret owner ID
+     * supported by this version of the libvirt API.
+     */
+    VIR_SECRET_USAGE_TYPE_LAST
 } virSecretUsageType;
 
 virConnectPtr           virSecretGetConnect     (virSecretPtr secret);
index b33ce98f70a00beb092aeb2bd4168333647756f5..fa808888d0bef6cfdc1327f6917d2df5b9929bc5 100644 (file)
@@ -35,7 +35,8 @@
 
 #define VIR_FROM_THIS VIR_FROM_SECRET
 
-VIR_ENUM_IMPL(virSecretUsageType, VIR_SECRET_USAGE_TYPE_VOLUME + 1, "none", "volume")
+VIR_ENUM_IMPL(virSecretUsageType, VIR_SECRET_USAGE_TYPE_LAST,
+              "none", "volume", "ceph")
 
 void
 virSecretDefFree(virSecretDefPtr def)
@@ -52,6 +53,9 @@ virSecretDefFree(virSecretDefPtr def)
         VIR_FREE(def->usage.volume);
         break;
 
+    case VIR_SECRET_USAGE_TYPE_CEPH:
+        VIR_FREE(def->usage.ceph);
+
     default:
         VIR_ERROR(_("unexpected secret usage type %d"), def->usage_type);
         break;
@@ -94,6 +98,15 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt,
         }
         break;
 
+    case VIR_SECRET_USAGE_TYPE_CEPH:
+        def->usage.ceph = virXPathString("string(./usage/name)", ctxt);
+        if (!def->usage.ceph) {
+            virSecretReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                                 _("Ceph usage specified, but name is missing"));
+            return -1;
+        }
+        break;
+
     default:
         virSecretReportError(VIR_ERR_INTERNAL_ERROR,
                              _("unexpected secret usage type %d"),
@@ -239,6 +252,13 @@ virSecretDefFormatUsage(virBufferPtr buf,
                                   def->usage.volume);
         break;
 
+    case VIR_SECRET_USAGE_TYPE_CEPH:
+        if (def->usage.ceph != NULL) {
+            virBufferEscapeString(buf, "    <name>%s</name>\n",
+                                  def->usage.ceph);
+        }
+        break;
+
     default:
         virSecretReportError(VIR_ERR_INTERNAL_ERROR,
                              _("unexpected secret usage type %d"),
index 4b47c527dfdc002eb936e70eb1bb636e3ecdd7a4..b5d72d4d9302c45679c39d86a276d7b2fa9549e9 100644 (file)
@@ -42,6 +42,7 @@ struct _virSecretDef {
     int usage_type;
     union {
         char *volume;               /* May be NULL */
+        char *ceph;
     } usage;
 };
 
index 59dc687d2ed0f8c82f87d3b561088b4e99570423..088a2431cb234b3f219fdc1d1c7f7bd480e2fbbf 100644 (file)
@@ -144,6 +144,11 @@ secretFindByUsage(virSecretDriverStatePtr driver, int usageType, const char *usa
             if (STREQ(s->def->usage.volume, usageID))
                 return s;
             break;
+
+        case VIR_SECRET_USAGE_TYPE_CEPH:
+            if (STREQ(s->def->usage.ceph, usageID))
+                return s;
+            break;
         }
     }
     return NULL;
@@ -607,6 +612,9 @@ secretUsageIDForDef(virSecretDefPtr def)
     case VIR_SECRET_USAGE_TYPE_VOLUME:
         return def->usage.volume;
 
+    case VIR_SECRET_USAGE_TYPE_CEPH:
+        return def->usage.ceph;
+
     default:
         return NULL;
     }