Пример #1
0
        public static TemplateObjectTO ParseJson(dynamic json)
        {
            TemplateObjectTO result = null;
            dynamic          templateObjectTOJson = json[CloudStackTypes.TemplateObjectTO];

            if (templateObjectTOJson != null)
            {
                result = new TemplateObjectTO()
                {
                    imageDataStore = templateObjectTOJson.imageDataStore,
                    format         = (string)templateObjectTOJson.format,
                    name           = (string)templateObjectTOJson.name,
                    uuid           = (string)templateObjectTOJson.uuid,
                    path           = (string)templateObjectTOJson.path,
                    checksum       = (string)templateObjectTOJson.checksum,
                    size           = (string)templateObjectTOJson.size,
                    id             = (string)templateObjectTOJson.id
                };
                result.s3DataStoreTO    = S3TO.ParseJson(templateObjectTOJson.imageDataStore);
                result.nfsDataStoreTO   = NFSTO.ParseJson(templateObjectTOJson.imageDataStore);
                result.primaryDataStore = PrimaryDataStoreTO.ParseJson(templateObjectTOJson.imageDataStore);
            }

            return(result);
        }
Пример #2
0
        public static VolumeObjectTO ParseJson(dynamic json)
        {
            VolumeObjectTO result = null;

            if (json == null)
            {
                return(result);
            }

            dynamic volumeObjectTOJson = json[CloudStackTypes.VolumeObjectTO];

            if (volumeObjectTOJson != null)
            {
                result = new VolumeObjectTO()
                {
                    dataStore = volumeObjectTOJson.dataStore,
                    format    = ((string)volumeObjectTOJson.format),
                    name      = (string)volumeObjectTOJson.name,
                    path      = volumeObjectTOJson.path,
                    uuid      = (string)volumeObjectTOJson.uuid,
                    size      = (ulong)volumeObjectTOJson.size
                };
                result.primaryDataStore = PrimaryDataStoreTO.ParseJson(volumeObjectTOJson.dataStore);
                result.nfsDataStore     = NFSTO.ParseJson(volumeObjectTOJson.dataStore);

                // Assert
                if (result.dataStore == null || (result.primaryDataStore == null && result.nfsDataStore == null))
                {
                    String errMsg = "VolumeObjectTO missing dataStore in spec " + Utils.CleanString(volumeObjectTOJson.ToString());
                    logger.Error(errMsg);
                    throw new ArgumentNullException(errMsg);
                }

                GuessFileExtension(result);
            }
            return(result);
        }