コード例 #1
0
        private void ExecuteCommand()
        {
            extensionName = DscExtensionCmdletConstants.ExtensionPublishedName;
            publisherName = DscExtensionCmdletConstants.ExtensionPublishedNamespace;

            List<ResourceExtensionReference> extensionRefs = GetPredicateExtensionList();
            WriteObject(
                extensionRefs == null ? null : extensionRefs.Select(
                r =>
                {
                    GetExtensionValues(r);
                    DscExtensionPublicSettings extensionPublicSettings = null;
                    try
                    {
                        extensionPublicSettings = DscExtensionSettingsSerializer.DeserializePublicSettings(PublicConfiguration);
                    }
                    catch (JsonException e)
                    {
                        this.ThrowTerminatingError(
                            new ErrorRecord(
                                new JsonException(
                                    String.Format(
                                        CultureInfo.CurrentUICulture,
                                        Properties.Resources.AzureVMDscWrongSettingsFormat,
                                        PublicConfiguration),
                                    e),
                                string.Empty,
                                ErrorCategory.ParserError,
                                null));
                    }
                    var context = new VirtualMachineDscExtensionContext
                    {
                        ExtensionName = r.Name,
                        Publisher = r.Publisher,
                        ReferenceName = r.ReferenceName,
                        Version = r.Version,
                        State = r.State,
                        RoleName = VM.GetInstance().RoleName,
                        PublicConfiguration = PublicConfiguration,
                        PrivateConfiguration = SecureStringHelper.GetSecureString(PrivateConfiguration)
                    };

                    if (extensionPublicSettings == null)
                    {
                        context.ModulesUrl = string.Empty;
                        context.ConfigurationFunction = string.Empty;
                        context.Properties = null;
                    }
                    else
                    {
                        context.ModulesUrl = extensionPublicSettings.ModulesUrl;
                        context.ConfigurationFunction = extensionPublicSettings.ConfigurationFunction;
                        context.Properties = new Hashtable(extensionPublicSettings.Properties.ToDictionary( x => x.Name, x => x.Value ));
                    }

                    return context;
                }
                
                ).FirstOrDefault());
        }
コード例 #2
0
        internal void ExecuteCommand()
        {
            List <ResourceExtensionReference> extensionRefs = GetPredicateExtensionList();

            WriteObject(
                extensionRefs == null ? null : extensionRefs.Select(
                    r =>
            {
                GetExtensionValues(r);
                DscPublicSettings publicSettings = null;
                try
                {
                    publicSettings = DscSettingsSerializer.DeserializePublicSettings(PublicConfiguration);
                }
                catch (JsonException e)
                {
                    this.ThrowTerminatingError(
                        new ErrorRecord(
                            new JsonException(
                                String.Format(
                                    CultureInfo.CurrentUICulture,
                                    Properties.Resources.AzureVMDscWrongSettingsFormat,
                                    PublicConfiguration),
                                e),
                            string.Empty,
                            ErrorCategory.ParserError,
                            null));
                }
                var context = new VirtualMachineDscExtensionContext
                {
                    ExtensionName        = r.Name,
                    Publisher            = r.Publisher,
                    ReferenceName        = r.ReferenceName,
                    Version              = r.Version,
                    State                = r.State,
                    RoleName             = VM.GetInstance().RoleName,
                    PublicConfiguration  = PublicConfiguration,
                    PrivateConfiguration = SecureStringHelper.GetSecureString(PrivateConfiguration)
                };

                if (publicSettings == null)
                {
                    context.ModulesUrl            = string.Empty;
                    context.ConfigurationFunction = string.Empty;
                    context.Properties            = null;
                }
                else
                {
                    context.ModulesUrl            = publicSettings.ModulesUrl;
                    context.ConfigurationFunction = publicSettings.ConfigurationFunction;
                    context.Properties            = new Hashtable(publicSettings.Properties.ToDictionary(x => x.Name, x => x.Value));
                }

                return(context);
            }

                    ).FirstOrDefault());
        }
コード例 #3
0
        internal void ExecuteCommand()
        {
            List <ResourceExtensionReference> extensionRefs = GetPredicateExtensionList();

            WriteObject(
                extensionRefs == null ? null : extensionRefs.Select(
                    r =>
            {
                GetExtensionValues(r);

                var publicSettings = string.IsNullOrEmpty(PublicConfiguration) ? null : JsonConvert.DeserializeObject <DscPublicSettings>(PublicConfiguration);

                var context = new VirtualMachineDscExtensionContext
                {
                    ExtensionName        = r.Name,
                    Publisher            = r.Publisher,
                    ReferenceName        = r.ReferenceName,
                    Version              = r.Version,
                    State                = r.State,
                    RoleName             = VM.GetInstance().RoleName,
                    PublicConfiguration  = PublicConfiguration,
                    PrivateConfiguration = SecureStringHelper.GetSecureString(PrivateConfiguration),
                };

                if (publicSettings == null)
                {
                    context.ModulesUrl            = string.Empty;
                    context.ConfigurationFunction = string.Empty;
                    context.Properties            = null;
                }
                else
                {
                    context.ModulesUrl            = publicSettings.ModulesUrl;
                    context.ConfigurationFunction = publicSettings.ConfigurationFunction;
                    context.Properties            = publicSettings.Properties;
                }

                return(context);
            }

                    ).FirstOrDefault());
        }
コード例 #4
0
        internal void ExecuteCommand()
        {
            List<ResourceExtensionReference> extensionRefs = GetPredicateExtensionList();
            WriteObject(
                extensionRefs == null ? null : extensionRefs.Select(
                r =>
                {
                    GetExtensionValues(r);
                    
                    var publicSettings = string.IsNullOrEmpty(PublicConfiguration) ? null : JsonConvert.DeserializeObject<DscPublicSettings>(PublicConfiguration);

                    var context = new VirtualMachineDscExtensionContext
                    {
                        ExtensionName = r.Name,
                        Publisher = r.Publisher,
                        ReferenceName = r.ReferenceName,
                        Version = r.Version,
                        State = r.State,
                        RoleName = VM.GetInstance().RoleName,
                        PublicConfiguration = PublicConfiguration,
                        PrivateConfiguration = SecureStringHelper.GetSecureString(PrivateConfiguration),
                    };

                    if (publicSettings == null)
                    {
                        context.ModulesUrl = string.Empty;
                        context.ConfigurationFunction = string.Empty;
                        context.Properties = null;
                    }
                    else
                    {
                        context.ModulesUrl = publicSettings.ModulesUrl;
                        context.ConfigurationFunction = publicSettings.ConfigurationFunction;
                        context.Properties = publicSettings.Properties;
                    }

                    return context;
                }
                
                ).FirstOrDefault());
        }
コード例 #5
0
        internal void ExecuteCommand()
        {
            List<ResourceExtensionReference> extensionRefs = GetPredicateExtensionList();
            WriteObject(
                extensionRefs == null ? null : extensionRefs.Select(
                r =>
                {
                    GetExtensionValues(r);
                    DscPublicSettings publicSettings = null;
                    try
                    {
                        publicSettings = string.IsNullOrEmpty(PublicConfiguration)
                            ? null
                            : JsonConvert.DeserializeObject<DscPublicSettings>(PublicConfiguration);
                    }
                    catch (JsonException)
                    {
                        // Try deserialize as version 1.0
                        try
                        {
                            DscPublicSettings.Version1 publicSettingsV1 = JsonConvert.DeserializeObject<DscPublicSettings.Version1>(PublicConfiguration);
                            publicSettings = publicSettingsV1.ToCurrentVersion();
                        }
                        catch (JsonException e)
                        {
                            this.ThrowTerminatingError(new ErrorRecord(new JsonException(String.Format(
                                CultureInfo.CurrentUICulture,
                                Properties.Resources.AzureVMDscWrongSettingsFormat,
                                PublicConfiguration), e), string.Empty,
                                ErrorCategory.ParserError,
                                null));
                        }
                    }
                    var context = new VirtualMachineDscExtensionContext
                    {
                        ExtensionName = r.Name,
                        Publisher = r.Publisher,
                        ReferenceName = r.ReferenceName,
                        Version = r.Version,
                        State = r.State,
                        RoleName = VM.GetInstance().RoleName,
                        PublicConfiguration = PublicConfiguration,
                        PrivateConfiguration = SecureStringHelper.GetSecureString(PrivateConfiguration),
                    };

                    if (publicSettings == null)
                    {
                        context.ModulesUrl = string.Empty;
                        context.ConfigurationFunction = string.Empty;
                        context.Properties = null;
                    }
                    else
                    {
                        context.ModulesUrl = publicSettings.ModulesUrl;
                        context.ConfigurationFunction = publicSettings.ConfigurationFunction;
                        context.Properties = new Hashtable(publicSettings.Properties.ToDictionary( x => x.Name, x => x.Value ));
                    }

                    return context;
                }
                
                ).FirstOrDefault());
        }