Esempio n. 1
0
        private ResourceModel AddAzureContainer(ResourceModel resourceModel)
        {
            var storageAccountCredential = this.DataBoxEdgeManagementClient.StorageAccountCredentials.Get(
                this.DeviceName,
                this.StorageAccountCredentialName,
                this.ResourceGroupName);

            resourceModel.AzureContainerInfo = this.IsParameterBound(c => c.ContainerName)
                ? new AzureContainerInfo(storageAccountCredential.Id, ContainerName, DataFormat)
                : new AzureContainerInfo(storageAccountCredential.Id, Name, this.DataFormat);
            return(resourceModel);
        }
Esempio n. 2
0
        public override void ExecuteCmdlet()
        {
            _share = InitShareObject();

            if (this.IsParameterBound(c => c.ClientAccessRight))
            {
                _share.ClientAccessRights = new List <ClientAccessRight>();
                foreach (var clientAccessRight in this.ClientAccessRight)
                {
                    var accessRightPolicy = HashtableToDictionary <string, string>(clientAccessRight);
                    _share.ClientAccessRights.Add(
                        new ClientAccessRight(
                            accessRightPolicy.GetOrNull("ClientId"),
                            accessRightPolicy.GetOrNull("AccessRight")
                            )
                        );
                }
            }

            if (this.IsParameterBound(c => c.UserAccessRight))
            {
                _share.UserAccessRights = new List <UserAccessRight>();
                foreach (var userAccessRight in this.UserAccessRight)
                {
                    var accessRightPolicy = HashtableToDictionary <string, string>(userAccessRight);

                    _share.UserAccessRights.Add(
                        new UserAccessRight(
                            GetUserId(accessRightPolicy.GetOrNull("Username")),
                            accessRightPolicy.GetOrNull("AccessRight")
                            ));
                }
            }

            if (this.ShouldProcess(this.Name,
                                   string.Format("Creating '{0}' in device '{1}' with name '{2}'.",
                                                 HelpMessageShare.ObjectName, this.DeviceName, this.Name)))
            {
                DoesResourceExists();
                var results = new List <PSResourceModel>()
                {
                    CreateResourceModel()
                };

                WriteObject(results, true);
            }
        }
Esempio n. 3
0
        private ResourceModel InitShareObject()
        {
            var dataPolicy = "Local";

            if (this.IsParameterBound(c => c.StorageAccountCredentialName))
            {
                dataPolicy = "Cloud";
            }

            var accessProtocol = this.NFS.IsPresent ? "NFS" : "SMB";
            var share          = new ResourceModel("Online",
                                                   "Enabled",
                                                   accessProtocol,
                                                   null, dataPolicy: dataPolicy);

            share = dataPolicy == "Cloud" ? AddAzureContainer(share) : share;
            return(share);
        }