public override List <WalletTransactionHistoryHeaderAPI> APIQueryWalletTransactionHistory(Guid accountUuid)
        {
            this.EnsureWalletLoaded();

            if (!this.IsWalletLoaded)
            {
                throw new ApplicationException("Wallet is not loaded");
            }

            if (accountUuid == Guid.Empty)
            {
                accountUuid = this.GetAccountUuid();
            }

            //TODO: merge correctly with base version of this method
            var results = this.WalletFileInfo.Accounts[accountUuid].WalletTransactionHistoryInfo.RunQuery <NeuraliumWalletTransactionHistoryHeaderAPI, NeuraliumWalletTransactionHistory>(caches => caches.Select(t => {
                TransactionId transactionId = new TransactionId(t.TransactionId);
                var version = new ComponentVersion <TransactionType>(t.Version);

                return(new NeuraliumWalletTransactionHistoryHeaderAPI {
                    TransactionId = t.TransactionId, Sender = transactionId.Account.ToString(), Timestamp = t.Timestamp, Status = t.Status,
                    Version = new { transactionType = version.Type.Value, major = version.Major.Value, minor = version.Minor.Value }, Recipient = t.Recipient, Local = t.Local, Amount = t.Amount,
                    Tip = t.Tip, Note = t.Note
                });
            }).OrderByDescending(t => t.Timestamp).ToList());

            return(results.Cast <WalletTransactionHistoryHeaderAPI>().ToList());
        }
Esempio n. 2
0
        public ApplyVersionFix(IProjectReference reference, ComponentVersion version)
        {
            _reference = reference;
            _version   = version;

            Title = $"version will be changed to {version}";
        }
Esempio n. 3
0
        // TODO: DryRun?

        public void Execute()
        {
            var version = ComponentVersion.Undefined;

            if (!String.IsNullOrEmpty(VersionString))
            {
                Console.WriteLine("Release for all SNAPSHOT projects in folder {0} to release version {1}", Path, VersionString);
                version = new ComponentVersion(VersionString);
            }
            else
            {
                Console.WriteLine("Release for all SNAPSHOT projects in folder {0} with build {1} and \"{2}\" suffix", Path, Build, Suffix);
            }

            var solutionManagement = new SolutionManagement(GetActionLog());
            var solution           = solutionManagement.OpenSolution(Path, LoadAllProjects);

            Debug.WriteLine(solution.AllProjects.Count() + " projects loaded");

            BulkSwitchToReleaseAction action = version.IsDefined ?
                                               new BulkSwitchToReleaseAction(solution, version) :
                                               new BulkSwitchToReleaseAction(solution, Build, Suffix);

            action.Execute();

            solution.ForceSaveAll();
        }
        public override WalletTransactionHistoryDetailsAPI APIQueryWalletTransationHistoryDetails(Guid accountUuid, string transactionId)
        {
            this.EnsureWalletLoaded();

            if (!this.IsWalletLoaded)
            {
                throw new ApplicationException("Wallet is not loaded");
            }

            if (accountUuid == Guid.Empty)
            {
                accountUuid = this.GetAccountUuid();
            }

            var results = this.WalletFileInfo.Accounts[accountUuid].WalletTransactionHistoryInfo.RunQuery <NeuraliumWalletTransactionHistoryDetailsAPI, NeuraliumWalletTransactionHistory>(caches => caches.Where(t => t.TransactionId == transactionId).Select(t => {
                var version = new ComponentVersion <TransactionType>(t.Version);

                return(new NeuraliumWalletTransactionHistoryDetailsAPI {
                    TransactionId = t.TransactionId, Sender = new TransactionId(t.TransactionId).Account.ToString(), Timestamp = t.Timestamp, Status = t.Status,
                    Version = new { transactionType = version.Type.Value, major = version.Major.Value, minor = version.Minor.Value }, Recipient = t.Recipient, Contents = t.Contents, Local = t.Local,
                    Amount = t.Amount, Tip = t.Tip, Note = t.Note
                });
            }).ToList());

            return(results.SingleOrDefault());
        }
        public override IEnvelope CreateNewEnvelope(ComponentVersion <EnvelopeType> version)
        {
            if (version == EnvelopeTypes.Instance.Message)
            {
                if (version == (1, 0))
                {
                    return(new NeuraliumMessageEnvelope());
                }
            }

            if (version == EnvelopeTypes.Instance.Block)
            {
                if (version == (1, 0))
                {
                    return(new NeuraliumBlockEnvelope());
                }
            }

            if (version == EnvelopeTypes.Instance.Transaction)
            {
                if (version == (1, 0))
                {
                    return(new NeuraliumTransactionEnvelope());
                }
            }

            return(null);
        }
Esempio n. 6
0
        /// <summary>
        /// Return current version of JMMServer
        /// </summary>
        /// <returns></returns>
        private object GetVersion()
        {
            List <ComponentVersion> list = new List <ComponentVersion>();

            ComponentVersion version = new ComponentVersion();

            version.version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
            version.name    = "server";
            list.Add(version);

            version         = new ComponentVersion();
            version.name    = "auth_module";
            version.version = Auth.version.ToString();
            list.Add(version);

            version         = new ComponentVersion();
            version.name    = "common_module";
            version.version = Common.version.ToString();
            list.Add(version);

            version         = new ComponentVersion();
            version.name    = "core_module";
            version.version = Core.version.ToString();
            list.Add(version);

            version         = new ComponentVersion();
            version.name    = "database_module";
            version.version = Database.version.ToString();
            list.Add(version);

            version         = new ComponentVersion();
            version.name    = "dev_module";
            version.version = Dev.version.ToString();
            list.Add(version);

            version         = new ComponentVersion();
            version.name    = "unauth_module";
            version.version = Unauth.version.ToString();
            list.Add(version);

            version         = new ComponentVersion();
            version.name    = "webui_module";
            version.version = Webui.version.ToString();
            list.Add(version);

            if (File.Exists("webui//index.ver"))
            {
                string   webui_version = File.ReadAllText("webui//index.ver");
                string[] versions      = webui_version.Split('>');
                if (versions.Length == 2)
                {
                    version         = new ComponentVersion();
                    version.name    = "webui/" + versions[0];
                    version.version = versions[1];
                    list.Add(version);
                }
            }

            return(list);
        }
Esempio n. 7
0
        /// <summary>
        /// Check for newest unstable version and return object { version: string, url: string }
        /// </summary>
        /// <returns></returns>
        private ComponentVersion WebUILatestUnstableVersion()
        {
            ComponentVersion version = new ComponentVersion();

            version = WebUIGetLatestVersion(false);

            return(version);
        }
Esempio n. 8
0
        public ComponentVersion WebUILatestStableVersion()
        {
            ComponentVersion version = new ComponentVersion {
                version = WebUIHelper.WebUIGetLatestVersion(true)
            };

            return(version);
        }
Esempio n. 9
0
        public ComponentVersion WebUILatestUnstableVersion()
        {
            ComponentVersion version = new ComponentVersion();

            version.version = WebUIHelper.WebUIGetLatestVersion(false);

            return(version);
        }
Esempio n. 10
0
        /// <summary>
        /// Check for newest stable version and return object { version: string, url: string }
        /// </summary>
        /// <returns></returns>
        private ComponentVersion WebUILatestStableVersion()
        {
            ComponentVersion version = new ComponentVersion();

            version = WebUIGetLatestVersion(true);

            return(version);
        }
Esempio n. 11
0
 public override int GetHashCode()
 {
     return(0x1D11842C
            ^ (ProductName != null ? ProductName.GetHashCode() : 0)
            ^ (ComponentName != null ? ComponentName.GetHashCode() : 0)
            ^ (ComponentEdition != null ? ComponentEdition.GetHashCode() : 0)
            ^ (ComponentVersion != null ? ComponentVersion.GetHashCode() : 0)
            ^ (ComponentVersionSuffix != null ? ComponentVersionSuffix.GetHashCode() : 0)
            ^ (ComponentRelease != null ? ComponentRelease.GetHashCode() : 0));
 }
        public override ITransaction CreateTransaction(IDehydratedTransaction dehydratedTransaction)
        {
            IDataRehydrator rehydrator = DataSerializationFactory.CreateRehydrator(dehydratedTransaction.Header);

            var version = new ComponentVersion <TransactionType>();

            version.Rehydrate(rehydrator);

            rehydrator.Rewind2Start();

            return(this.CreateTransation(version));
        }
Esempio n. 13
0
        public static BountyAllocator GetRepresentativeSelector(string bountyAllocationMethodType)
        {
            var version = new ComponentVersion <BountyAllocationMethodType>(bountyAllocationMethodType);

            if (version == BountyAllocationMethodTypes.Instance.EqualSplit)
            {
                if (version == (1, 0))
                {
                    return(new EqualSplitBountyAllocator());
                }
            }

            throw new ApplicationException("Invalid bounty allocation type");
        }
Esempio n. 14
0
        public BulkSwitchToReleaseAction(IProjectsRepository projects, ComponentVersion version)
        {
            if (!version.IsDefined)
            {
                throw new InvalidOperationException("targer version is undefied");
            }
            if (version.IsSnapshot)
            {
                throw new InvalidOperationException("targer version is snapshot");
            }

            _projects = projects;
            _version  = version;
        }
Esempio n. 15
0
        /// <summary>
        /// Return current version of JMMServer
        /// </summary>
        /// <returns></returns>
        private object GetVersion()
        {
            List <ComponentVersion> list    = new List <ComponentVersion>();
            ComponentVersion        version = new ComponentVersion();

            version.version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString();
            version.name    = "jmmserver";
            list.Add(version);
            version         = new ComponentVersion();
            version.version = APIv2_core_Module.version.ToString();
            version.name    = "apiv2";
            list.Add(version);
            return(list);
        }
Esempio n. 16
0
        /// <summary>
        /// Find version that match requirements
        /// </summary>
        /// <param name="stable">do version have to be stable</param>
        /// <returns></returns>
        internal ComponentVersion WebUIGetLatestVersion(bool stable)
        {
            var client = new System.Net.WebClient();

            client.Headers.Add("Accept: application/vnd.github.v3+json");
            client.Headers.Add("User-Agent", "jmmserver");
            var response = client.DownloadString(new Uri(
                                                     "https://api.github.com/repos/japanesemediamanager/shokoserver-webui/releases/latest"));

            dynamic result = Newtonsoft.Json.JsonConvert.DeserializeObject(response);

            ComponentVersion version = new ComponentVersion();

            if (result.prerelease == "False")
            {
                //not pre-build
                if (stable)
                {
                    version.version = result.tag_name;
                }
                else
                {
                    version.version = WebUIGetVersionsTag(false);
                }
            }
            else
            {
                //pre-build
                if (stable)
                {
                    version.version = WebUIGetVersionsTag(true);
                }
                else
                {
                    version.version = result.tag_name;
                }
            }

            return(version);
        }
Esempio n. 17
0
        public void IsSnapshotPositiveTest()
        {
            var version = new ComponentVersion("A-SNAPSHOT");

            Assert.True(version.IsSnapshot);
        }
Esempio n. 18
0
        public void EmptyStringIsNotDefinedTest()
        {
            var version = new ComponentVersion(string.Empty);

            Assert.True(!version.IsDefined);
        }
Esempio n. 19
0
        public void IsDefinedTest()
        {
            var version = new ComponentVersion("a");

            Assert.True(version.IsDefined);
        }
Esempio n. 20
0
        public void ToSnapshotFromReleaseWithWrongPositionTest()
        {
            var version = new ComponentVersion("1.0.0");

            Assert.Throws <InvalidOperationException>(delegate { version.Operations().ToSnapshotWithVersionIncrement(4); });
        }
Esempio n. 21
0
        public void ToSnapshotFromReleaseWithSuffixAndPositionTest()
        {
            var version = new ComponentVersion("1.0.0-RE").Operations().ToSnapshotWithVersionIncrement(1);

            Assert.That(version.Value, Is.EqualTo("1.1.0-RE-SNAPSHOT"));
        }
Esempio n. 22
0
        public void ToSnapshotFromReleaseWithFirstPositionStoppedTest()
        {
            var version = new ComponentVersion("1.0.0.0").Operations().ToSnapshotWithVersionIncrement(1, 2);

            Assert.That(version.Value, Is.EqualTo("1.1.0-SNAPSHOT"));
        }
Esempio n. 23
0
        public void ToSnapshotFromNullWithPositionTest()
        {
            var version = new ComponentVersion(null);

            Assert.Throws <InvalidOperationException>(delegate { version.Operations().ToSnapshotWithVersionIncrement(1); });
        }
        public override void ExecuteCmdlet()
        {
            parameters.UserName = HttpCredential.UserName;
            parameters.Password = HttpCredential.Password.ConvertToString();

            if (RdpCredential != null)
            {
                parameters.RdpUsername = RdpCredential.UserName;
                parameters.RdpPassword = RdpCredential.Password.ConvertToString();
            }

            if (SshCredential != null)
            {
                parameters.SshUserName = SshCredential.UserName;
                if (!string.IsNullOrEmpty(SshCredential.Password.ConvertToString()))
                {
                    parameters.SshPassword = SshCredential.Password.ConvertToString();
                }
                if (!string.IsNullOrEmpty(SshPublicKey))
                {
                    parameters.SshPublicKey = SshPublicKey;
                }
            }

            if (DefaultStorageAccountType == null || DefaultStorageAccountType == StorageType.AzureStorage)
            {
                parameters.DefaultStorageInfo = new AzureStorageInfo(DefaultStorageAccountName, DefaultStorageAccountKey, DefaultStorageContainer);
            }
            else
            {
                parameters.DefaultStorageInfo = new AzureDataLakeStoreInfo(DefaultStorageAccountName, DefaultStorageRootPath);
            }

            foreach (
                var storageAccount in
                AdditionalStorageAccounts.Where(
                    storageAccount => !parameters.AdditionalStorageAccounts.ContainsKey(storageAccount.Key)))
            {
                parameters.AdditionalStorageAccounts.Add(storageAccount.Key, storageAccount.Value);
            }
            foreach (var config in Configurations.Where(config => !parameters.Configurations.ContainsKey(config.Key)))
            {
                parameters.Configurations.Add(config.Key, config.Value);
            }
            foreach (var action in ScriptActions.Where(action => parameters.ScriptActions.ContainsKey(action.Key)))
            {
                parameters.ScriptActions.Add(action.Key,
                                             action.Value.Select(a => a.GetScriptActionFromPSModel()).ToList());
            }
            foreach (var component in ComponentVersion.Where(component => !parameters.ComponentVersion.ContainsKey(component.Key)))
            {
                parameters.ComponentVersion.Add(component.Key, component.Value);
            }
            if (OozieMetastore != null)
            {
                var metastore = OozieMetastore;
                parameters.OozieMetastore = new Metastore(metastore.SqlAzureServerName, metastore.DatabaseName, metastore.Credential.UserName, metastore.Credential.Password.ConvertToString());
            }
            if (HiveMetastore != null)
            {
                var metastore = HiveMetastore;
                parameters.HiveMetastore = new Metastore(metastore.SqlAzureServerName, metastore.DatabaseName, metastore.Credential.UserName, metastore.Credential.Password.ConvertToString());
            }
            if (!string.IsNullOrEmpty(CertificatePassword))
            {
                if (!string.IsNullOrEmpty(CertificateFilePath))
                {
                    CertificateFileContents = File.ReadAllBytes(CertificateFilePath);
                }
                var servicePrincipal = new Management.HDInsight.Models.ServicePrincipal(
                    GetApplicationId(ApplicationId), GetTenantId(AadTenantId), CertificateFileContents,
                    CertificatePassword);

                parameters.Principal = servicePrincipal;
            }

            if (SecurityProfile != null)
            {
                parameters.SecurityProfile = new SecurityProfile()
                {
                    DirectoryType  = DirectoryType.ActiveDirectory,
                    Domain         = SecurityProfile.Domain,
                    DomainUsername =
                        SecurityProfile.DomainUserCredential != null
                            ? SecurityProfile.DomainUserCredential.UserName
                            : null,
                    DomainUserPassword =
                        SecurityProfile.DomainUserCredential != null &&
                        SecurityProfile.DomainUserCredential.Password != null
                            ? SecurityProfile.DomainUserCredential.Password.ConvertToString()
                            : null,
                    OrganizationalUnitDN = SecurityProfile.OrganizationalUnitDN,
                    LdapsUrls            = SecurityProfile.LdapsUrls,
                    ClusterUsersGroupDNs = SecurityProfile.ClusterUsersGroupDNs
                };
            }

            if (DisksPerWorkerNode > 0)
            {
                parameters.WorkerNodeDataDisksGroups = new List <DataDisksGroups>()
                {
                    new DataDisksGroups()
                    {
                        DisksPerNode = DisksPerWorkerNode
                    }
                };
            }

            if (EncryptionKeyName != null && EncryptionKeyVersion != null && EncryptionVaultUri != null && AssignedIdentity != null)
            {
                parameters.ClusterIdentity = new ClusterIdentity
                {
                    Type = ResourceIdentityType.UserAssigned,
                    UserAssignedIdentities = new Dictionary <string, ClusterIdentityUserAssignedIdentitiesValue>
                    {
                        { AssignedIdentity, new ClusterIdentityUserAssignedIdentitiesValue() }
                    }
                };
                parameters.DiskEncryptionProperties = new DiskEncryptionProperties()
                {
                    KeyName             = EncryptionKeyName,
                    KeyVersion          = EncryptionKeyVersion,
                    VaultUri            = EncryptionVaultUri,
                    EncryptionAlgorithm = EncryptionAlgorithm != null ? EncryptionAlgorithm : JsonWebKeyEncryptionAlgorithm.RSAOAEP,
                    MsiResourceId       = AssignedIdentity
                };
            }

            if (EncryptionAtHost != null)
            {
                if (parameters.DiskEncryptionProperties != null)
                {
                    parameters.DiskEncryptionProperties.EncryptionAtHost = EncryptionAtHost;
                }
                else
                {
                    parameters.DiskEncryptionProperties = new DiskEncryptionProperties()
                    {
                        EncryptionAtHost = EncryptionAtHost
                    };
                }
            }

            Autoscale autoscaleParameter = null;

            if (AutoscaleConfiguration != null)
            {
                autoscaleParameter = AutoscaleConfiguration.ToAutoscale();
            }

            var cluster = HDInsightManagementClient.CreateNewCluster(ResourceGroupName, ClusterName, OSType, parameters, MinSupportedTlsVersion, this.DefaultContext.Environment.ActiveDirectoryAuthority, this.DefaultContext.Environment.DataLakeEndpointResourceId, PublicNetworkAccessType, OutboundPublicNetworkAccessType, EncryptionInTransit, autoscaleParameter);

            if (cluster != null)
            {
                WriteObject(new AzureHDInsightCluster(cluster));
            }
        }
        public override void ExecuteCmdlet()
        {
            parameters.UserName = HttpCredential.UserName;
            parameters.Password = HttpCredential.Password.ConvertToString();

            if (RdpCredential != null)
            {
                parameters.RdpUsername = RdpCredential.UserName;
                parameters.RdpPassword = RdpCredential.Password.ConvertToString();
            }

            if (OSType == OSType.Linux && SshCredential != null)
            {
                parameters.SshUserName = SshCredential.UserName;
                if (!string.IsNullOrEmpty(SshCredential.Password.ConvertToString()))
                {
                    parameters.SshPassword = SshCredential.Password.ConvertToString();
                }
                if (!string.IsNullOrEmpty(SshPublicKey))
                {
                    parameters.SshPublicKey = SshPublicKey;
                }
            }

            if (DefaultStorageAccountType == null || DefaultStorageAccountType == StorageType.AzureStorage)
            {
                parameters.DefaultStorageInfo = new AzureStorageInfo(DefaultStorageAccountName, DefaultStorageAccountKey, DefaultStorageContainer);
            }
            else
            {
                parameters.DefaultStorageInfo = new AzureDataLakeStoreInfo(DefaultStorageAccountName, DefaultStorageRootPath);
            }

            foreach (
                var storageAccount in
                AdditionalStorageAccounts.Where(
                    storageAccount => !parameters.AdditionalStorageAccounts.ContainsKey(storageAccount.Key)))
            {
                parameters.AdditionalStorageAccounts.Add(storageAccount.Key, storageAccount.Value);
            }
            foreach (var config in Configurations.Where(config => !parameters.Configurations.ContainsKey(config.Key)))
            {
                parameters.Configurations.Add(config.Key, config.Value);
            }
            foreach (var action in ScriptActions.Where(action => parameters.ScriptActions.ContainsKey(action.Key)))
            {
                parameters.ScriptActions.Add(action.Key,
                                             action.Value.Select(a => a.GetScriptActionFromPSModel()).ToList());
            }
            foreach (var component in ComponentVersion.Where(component => !parameters.ComponentVersion.ContainsKey(component.Key)))
            {
                parameters.ComponentVersion.Add(component.Key, component.Value);
            }
            if (OozieMetastore != null)
            {
                var metastore = OozieMetastore;
                parameters.OozieMetastore = new Metastore(metastore.SqlAzureServerName, metastore.DatabaseName, metastore.Credential.UserName, metastore.Credential.Password.ConvertToString());
            }
            if (HiveMetastore != null)
            {
                var metastore = HiveMetastore;
                parameters.HiveMetastore = new Metastore(metastore.SqlAzureServerName, metastore.DatabaseName, metastore.Credential.UserName, metastore.Credential.Password.ConvertToString());
            }
            if (!string.IsNullOrEmpty(CertificatePassword))
            {
                if (!string.IsNullOrEmpty(CertificateFilePath))
                {
                    CertificateFileContents = File.ReadAllBytes(CertificateFilePath);
                }
                var servicePrincipal = new Management.HDInsight.Models.ServicePrincipal(
                    GetApplicationId(), GetTenantId(AadTenantId), CertificateFileContents,
                    CertificatePassword);

                parameters.Principal = servicePrincipal;
            }

            if (SecurityProfile != null)
            {
                parameters.SecurityProfile = new SecurityProfile()
                {
                    DirectoryType  = DirectoryType.ActiveDirectory,
                    Domain         = SecurityProfile.Domain,
                    DomainUsername =
                        SecurityProfile.DomainUserCredential != null
                            ? SecurityProfile.DomainUserCredential.UserName
                            : null,
                    DomainUserPassword =
                        SecurityProfile.DomainUserCredential != null &&
                        SecurityProfile.DomainUserCredential.Password != null
                            ? SecurityProfile.DomainUserCredential.Password.ConvertToString()
                            : null,
                    OrganizationalUnitDN = SecurityProfile.OrganizationalUnitDN,
                    LdapsUrls            = SecurityProfile.LdapsUrls,
                    ClusterUsersGroupDNs = SecurityProfile.ClusterUsersGroupDNs
                };
            }

            var cluster = HDInsightManagementClient.CreateNewCluster(ResourceGroupName, ClusterName, parameters);

            if (cluster != null)
            {
                WriteObject(new AzureHDInsightCluster(cluster.Cluster));
            }
        }
Esempio n. 26
0
        public void AddPostfixReleaseWithSuffixTest()
        {
            var version = new ComponentVersion("1.0.0-RE");

            Assert.Throws <InvalidOperationException>(delegate { version.SwitchSnapshotToRelease(postfix: "abc"); });
        }
        public override void ExecuteCmdlet()
        {
            foreach (var component in ComponentVersion.Where(component => !clusterComponentVersion.ContainsKey(component.Key)))
            {
                clusterComponentVersion.Add(component.Key, component.Value);
            }
            // Construct Configurations
            foreach (var config in Configurations.Where(config => !clusterConfigurations.ContainsKey(config.Key)))
            {
                clusterConfigurations.Add(config.Key, config.Value);
            }

            // Add cluster username/password to gateway config.
            ClusterCreateHelper.AddClusterCredentialToGatewayConfig(HttpCredential, clusterConfigurations);

            // Construct OS Profile
            OsProfile osProfile = ClusterCreateHelper.CreateOsProfile(SshCredential, SshPublicKey);

            // Construct Virtual Network Profile
            VirtualNetworkProfile vnetProfile = ClusterCreateHelper.CreateVirtualNetworkProfile(VirtualNetworkId, SubnetName);

            // Handle storage account
            StorageProfile storageProfile = new StorageProfile()
            {
                Storageaccounts = new List <StorageAccount> {
                }
            };

            if (StorageAccountType == null || StorageAccountType == StorageType.AzureStorage)
            {
                var azureStorageAccount = ClusterCreateHelper.CreateAzureStorageAccount(ClusterName, StorageAccountResourceId, StorageAccountKey, StorageContainer, this.DefaultContext.Environment.StorageEndpointSuffix);
                storageProfile.Storageaccounts.Add(azureStorageAccount);
            }
            else if (StorageAccountType == StorageType.AzureDataLakeStore)
            {
                ClusterCreateHelper.AddAzureDataLakeStorageGen1ToCoreConfig(StorageAccountResourceId, StorageRootPath, this.DefaultContext.Environment.AzureDataLakeStoreFileSystemEndpointSuffix, clusterConfigurations);
            }
            else if (StorageAccountType == StorageType.AzureDataLakeStorageGen2)
            {
                var adlsgen2Account = ClusterCreateHelper.CreateAdlsGen2StorageAccount(ClusterName, StorageAccountResourceId, StorageAccountKey, StorageFileSystem, StorageAccountManagedIdentity, this.DefaultContext.Environment.StorageEndpointSuffix);
                storageProfile.Storageaccounts.Add(adlsgen2Account);
            }

            // Handle additional storage accounts
            foreach (
                var storageAccount in
                AdditionalStorageAccounts.Where(
                    storageAccount => !clusterAdditionalStorageAccounts.ContainsKey(storageAccount.Key)))
            {
                clusterAdditionalStorageAccounts.Add(storageAccount.Key, storageAccount.Value);
            }
            ClusterCreateHelper.AddAdditionalStorageAccountsToCoreConfig(clusterAdditionalStorageAccounts, clusterConfigurations);

            // Handle script action
            foreach (var action in ScriptActions.Where(action => clusterScriptActions.ContainsKey(action.Key)))
            {
                clusterScriptActions.Add(action.Key,
                                         action.Value.Select(a => a.GetScriptActionFromPSModel()).ToList());
            }

            // Handle metastore
            if (OozieMetastore != null)
            {
                ClusterCreateHelper.AddOozieMetastoreToConfigurations(OozieMetastore, clusterConfigurations);
            }
            if (HiveMetastore != null)
            {
                ClusterCreateHelper.AddHiveMetastoreToConfigurations(HiveMetastore, clusterConfigurations);
            }

            // Handle ADLSGen1 identity
            if (!string.IsNullOrEmpty(CertificatePassword))
            {
                if (!string.IsNullOrEmpty(CertificateFilePath))
                {
                    CertificateFileContents = File.ReadAllBytes(CertificateFilePath);
                }

                ClusterCreateHelper.AddDataLakeStorageGen1IdentityToIdentityConfig(
                    GetApplicationId(ApplicationId), GetTenantId(AadTenantId), CertificateFileContents, CertificatePassword, clusterConfigurations,
                    this.DefaultContext.Environment.ActiveDirectoryAuthority, this.DefaultContext.Environment.DataLakeEndpointResourceId);
            }

            // Handle Kafka Rest Proxy
            KafkaRestProperties kafkaRestProperties = null;

            if (KafkaClientGroupId != null && KafkaClientGroupName != null)
            {
                kafkaRestProperties = new KafkaRestProperties()
                {
                    ClientGroupInfo = new ClientGroupInfo(KafkaClientGroupName, KafkaClientGroupId)
                };
            }

            // Compute profile contains headnode, workernode, zookeepernode, edgenode, kafkamanagementnode, idbrokernode, etc.
            ComputeProfile computeProfile = ClusterCreateHelper.CreateComputeProfile(osProfile, vnetProfile, clusterScriptActions, ClusterType, ClusterSizeInNodes, HeadNodeSize, WorkerNodeSize, ZookeeperNodeSize, EdgeNodeSize, KafkaManagementNodeSize, EnableIDBroker.IsPresent);

            // Handle SecurityProfile
            SecurityProfile securityProfile = ClusterCreateHelper.ConvertAzureHDInsightSecurityProfileToSecurityProfile(SecurityProfile, AssignedIdentity);

            // Handle DisksPerWorkerNode feature
            Role workerNode = Utils.ExtractRole(ClusterNodeType.WorkerNode.ToString(), computeProfile);

            if (DisksPerWorkerNode > 0)
            {
                workerNode.DataDisksGroups = new List <DataDisksGroups>()
                {
                    new DataDisksGroups()
                    {
                        DisksPerNode = DisksPerWorkerNode
                    }
                };
            }

            // Handle ClusterIdentity
            ClusterIdentity clusterIdentity = null;

            if (AssignedIdentity != null || StorageAccountManagedIdentity != null)
            {
                clusterIdentity = new ClusterIdentity
                {
                    Type = ResourceIdentityType.UserAssigned,
                    UserAssignedIdentities = new Dictionary <string, ClusterIdentityUserAssignedIdentitiesValue>()
                };
                if (AssignedIdentity != null)
                {
                    clusterIdentity.UserAssignedIdentities.Add(AssignedIdentity, new ClusterIdentityUserAssignedIdentitiesValue());
                }
                if (StorageAccountManagedIdentity != null)
                {
                    clusterIdentity.UserAssignedIdentities.Add(StorageAccountManagedIdentity, new ClusterIdentityUserAssignedIdentitiesValue());
                }
            }

            // Handle CMK feature
            DiskEncryptionProperties diskEncryptionProperties = null;

            if (EncryptionKeyName != null && EncryptionKeyVersion != null && EncryptionVaultUri != null)
            {
                diskEncryptionProperties = new DiskEncryptionProperties()
                {
                    KeyName             = EncryptionKeyName,
                    KeyVersion          = EncryptionKeyVersion,
                    VaultUri            = EncryptionVaultUri,
                    EncryptionAlgorithm = EncryptionAlgorithm != null ? EncryptionAlgorithm : JsonWebKeyEncryptionAlgorithm.RSAOAEP,
                    MsiResourceId       = AssignedIdentity
                };
            }

            // Handle encryption at host feature
            if (EncryptionAtHost != null)
            {
                if (diskEncryptionProperties != null)
                {
                    diskEncryptionProperties.EncryptionAtHost = EncryptionAtHost;
                }
                else
                {
                    diskEncryptionProperties = new DiskEncryptionProperties()
                    {
                        EncryptionAtHost = EncryptionAtHost
                    };
                }
            }

            // Handle autoscale featurer
            Autoscale autoscaleParameter = null;

            if (AutoscaleConfiguration != null)
            {
                autoscaleParameter = AutoscaleConfiguration.ToAutoscale();
                workerNode.AutoscaleConfiguration = autoscaleParameter;
            }

            // Construct cluster create parameter
            ClusterCreateParametersExtended createParams = new ClusterCreateParametersExtended
            {
                Location = Location,
                //Tags = Tags,  //To Do add this Tags parameter
                Properties = new ClusterCreateProperties
                {
                    Tier = ClusterTier,
                    ClusterDefinition = new ClusterDefinition
                    {
                        Kind             = ClusterType ?? "Hadoop",
                        ComponentVersion = clusterComponentVersion,
                        Configurations   = clusterConfigurations
                    },
                    ClusterVersion      = Version ?? "default",
                    KafkaRestProperties = kafkaRestProperties,
                    ComputeProfile      = computeProfile,
                    OsType                   = OSType,
                    SecurityProfile          = securityProfile,
                    StorageProfile           = storageProfile,
                    DiskEncryptionProperties = diskEncryptionProperties,
                    //handle Encryption In Transit feature
                    EncryptionInTransitProperties = EncryptionInTransit != null ? new EncryptionInTransitProperties()
                    {
                        IsEncryptionInTransitEnabled = EncryptionInTransit
                    } : null,
                    MinSupportedTlsVersion = MinSupportedTlsVersion
                },
                Identity = clusterIdentity
            };

            var cluster = HDInsightManagementClient.CreateCluster(ResourceGroupName, ClusterName, createParams);

            if (cluster != null)
            {
                WriteObject(new AzureHDInsightCluster(cluster));
            }
        }
Esempio n. 28
0
        public void ToSnapshotFromReleaseBareTest()
        {
            var version = new ComponentVersion("1.0.0").Operations().ToSnapshotWithVersionIncrement();

            Assert.That(version.Value, Is.EqualTo("1.0.1-SNAPSHOT"));
        }
Esempio n. 29
0
        public List <ComponentVersion> GetVersion()
        {
            List <ComponentVersion> list = new List <ComponentVersion>();

            ComponentVersion version = new ComponentVersion
            {
                version = Utils.GetApplicationVersion(),
                name    = "server"
            };

            list.Add(version);

            string versionExtra = Utils.GetApplicationExtraVersion();

            if (!string.IsNullOrEmpty(versionExtra))
            {
                version = new ComponentVersion
                {
                    version = versionExtra,
                    name    = "servercommit"
                };
                list.Add(version);
            }

            version = new ComponentVersion
            {
                version = Assembly.GetAssembly(typeof(FolderMappings)).GetName().Version.ToString(),
                name    = "commons"
            };
            list.Add(version);

            version = new ComponentVersion
            {
                version = Assembly.GetAssembly(typeof(AniDB_Anime)).GetName().Version.ToString(),
                name    = "models"
            };
            list.Add(version);

            /*version = new ComponentVersion
             * {
             *  version = Assembly.GetAssembly(typeof(INancyModule)).GetName().Version.ToString(),
             *  name = "Nancy"
             * };
             * list.Add(version);*/

            string dllpath = Assembly.GetEntryAssembly().Location;

            dllpath = Path.GetDirectoryName(dllpath);
            dllpath = Path.Combine(dllpath, "x86");
            dllpath = Path.Combine(dllpath, "MediaInfo.dll");

            if (System.IO.File.Exists(dllpath))
            {
                version = new ComponentVersion
                {
                    version = FileVersionInfo.GetVersionInfo(dllpath).FileVersion,
                    name    = "MediaInfo"
                };
                list.Add(version);
            }
            else
            {
                dllpath = Assembly.GetEntryAssembly().Location;
                dllpath = Path.GetDirectoryName(dllpath);
                dllpath = Path.Combine(dllpath, "x64");
                dllpath = Path.Combine(dllpath, "MediaInfo.dll");
                if (System.IO.File.Exists(dllpath))
                {
                    version = new ComponentVersion
                    {
                        version = FileVersionInfo.GetVersionInfo(dllpath).FileVersion,
                        name    = "MediaInfo"
                    };
                    list.Add(version);
                }
                else
                {
                    version = new ComponentVersion
                    {
                        version = @"DLL not found, using internal",
                        name    = "MediaInfo"
                    };
                    list.Add(version);
                }
            }

            if (System.IO.File.Exists("webui//index.ver"))
            {
                string   webui_version = System.IO.File.ReadAllText("webui//index.ver");
                string[] versions      = webui_version.Split('>');
                if (versions.Length == 2)
                {
                    version = new ComponentVersion
                    {
                        name    = "webui/" + versions[0],
                        version = versions[1]
                    };
                    list.Add(version);
                }
            }

            return(list);
        }
Esempio n. 30
0
        public void ToSnapshotFromSnapshotTest()
        {
            var version = new ComponentVersion("1.0.0-SNAPSHOT");

            Assert.Throws <InvalidOperationException>(delegate { version.Operations().ToSnapshotWithVersionIncrement(); });
        }