Creates a rule that is enforced by the cloud.
CALL DBCloud.CreateRule ( is_strict=is_strict, rule_definition=rule_definition, target_object_type=target_object_type [, optional-parameters ] )
dbcloudcmd run CreateRule is_strict rule_definition target_object_type [ optional-parameters ]
An output parameter. Internal use only.
Set to 1 for a strict rule. Set to 0 for a weak rule. If set to 1, then target_object or target_tag must be specified. (Required)
A search query that must hold for each target object. (Required)
The type of object the rule applies to. Accepts an object type. (Required)
The following values are supported:
A cloud server.
A tenant database.
The single object the rule applies to. Accepts a search query that identifies one object that is of the same type as that defined for the target_object_type parameter, for example an object name or ID. The default is NULL.
The tag the rule applies to. Accepts a search query that identifies one tag, for example a tag name or ID. The default is NULL.
The name for the rule. The default is NULL.
The owner of the rule. Accepts a search query that identifies one user, for example a user name or ID. The default is the current user.
Specifies whether the rule is a strict rule or a weak rule. When creating a strict rule, you must specify either target_object_id or target_tag_id.
Specifies the syntax for the rule. Rules use similar syntax to searches.
The rule applies only to the specified object type.
You can use this parameter to restrict the rule to objects with a specific tag.
If you do not specify a value for the rule_name parameter (or you set the value to NULL), then the cloud generates a unique name for the rule.
The following command creates a weak rule that specifies that the database Demo cannot run on the same host as the database Test.
dbcloudcmd run CreateRule is_strict=0 rule_definition="type:host and type:database and name:Demo and type:server and name:my-server#3" target_object_type=database target_object="Test" rule_name=TestandDemoOnDifferentHostsDatabasesRunOnServer3Rule
The following command creates a weak rule that specifies that every host must be tagged with one of the following countries: Canada, the US, or the UK:
dbcloudcmd run CreateRule is_strict=0 rule_definition="not(tag:Canada or tag:US or tag:UK)" target_object_type=Host rule_name=CountryRule
The following command creates a weak rule named CompanyARule that specifies that all databases must have the tag CloudyTag:
dbcloudcmd run ExecuteTaskBatch "CALL DBCloud.CreateRule (null,0,'not tag:CloudyTag', 'database',null,null,'CompanyARule')"