Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP SQL Anywhere, on-demand edition 1.0 SP 6 » Task syntax

CreateRule task

Creates a rule that is enforced by the cloud.

Syntax 1 (SQL)
CALL DBCloud.CreateRule ( is_strict=is_strict, rule_definition=rule_definition, target_object_type=target_object_type [, optional-parameters ] )
Syntax 2 (Cloud Command utility)
dbcloudcmd run CreateRule is_strict rule_definition target_object_type [ optional-parameters ]
Parameters
  • rule_id

    An output parameter. Internal use only.

  • is_strict

    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)

  • rule_definition

    A search query that must hold for each target object. (Required)

  • target_object_type

    The type of object the rule applies to. Accepts an object type. (Required)

    The following values are supported:

    • Host

      A host.

    • Server

      A cloud server.

    • Database

      A tenant database.

  • target_object

    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.

  • target_tag

    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.

  • rule_name

    The name for the rule. The default is NULL.

  • user

    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.

Required privileges

CreateDropRule

Remarks
  • is_strict

    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.

  • rule_definition

    Specifies the syntax for the rule. Rules use similar syntax to searches.

  • target_object_type

    The rule applies only to the specified object type.

  • target_tag

    You can use this parameter to restrict the rule to objects with a specific tag.

  • rule_name

    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.

Example

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')"