Re: [PATCH v3 1/7] storage_conf: Adjust virStoragePoolAuthType enum

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jul 15, 2013 at 09:04:29AM -0400, John Ferlan wrote:
> Generate and use the virStoragePoolAuthTypeType{To|From}String helpers
> ---
>  src/conf/storage_conf.c | 19 +++++++++++--------
>  src/conf/storage_conf.h |  3 +++
>  2 files changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
> index 524a4d6..9bcfced 100644
> --- a/src/conf/storage_conf.c
> +++ b/src/conf/storage_conf.c
> @@ -95,6 +95,10 @@ VIR_ENUM_IMPL(virStoragePoolSourceAdapterType,
>                VIR_STORAGE_POOL_SOURCE_ADAPTER_TYPE_LAST,
>                "default", "scsi_host", "fc_host")
>  
> +VIR_ENUM_IMPL(virStoragePoolAuthType,
> +              VIR_STORAGE_POOL_AUTH_LAST,
> +              "none", "chap", "ceph")
> +
>  typedef const char *(*virStorageVolFormatToString)(int format);
>  typedef int (*virStorageVolFormatFromString)(const char *format);
>  typedef const char *(*virStorageVolFeatureToString)(int feature);
> @@ -676,11 +680,8 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt,
>      if (authType == NULL) {
>          source->authType = VIR_STORAGE_POOL_AUTH_NONE;
>      } else {
> -        if (STREQ(authType, "chap")) {
> -            source->authType = VIR_STORAGE_POOL_AUTH_CHAP;
> -        } else if (STREQ(authType, "ceph")) {
> -            source->authType = VIR_STORAGE_POOL_AUTH_CEPHX;
> -        } else {
> +        if ((source->authType =
> +             virStoragePoolAuthTypeTypeFromString(authType)) < 0) {
>              virReportError(VIR_ERR_XML_ERROR,
>                             _("unknown auth type '%s'"),
>                             authType);
> @@ -1117,13 +1118,15 @@ virStoragePoolSourceFormat(virBufferPtr buf,
>      }
>  
>      if (src->authType == VIR_STORAGE_POOL_AUTH_CHAP)
> -        virBufferAsprintf(buf,"    <auth type='chap' login='%s' passwd='%s'/>\n",
> +        virBufferAsprintf(buf,"    <auth type='%s' login='%s' passwd='%s'/>\n",
> +                          virStoragePoolAuthTypeTypeToString(src->authType),
>                            src->auth.chap.login,
>                            src->auth.chap.passwd);
>  
>      if (src->authType == VIR_STORAGE_POOL_AUTH_CEPHX) {
> -        virBufferAsprintf(buf,"    <auth username='%s' type='ceph'>\n",
> -                          src->auth.cephx.username);
> +        virBufferAsprintf(buf,"    <auth username='%s' type='%s'>\n",
> +                          src->auth.cephx.username,
> +                          virStoragePoolAuthTypeTypeToString(src->authType));
>  
>          virBufferAddLit(buf,"      <secret");
>          if (src->auth.cephx.secret.uuidUsable) {
> diff --git a/src/conf/storage_conf.h b/src/conf/storage_conf.h
> index c183427..98339ef 100644
> --- a/src/conf/storage_conf.h
> +++ b/src/conf/storage_conf.h
> @@ -146,7 +146,10 @@ enum virStoragePoolAuthType {
>      VIR_STORAGE_POOL_AUTH_NONE,
>      VIR_STORAGE_POOL_AUTH_CHAP,
>      VIR_STORAGE_POOL_AUTH_CEPHX,
> +
> +    VIR_STORAGE_POOL_AUTH_LAST,
>  };
> +VIR_ENUM_DECL(virStoragePoolAuthType)
>  
>  typedef struct _virStoragePoolAuthChap virStoragePoolAuthChap;
>  typedef virStoragePoolAuthChap *virStoragePoolAuthChapPtr;

ACK


Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]