The structure of the CustomSettings.ini

It is important to understand the structure of the customsettings.ini file before we look at the rule processing options. The file is structured into sections. These sections give you the ability to customize how properties are gathered.
在深入规则实施之前,我们需要明白customsettings.ini文件结构的重要性。customsettings.ini文件分为几个部分,这些部分使得你可以自定义如何收集参数

Settings section

This section is divided into two lines, priority and properties which define properties to be gathered and the rule processing order. 这个部分由两行组成,priority和properties,properties定义了那些将被收集和应用于的规则实施的参数
Priority
The rules are processed according to the section they belong. This line determines the order in which rules should be processed. Values are assigned to a property on a first come first served basis. 这条规则根据所属的section执行。它决定了执行的优先顺序——写在前面的先执行
For example with the priority line below if a value is specified in the “Default” and “CSettings” sections the “CSettings” section will take precedence.
例如,有两个个section,“default”、“CSettings”,“CSettings”写在前面先执行
[Settings]
Priority=CSettings,Default
[Default]
OSInstall=Yes
Computername=Computer1
[CSettings]
Computername=MyComputer
Note: When the property is a list then each subsequent value will be added to the list.
注意:当参数是一个列表,每一个子序列值将会被加到列表中。
Properties
BDD defines its standard properties via the ZTIGather.xml file, these properties do not have to be explicitly defined. In some scenarios the standard properties may not be adequate for your requirements. In these cases you can define custom properties. These can be used within all BDD scripts. Custom properties are defined on the “Properties” line.
BDD通过ZTIGather.xml来定义标准参数,这些参数并不需要全部定义。在一些方案中,并不是所有的标准参数都适用。有时你需要定义自己的参数用于所有的BDD脚本。自定义参数用于“Properties”行
For example if you wanted to create a new disk partitioning script that would configure partitions according to custom partition sizes, you would define these properties in this section as follows.
例如,你想创建一个硬盘分区脚本,你可以定义: 
[Settings]
Properties=Partition1Size,Partition2Size
These properties would then be available to use in all BDD scripts. 那么这些参数将可以在所有BDD脚本中使用

Rule Sections

Once you have defined the rules processing order and any custom variables you can then assign values to these properties.一旦定义了参数,你就可以把任意的值赋给这些参数
Default
Rules that you wish to be applied to all computers are generally specified in the default section. These values could be values such as the time zone or the BDD Deployment Root. 所有电脑都适用的规则。可以是时区等等
Custom Sections
There are three custom section types, dynamic, database or static.
有三种自定义section类型,dynamic, database or static
Dynamic sections
Using variables such as make model or default gateway you can dynamically specify rules.
For example if you specified “Priority=Make” and the make is “Dell Corporation” BDD will look for a section called “Dell Corporation” and will then process any rules in that section.
使用那些根据规则动态变化的变量,例如make model或者default gataway。
例如你想让“Priority=Make”,make为“Dell Corporation”。BDD会寻找一个section为“Dell Corporation”的,并自动使用这个section中的规则
[Settings]
Priority=Make,…
[Dell Corporation]
ComputerName=”DellComputer”
Database sections
This will perform a database lookup and return a single record. It will then assign the values of any column that matches a BDD property to that property.
查询数据库并返回一个记录。然后将得到的参数值赋给BDD的属性
BDD automatically recognizes database sections based on the information they contain. The information is used to connect to the DB and construct a select statement which retrieves values from the DB. BDD自动根据section的信息辨认数据库。这些信息用于连接数据库并读取需要的数据
The following variables are used to declare DB connectivity requirements:
以下变量用于声明数据库连接需求 
    • SQLServer - This is the SQL Server hosting the DB you wish to connect to.服务器名称
    • Instance – The name of the instance of SQL Server to be used for querying property values. 实例
    • Port – The number of the port to connect to the SQL server, if required 端口
    • Netlib –The protocol to be used in communicating with the SQL Server. DBNMPNTW – Named pipes, DBMSSOCN –TCP/IP Sockets 命名管道或者是tcpip接口
    • Database – The name of the database to be used for querying property values 数据库名称
    • Table – The name of the table or view to be queried for property values. 查找属性的表
    • Parameters – The list of parameters to pass to the database query 数据库查询的参数值列表
    • Order - The sorting order for the result set on a database query. 数据库查询排列方式
    • SQLShare – Any share on the SQL server. You need to connect to a UNC path to get a secure named pipes connection as WinPE is not a member of the domain.数据库服务器的共享
The best way to explain this section is by an example:
例如:
[MSettings]
SQLServer=SERVER1
Instance=SQLEXPRESS
Port=1433
Netlib=DBNMPNTW
Database=BDDAdminDB
Table=MachineDetails
Parameters=AssetTag
SQLShare=Logs
This will connect to the machine using the share \\SERVER1\Logs , then establish a connection the DB using the first four properties. Once this has been established it will then execute the following dynamically created select statement. 根据前四个值和sqlshare,BDD建立与数据库的连接并查询
SELECT * FROM MachineDetails WHERE AssetTag = ‘%AssetTag%’
This will perform a search for records where the AssetTag value is equal to that of the current machine. It will return any column values that match the standard properties or any custom properties declared in the properties section. 这将会查询AssetTag并返回所有符合要求的标准属性或者自定义属性
So for example if the column ComputerName had a value “Desktop1” it would update the ComputerName property within BDD with that value.如果ComputerName列中有一个值为“Desktop1”,将会更新ComputerName属性并把这个值传递给bdd
It is also possible to retrieve information from databases other than the BDD database. To make these database lookups more flexible it is possible to translate the column names. 那么从其他数据库读取信息而不仅仅是BDD数据库是可能的。转换列名称以利于数据库更加方便查询也是可能的
Say for example you want to perform a query of a table where the column name of the table does not match the value of that we want to retrieve. In this case we can create mappings that translate these values.例如你想要查询一张表,而里面的列名称并不相符。我们创建一个映射来讲这些转换为所需要的,就像下面的将Computer转换为Computername
For example if we want to connect to an asset management database to retrieve the computer name. Unfortunately records within this table do not have a “ComputerName” column. However it does have a “computer” column. To retrieve this value we simply add a line to the database section which will translate the column value:
Computername=Computer
Static sections
This is simply a section that is defined in the priority line that is not a dynamic or database section.

0

收藏

xmuxsp

207篇文章,86W+人气,2粉丝

Ctrl+Enter 发布

发布

取消

深入BDD规则实施(rule processing)(2)
深入BDD规则实施(rule processing)(2)

扫一扫,领取大礼包

0

分享
深入BDD规则实施(rule processing)(2)
xmuxsp
深入BDD规则实施(rule processing)(2)