Showing posts with label CML. Show all posts
Showing posts with label CML. Show all posts

2008-10-28

[Opsware] Stanza abstraction loop in CML

I'm trying to abstract out the logic necessary to have a single CML markup section/stanza which loops through and adds as many <Directory> sections as specified in the Application Configuration in the SAS client.

I'm not even pretending that this should work in the first version of my syntax. I know it does not before even testing it. However, I need to black box my way into hammering out the correct syntax. Here is my first experimental attempt.

@1*directory;;;ordered-lines@
<Directory @.path;dir@>
@2*directives;;;ordered-lines@
@.directive;string@ @.argument;string@
@2]@
</Directory>
@1]@


Obviously, it does not work. It won't even pass Preview. The error is:

com.opsware.acm.CMLFileGenerationException: A value required to create this configuration was missing. Key: com.opsware.acm.CMLFileParsingException: Did not find a match for: "<Directory />" line: 88

[Opsware] Unhappy CML loop or block syntax.

I just hit this one. I have no idea what the problem might be right now. The syntax snippet.

@1[;ordered-lines@
<IfModule mod_alias.c>
@2*script_alias@
ScriptAlias @.url_path;dir@ @.file_ath;dir@
@2]@
@2*alias@
Alias @.url_path;dir@ @.file_path;dir@
@2]@
</IfModule>
@1]@


Here is the error message on a Preview operation in the SAS client.

com.opsware.acm.CMLFileGenerationException: Did not find a match for: "TextTag(<IfModule)" line: 99

Update:


The problem was the loops (alias and script_alias) not being optional and not having any values specified.

If I want the entire stanza, including the IfModule section delimiters, to not appear if there are no values, then the correct syntax is:

@1[;optional@
<IfModule mod_alias.c>
@2*script_alias;;;optional@
ScriptAlias @.url_path;dir@ @.file_ath;dir@
@2]@
</IfModule>
@1]@


If I want the IfModule section delimiters to appear even if there is nothing between them, then this syntax works without errors.

<IfModule mod_alias.c>
@2*script_alias;;;optional@
ScriptAlias @.url_path;dir@ @.file_ath;dir@
@2]@
</IfModule>


But using the optional option with just the loop and not the block will still cause the error I described above.

[Opsware] line-comment="#" not working

Here is my entire CML file at this point. I've pared it down to almost nothing in order to debug this.

@!filename-key="/Apache/conf/httpd_conf";filename-default="/opt/Apache/conf/httpd.conf"@
@!line-comment="#"@
@!missing-values-are-null@
@!namespace=/Apache/@
@!ordered-lines@

# Main
ServerRoot @server_root;dir;;optional@
DocumentRoot @document_root;dir;;optional@
# Bart


But, when I attempt a Preview or Push from the SAS client, I get this error message.

com.opsware.acm.CMLFileGenerationException: Did not find a match for: "TextTag(#)" line: 4

From what? I see nothing in the CML docs from Opsware SAS 7.0 Policy Setter's Guide that indicates the number sign (#) is special by itself or that there is such a thing as a "TextTag".

Here is my entire httpd.conf from the machine Opsware is managing.

me@mybox:/opt/Apache/conf
$ cat httpd.conf
# Main
ServerRoot /some/dir
DocumentRoot /some/dir
# Bart


Update:

I just discovered something. I have the setting Preserve Format = no for the template. This is important.

Also, when I removed the line-comment instruction, the Preview and Push operations did not return an error.