예제 #1
0
        protected override void ProcessRecord()
        {
            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)
            {
                parameters.SshUserName = SshCredential.UserName;
                if (!string.IsNullOrEmpty(SshCredential.Password.ConvertToString()))
                {
                    parameters.SshPassword = SshCredential.Password.ConvertToString();
                }
                if (!string.IsNullOrEmpty(SshPublicKey))
                {
                    parameters.SshPublicKey = SshPublicKey;
                }
            }

            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());
            }
            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.OozieMetastore = new Metastore(metastore.SqlAzureServerName, metastore.DatabaseName, metastore.Credential.UserName, metastore.Credential.Password.ConvertToString());
            }

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

            if (cluster != null)
            {
                WriteObject(new AzureHDInsightCluster(cluster.Cluster));
            }
        }
 public ITemplate Build()
 {
     HeadActions.ToTemplate(_template);
     ScriptActions.ToTemplate(_template);
     StyleActions.ToTemplate(_template);
     BodyActions.ToTemplate(_template);
     InitializationActions.ToTemplate(_template);
     return(_template);
 }
 public ITemplateDefinition AddScriptLine(string javaScript)
 {
     ScriptActions.Add(r =>
     {
         r.Html.Write(javaScript);
         r.Html.WriteLine();
     });
     return(this);
 }
        public ITemplateDefinition AddTemplate(string templatePath)
        {
            _nameManager.AddResolutionHandler(NameResolutionPhase.ResolveElementReferences, nm =>
            {
                AddConsumerNeeds(nm.ResolveTemplate(templatePath) as IDataConsumer);
            });

            HeadActions.Add(r =>
            {
                var t = _nameManager.ResolveTemplate(templatePath);
                if (t != null)
                {
                    t.WritePageArea(r, PageArea.Head);
                }
            });

            ScriptActions.Add(r =>
            {
                var t = _nameManager.ResolveTemplate(templatePath);
                if (t != null)
                {
                    t.WritePageArea(r, PageArea.Scripts);
                }
            });

            StyleActions.Add(r =>
            {
                var t = _nameManager.ResolveTemplate(templatePath);
                if (t != null)
                {
                    t.WritePageArea(r, PageArea.Styles);
                }
            });

            BodyActions.Add(r =>
            {
                var t = _nameManager.ResolveTemplate(templatePath);
                if (t != null)
                {
                    t.WritePageArea(r, PageArea.Body);
                }
            });

            InitializationActions.Add(r =>
            {
                var t = _nameManager.ResolveTemplate(templatePath);
                if (t != null)
                {
                    t.WritePageArea(r, PageArea.Initialization);
                }
            });

            return(this);
        }
        public ITemplateDefinition AddTemplate(ITemplate template)
        {
            HeadActions.Add(r => template.WritePageArea(r, PageArea.Head));
            ScriptActions.Add(r => template.WritePageArea(r, PageArea.Scripts));
            StyleActions.Add(r => template.WritePageArea(r, PageArea.Styles));
            BodyActions.Add(r => template.WritePageArea(r, PageArea.Body));
            InitializationActions.Add(r => template.WritePageArea(r, PageArea.Initialization));

            AddConsumerNeeds(template as IDataConsumer);

            return(this);
        }
예제 #6
0
    private void ProcessScriptData(FileEntry file, List <XMLTagLookup> lookup)
    {
        /*ScriptData script = new ScriptData(new BinaryReader(file.FileStream()));
         * if (script.Root is Dictionary<string, object>)
         * {
         *
         * }*/
        Stream str = file.FileStream();
        string xml = ScriptActions.GetConverter("scriptdata", "script_cxml").export(str, true);

        str = null;
        this.ProcessXML(file, lookup, xml);
    }
        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;
                parameters.SshPassword = SshCredential.Password.ConvertToString();
            }
            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);
            }
            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.OozieMetastore = new Metastore(metastore.SqlAzureServerName, metastore.DatabaseName, metastore.Credential.UserName, metastore.Credential.Password.ConvertToString());
            }

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

            if (cluster != null)
            {
                WriteObject(new AzureHDInsightCluster(cluster.Cluster));
            }
        }
예제 #8
0
        public static void Run(List <string> args, int i)
        {
            if (args.Count < 2)
            {
                throw new InvalidArgumentLengthException("Expected 2 arguments but got " + args.Count + " for command \"lights\" at line " + i + ".");
            }

            var _fixedName = args[0].Trim().ToUpper();
            var HCZOnly    = false;

            if (_fixedName == "HCZ")
            {
                HCZOnly = true;
            }
            else if (_fixedName != "ALL")
            {
                throw new InvalidArgumentException("Invalid argument for command \"lights\" on line " + i + ", argument 0. Expected \"HCZ/ALL\" but got \"" + args[0] + "\".");
            }

            if (!int.TryParse(args[1].Trim(), out var time))
            {
                throw new InvalidArgumentException("Invalid argument for command \"lights\" on line " + i + ", argument 1. Expected \"INT\" but got \"" + args[1] + "\".");
            }

            if (args.Count == 3)
            {
                if (!int.TryParse(args[2].Trim(), out var delay))
                {
                    throw new InvalidArgumentException("Invalid argument for command \"lights\" on line " + i + ", argument 2. Expected \"INT\" but got \"" + args[2] + "\".");
                }

                ScriptActions.GetDelay(delay).lights.Add(new LightData(HCZOnly, time));
            }
            else
            {
                ScriptActions.scriptData.lights.Add(new LightData(HCZOnly, time));
            }
        }
예제 #9
0
        public static void Run(List <string> args, int i)
        {
            if (args.Count < 1)
            {
                throw new InvalidArgumentLengthException("Expected 1 argument but got 0 for command \"teleport\" at line " + i + ".");
            }

            if (args.Count < 4)
            {
                var roleInfo = RoleInfo.parseRole(args[0], "teleport", i, 0);

                var door = UnityEngine.Object.FindObjectsOfType <DoorNametagExtension>().FirstOrDefault(_door => _door.GetName.Trim().ToUpper() == args[1].Trim().ToUpper());
                if (door == null)
                {
                    throw new InvalidArgumentException("Invalid argument for command \"teleport\" on line " + i + ", argument 1. The door name specified is not valid.");
                }

                if (!PlayerMovementSync.FindSafePosition(door.transform.position, out var pos))
                {
                    throw new CommandErrorException("No safe position could be found for door \"" + door.name + "\".");
                }

                if (args.Count == 3)
                {
                    if (!int.TryParse(args[2].Trim(), out var delay))
                    {
                        throw new InvalidArgumentException("Invalid argument for command \"teleport\" on line " + i + ", argument 2. Expected \"INT\" but got \"" + args[2] + "\".");
                    }

                    ScriptActions.GetDelay(delay).teleportIds.Add(new TeleportData(pos, roleInfo));
                }
                else
                {
                    ScriptActions.scriptData.teleportIds.Add(new TeleportData(pos, roleInfo));
                }
            }
            else
            {
                var roleInfo = RoleInfo.parseRole(args[0], "teleport", i, 0);

                if (!int.TryParse(args[1].Trim(), out var x))
                {
                    throw new InvalidArgumentException("Invalid argument for command \"teleport\" on line " + i + ", argument 1. Expected \"INT\" but got \"" + args[1] + "\".");
                }
                if (!int.TryParse(args[2].Trim(), out var y))
                {
                    throw new InvalidArgumentException("Invalid argument for command \"teleport\" on line " + i + ", argument 2. Expected \"INT\" but got \"" + args[2] + "\".");
                }
                if (!int.TryParse(args[3].Trim(), out var z))
                {
                    throw new InvalidArgumentException("Invalid argument for command \"teleport\" on line " + i + ", argument 3. Expected \"INT\" but got \"" + args[3] + "\".");
                }

                if (args.Count == 5)
                {
                    if (!int.TryParse(args[4].Trim(), out var delay))
                    {
                        throw new InvalidArgumentException("Invalid argument for command \"teleport\" on line " + i + ", argument 2. Expected \"INT\" but got \"" + args[2] + "\".");
                    }

                    ScriptActions.GetDelay(delay).teleportIds.Add(new TeleportData(new Vector3(x, y, z), roleInfo));
                }
                else
                {
                    ScriptActions.scriptData.teleportIds.Add(new TeleportData(new Vector3(x, y, z), roleInfo));
                }
            }
        }
예제 #10
0
 public void register()
 {
     Console.WriteLine("Register");
     ScriptActions.RegisterScript(new HashlistOutputter());
 }
예제 #11
0
        private void LoadConverters()
        {
            ScriptActions.AddConverter(new FormatConverter
            {
                Key         = "script_cxml",
                Title       = "Custom XML",
                Extension   = "xml",
                ExportEvent = (MemoryStream ms, bool escape) =>
                {
                    try
                    {
                        Dictionary <string, object> root = new ScriptData(new BinaryReader(ms), Utils.IsRaid()).Root;
                        return(new CustomXMLNode("table", root, "").ToString(0, escape));
                    } catch (Exception e)
                    {
                        MessageBox.Show($"Failed to read scriptdata: \n {e.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return(null);
                    }
                },
                Type = "scriptdata"
            });

            //Temporary until I get source code of this DLL, hopefully.
            ScriptActions.AddConverter(new FormatConverter
            {
                Key               = "stream",
                Title             = "Stream to Wav",
                RequiresAttention = false,
                Extension         = "wav",
                Type              = "stream",
                SaveEvent         = (Stream stream, string toPath) =>
                {
                    WavFile file = new WavFile(stream);
                    WavProcessor.ConvertToPCM(file);
                    file.WriteFile(toPath);
                },
            });

            ScriptActions.AddConverter(new FormatConverter
            {
                Key         = "diesel_strings",
                Title       = "Diesel",
                Extension   = "strings",
                ImportEvent = (path) => new StringsFile(path),
                Type        = "strings"
            });

            ScriptActions.AddConverter(new FormatConverter
            {
                Key               = "movie",
                Title             = "Bink Video",
                Extension         = "bik",
                Type              = "movie",
                RequiresAttention = false
            });

            //Loop each XML format to have it automatically get .xml suffix

            ScriptActions.AddConverter(new FormatConverter
            {
                Key               = "xmL_conversion",
                Type              = "text",
                Extension         = "xml",
                RequiresAttention = false
            });

            ScriptActions.AddConverter(new FormatConverter
            {
                Key               = "texture_dds",
                Title             = "DDS",
                Extension         = "dds",
                Type              = "texture",
                RequiresAttention = false
            });

            ScriptActions.AddConverter(new FormatConverter
            {
                Key         = "strings_csv",
                Title       = "CSV",
                Extension   = "csv",
                ExportEvent = (MemoryStream ms, bool arg0) =>
                {
                    //Excel doesn't seem to like it?
                    StringsFile str       = new StringsFile(ms);
                    StringBuilder builder = new StringBuilder();
                    builder.Append("ID,String\n");
                    foreach (var entry in str.LocalizationStrings)
                    {
                        builder.Append("\"" + entry.ID.ToString() + "\",\"" + entry.Text + "\"\n");
                    }
                    Console.WriteLine(builder.ToString());
                    return(builder.ToString());
                },
                Type = "strings"
            });

            ScriptActions.AddConverter(new FormatConverter
            {
                Key         = "script_json",
                Title       = "JSON",
                Extension   = "json",
                ExportEvent = (MemoryStream ms, bool arg0) =>
                {
                    try
                    {
                        ScriptData sdata = new ScriptData(new BinaryReader(ms), Utils.IsRaid());
                        return((new JSONNode("table", sdata.Root, "")).ToString());
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show($"Failed to read scriptdata: \n {e.Message}", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                        return(null);
                    }
                },
                Type = "scriptdata"
            });

            ScriptActions.AddConverter(new FormatConverter
            {
                Key         = "strings_json",
                Title       = "JSON",
                Extension   = "json",
                ExportEvent = (MemoryStream ms, bool arg0) =>
                {
                    StringsFile str       = new StringsFile(ms);
                    StringBuilder builder = new StringBuilder();
                    builder.Append("{\n");
                    for (int i = 0; i < str.LocalizationStrings.Count; i++)
                    {
                        StringEntry entry = str.LocalizationStrings[i];
                        builder.Append("\t");
                        builder.Append("\"" + entry.ID + "\" : \"" + entry.Text + "\"");
                        if (i < str.LocalizationStrings.Count - 1)
                        {
                            builder.Append(",");
                        }
                        builder.Append("\n");
                    }
                    builder.Append("}");
                    Console.WriteLine(builder.ToString());
                    return(builder.ToString());
                },
                Type = "strings"
            });
        }
예제 #12
0
        public static void Run(List <string> args, int i)
        {
            if (args.Count < 1)
            {
                throw new InvalidArgumentLengthException("Expected 1 argument but got 0 for command \"spawn\" at line " + i + ".");
            }

            var    finalClassId   = -1;
            string finalClassRole = null;
            var    sum            = 0;
            var    classIds       = new List <SpawnData>();

            for (var y = 0; y < args.Count; y++)
            {
                var argEls = args[y].Split(',');

                if (argEls.Length < 1)
                {
                    throw new InvalidArgumentException("Invalid argument for command \"spawn\" on line " + i + ", argument " + y + ". Expected \"(0-17),(0-100),(0+)\" but got \"" + args[y] + "\".");
                }

                if (argEls.Length == 1)
                {
                    if (y != args.Count - 1 || finalClassId != -1)
                    {
                        throw new InvalidArgumentException("Invalid argument for command \"spawn\" on line " + i + ", argument " + y + ". Expected \"(0-17),(0-100),(0+)\" but got \"" + args[y] + "\".");
                    }

                    var classId = -1;

                    var roleInfo = RoleInfo.parseRole(argEls[0], "spawn", i, y);
                    classId        = roleInfo.classId;
                    finalClassRole = roleInfo.roleID;

                    if (classId < 0 || classId > 17)
                    {
                        throw new InvalidArgumentException("Invalid argument for command \"spawn\" on line " + i + ", argument " + y + ". Expected \"(0-17),(0-100),(0+)\" but got \"" + args[y] + "\".");
                    }

                    finalClassId = classId;
                }
                else if (argEls.Length == 3)
                {
                    var    roleInfo = RoleInfo.parseRole(argEls[0], "spawn", i, y);
                    var    classId  = roleInfo.classId;
                    string role     = roleInfo.roleID;

                    if (!int.TryParse(argEls[1], out var chance) || !int.TryParse(argEls[2], out var min))
                    {
                        throw new InvalidArgumentException("Invalid argument for command \"spawn\" on line " + i + ", argument " + y + ". Expected \"(0-17),(0-100),(0+)\" but got \"" + args[y] + "\".");
                    }
                    if (classId < 0 || classId > 17 || chance < 0 || chance > 100 || min < 0)
                    {
                        throw new InvalidArgumentException("Invalid argument for command \"spawn\" on line " + i + ", argument " + y + ". Expected \"(0-17),(0-100),(0+)\" but got \"" + args[y] + "\".");
                    }

                    sum += chance;
                    classIds.Add(new SpawnData(chance, min, new RoleInfo(role, classId)));
                }
                else
                {
                    throw new InvalidArgumentException("Invalid argument for command \"spawn\" on line " + i + ", argument " + y + ". Expected \"(0-17),(0-100),(0+)\" but got \"" + args[y] + "\".");
                }
            }

            if (sum > 100)
            {
                throw new InvalidArgumentException("Invalid arguments for command \"spawn\" on line " + i + ", argument. The sum of spawn chances should never exceed 100. Got " + sum + ".");
            }

            ScriptActions.SetCustomSpawn(classIds, new RoleInfo(finalClassRole, finalClassId), i, ScriptActions.scriptData);
        }
예제 #13
0
 public void register()
 {
     Console.WriteLine("Register HeistExtractor");
     ScriptActions.RegisterScript(new HeistExtractor());
 }
        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));
            }
        }
        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)
            {
                parameters.SshUserName = SshCredential.UserName;
                if (!string.IsNullOrEmpty(SshCredential.Password.ConvertToString()))
                {
                    parameters.SshPassword = SshCredential.Password.ConvertToString();
                }
                if (!string.IsNullOrEmpty(SshPublicKey))
                {
                    parameters.SshPublicKey = SshPublicKey;
                }
            }

            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());
            }
            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;
            }

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

            if (cluster != null)
            {
                WriteObject(new AzureHDInsightCluster(cluster.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));
            }
        }
예제 #17
0
 public void register()
 {
     Console.WriteLine("Register Conv");
     ScriptActions.RegisterConverter(new ParserTesting());
     ScriptActions.RegisterConverter(new StringsView());
 }
        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));
            }
        }
예제 #19
0
 public void register()
 {
     Console.WriteLine("Register");
     ScriptActions.RegisterConverter(new JSONConv());
     //ScriptDefs.RegisterImport(new CXMLImport());
 }
예제 #20
0
    private void ProcessWorld(FileEntry file)
    {
        foreach (KeyValuePair <string, IChild> child in file.Parent.Children)
        {
            if (child.Value is FileEntry)
            {
                this.WriteFile(child.Value as FileEntry);
            }
        }

        this.WriteFile(file);
        this.ProcessScriptData(file, new List <XMLTagLookup> {
            new XMLTagLookup {
                node_name = "environment_values", value = new[] { "environment" }, Converter = (hash) => { return(hash + ".environment"); }
            }
        });

        string   continents_file = Path.Combine(Path.GetDirectoryName(file.Path), "continents").Replace("\\", "/");
        Idstring ids             = HashIndex.Get(continents_file);
        var      t_ids           = new Tuple <Idstring, Idstring, Idstring>(ids, new Idstring(0), HashIndex.Get("continents"));

        if (this._browser.RawFiles.ContainsKey(t_ids))
        {
            FileEntry c_file = this._browser.RawFiles[t_ids];
            this.WriteFile(c_file);

            string xml = ScriptActions.GetConverter("scriptdata", "script_cxml").export(c_file.FileStream(), true);

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.LoadXml(xml);
                foreach (XmlNode child in doc.ChildNodes[0])
                {
                    this.ProcessFile(Path.Combine(Path.GetDirectoryName(file.Path), string.Format("{0}/{0}.continent", child.Attributes.GetNamedItem("name").Value)).Replace("\\", "/"));
                }
            }
            catch (Exception exc)
            {
                this.error_output.Write("Exception occured on file: {0}\n", c_file.Path);
                if (xml != null)
                {
                    this.error_output.Write(xml + "\n");
                }
                this.error_output.Write(exc.Message + "\n");
                this.error_output.Write(exc.StackTrace + "\n");
                this.error_output.Flush();
                return;
            }
        }
        else
        {
            this.error_output.Write("Continents file {0} does not exist!\n", continents_file);
        }

        string   mission_file = Path.Combine(Path.GetDirectoryName(file.Path), "mission").Replace("\\", "/");
        Idstring m_ids        = HashIndex.Get(mission_file);
        var      t_m_ids      = new Tuple <Idstring, Idstring, Idstring>(m_ids, new Idstring(0), HashIndex.Get("mission"));

        if (this._browser.RawFiles.ContainsKey(t_m_ids))
        {
            FileEntry m_file = this._browser.RawFiles[t_m_ids];
            this.WriteFile(m_file);

            string xml = ScriptActions.GetConverter("scriptdata", "script_cxml").export(m_file.FileStream(), true);

            XmlDocument doc = new XmlDocument();

            try
            {
                doc.LoadXml(xml);
                foreach (XmlNode child in doc.ChildNodes[0])
                {
                    this.ProcessFile(Path.Combine(Path.GetDirectoryName(file.Path), string.Format("{0}.mission", child.Attributes.GetNamedItem("file").Value)).Replace("\\", "/"));
                }
            }
            catch (Exception exc)
            {
                this.error_output.Write("Exception occured on file: {0}\n", m_file.Path);
                if (xml != null)
                {
                    this.error_output.Write(xml + "\n");
                }
                this.error_output.Write(exc.Message + "\n");
                this.error_output.Write(exc.StackTrace + "\n");
                this.error_output.Flush();
                return;
            }
        }
        else
        {
            this.error_output.Write("Mission file {0} does not exist!\n", continents_file);
        }

        this.error_output.Flush();
    }
예제 #21
0
        public static void Run(List <string> args, int i, string cmd)
        {
            if (args.Count < 3 && cmd != "cassie")
            {
                throw new InvalidArgumentLengthException("Expected 2 arguments but got " + args.Count + " for command \"" + cmd + "\" at line " + i + ".");
            }
            if (cmd == "cassie" && args.Count < 1)
            {
                throw new InvalidArgumentLengthException("Expected 1 argument but got " + args.Count + " for command \"" + cmd + "\" at line " + i + ".");
            }

            RoleInfo role     = null;
            var      duration = 0;

            if (cmd != "cassie")
            {
                role = RoleInfo.parseRole(args[0], cmd, i, 1);
                args.RemoveAt(0);

                if (!int.TryParse(args[0].Trim(), out duration))
                {
                    throw new InvalidArgumentException("Invalid argument for command \"" + cmd + "\" on line " + i + ", argument 1. Expected \"INT\" but got \"" + args[0] + "\".");
                }
                args.RemoveAt(0);
            }

            if (int.TryParse(args.Last(), out var delay))
            {
                args.pop();
            }

            var data = new TextData(args[0].Trim('"'), role, duration);

            switch (cmd)
            {
            case "cassie":
                if (delay == -1)
                {
                    ScriptActions.scriptData.cassie.Add(data);
                }
                else
                {
                    ScriptActions.GetDelay(delay).cassie.Add(data);
                }
                break;

            case "broadcast":
                if (delay == -1)
                {
                    ScriptActions.scriptData.broadcast.Add(data);
                }
                else
                {
                    ScriptActions.GetDelay(delay).broadcast.Add(data);
                }
                break;

            case "hint":
                if (delay == -1)
                {
                    ScriptActions.scriptData.hint.Add(data);
                }
                else
                {
                    ScriptActions.GetDelay(delay).hint.Add(data);
                }
                break;
            }
        }