mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
secret: add Ceph secret type
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>
This commit is contained in:
@@ -39,8 +39,8 @@
|
|||||||
<dd>
|
<dd>
|
||||||
Specifies what this secret is used for. A mandatory
|
Specifies what this secret is used for. A mandatory
|
||||||
<code>type</code> attribute specifies the usage category, currently
|
<code>type</code> attribute specifies the usage category, currently
|
||||||
only <code>volume</code> is defined. Specific usage categories are
|
only <code>volume</code> and <code>ceph</code> are defined.
|
||||||
described below.
|
Specific usage categories are described below.
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
@@ -54,6 +54,18 @@
|
|||||||
this secret is associated with.
|
this secret is associated with.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h3>Usage type "ceph"</h3>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
This secret is associated with a Ceph RBD (rados block device).
|
||||||
|
The <code><usage type='ceph'></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><auth></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>
|
<h2><a name="example">Example</a></h2>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
<element name='usage'>
|
<element name='usage'>
|
||||||
<choice>
|
<choice>
|
||||||
<ref name='usagevolume'/>
|
<ref name='usagevolume'/>
|
||||||
|
<ref name='usageceph'/>
|
||||||
<!-- More choices later -->
|
<!-- More choices later -->
|
||||||
</choice>
|
</choice>
|
||||||
</element>
|
</element>
|
||||||
@@ -54,6 +55,15 @@
|
|||||||
</element>
|
</element>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
|
<define name='usageceph'>
|
||||||
|
<attribute name='type'>
|
||||||
|
<value>ceph</value>
|
||||||
|
</attribute>
|
||||||
|
<element name='name'>
|
||||||
|
<text/>
|
||||||
|
</element>
|
||||||
|
</define>
|
||||||
|
|
||||||
<define name="UUID">
|
<define name="UUID">
|
||||||
<choice>
|
<choice>
|
||||||
<data type="string">
|
<data type="string">
|
||||||
|
|||||||
@@ -2381,7 +2381,14 @@ typedef virSecret *virSecretPtr;
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
VIR_SECRET_USAGE_TYPE_NONE = 0,
|
VIR_SECRET_USAGE_TYPE_NONE = 0,
|
||||||
VIR_SECRET_USAGE_TYPE_VOLUME = 1,
|
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;
|
} virSecretUsageType;
|
||||||
|
|
||||||
virConnectPtr virSecretGetConnect (virSecretPtr secret);
|
virConnectPtr virSecretGetConnect (virSecretPtr secret);
|
||||||
|
|||||||
@@ -35,7 +35,8 @@
|
|||||||
|
|
||||||
#define VIR_FROM_THIS VIR_FROM_SECRET
|
#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
|
void
|
||||||
virSecretDefFree(virSecretDefPtr def)
|
virSecretDefFree(virSecretDefPtr def)
|
||||||
@@ -52,6 +53,9 @@ virSecretDefFree(virSecretDefPtr def)
|
|||||||
VIR_FREE(def->usage.volume);
|
VIR_FREE(def->usage.volume);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_SECRET_USAGE_TYPE_CEPH:
|
||||||
|
VIR_FREE(def->usage.ceph);
|
||||||
|
|
||||||
default:
|
default:
|
||||||
VIR_ERROR(_("unexpected secret usage type %d"), def->usage_type);
|
VIR_ERROR(_("unexpected secret usage type %d"), def->usage_type);
|
||||||
break;
|
break;
|
||||||
@@ -94,6 +98,15 @@ virSecretDefParseUsage(xmlXPathContextPtr ctxt,
|
|||||||
}
|
}
|
||||||
break;
|
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:
|
default:
|
||||||
virSecretReportError(VIR_ERR_INTERNAL_ERROR,
|
virSecretReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unexpected secret usage type %d"),
|
_("unexpected secret usage type %d"),
|
||||||
@@ -239,6 +252,13 @@ virSecretDefFormatUsage(virBufferPtr buf,
|
|||||||
def->usage.volume);
|
def->usage.volume);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_SECRET_USAGE_TYPE_CEPH:
|
||||||
|
if (def->usage.ceph != NULL) {
|
||||||
|
virBufferEscapeString(buf, " <name>%s</name>\n",
|
||||||
|
def->usage.ceph);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
virSecretReportError(VIR_ERR_INTERNAL_ERROR,
|
virSecretReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("unexpected secret usage type %d"),
|
_("unexpected secret usage type %d"),
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ struct _virSecretDef {
|
|||||||
int usage_type;
|
int usage_type;
|
||||||
union {
|
union {
|
||||||
char *volume; /* May be NULL */
|
char *volume; /* May be NULL */
|
||||||
|
char *ceph;
|
||||||
} usage;
|
} usage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -144,6 +144,11 @@ secretFindByUsage(virSecretDriverStatePtr driver, int usageType, const char *usa
|
|||||||
if (STREQ(s->def->usage.volume, usageID))
|
if (STREQ(s->def->usage.volume, usageID))
|
||||||
return s;
|
return s;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case VIR_SECRET_USAGE_TYPE_CEPH:
|
||||||
|
if (STREQ(s->def->usage.ceph, usageID))
|
||||||
|
return s;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -607,6 +612,9 @@ secretUsageIDForDef(virSecretDefPtr def)
|
|||||||
case VIR_SECRET_USAGE_TYPE_VOLUME:
|
case VIR_SECRET_USAGE_TYPE_VOLUME:
|
||||||
return def->usage.volume;
|
return def->usage.volume;
|
||||||
|
|
||||||
|
case VIR_SECRET_USAGE_TYPE_CEPH:
|
||||||
|
return def->usage.ceph;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user