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] Regular expressions in CML continued

This is a follow up from my first post about CML reg exps.

#1 - Use double quotes.

Do not use single quotes like in the docs. That is certain.

#2 - Parenthesis not used that I can tell.

A CML delimited reg exp like this:

r"(one)|(two)|(three)"

...is pointless use of parenthesis unless Opsware plans on playing back the regular expressions later the way Apache's mod_rewrite can. If that were the case, then "$1" would play back the match from the reg exp "one". This sure would be useful in the drop-down list box in the SAS client when filling in values. The user could see all the possible legal values listed. However, SAS client does not do this.

The use of a single set of parenthesis is no better.

r"(one|two|three)"

The simpler regular expression:

r"one|two|three"

...works just fine. Of course, one would expect this to be true, but in the veiled deep that is Opsware, I feel that specifying it is necessary.

[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.

2008-10-24

[Opsware] boolean-(yes|no)-format="<string>" not working

In Opsware SAS 7.0 Policy Setter's Guide in "Appendix A: CML Tutorial and Reference", the following example is given.

@!boolean-yes-format="1";boolean-no-format="0"@

With the following explanation.

Defines the allowable boolean values in the configuration file. In this case, Yes is
indicated with the character 1, and No is indicated with a 0. This means that is a
user tried to use the string yes, the Application Configuration would not accept it.

Well, the SAS Client simply does not acknowledge these instructions. Here are my own usage attempts to get the SAS Client to work.

@!boolean-yes-format="on"@
@!boolean-no-format="off"@

and

@!boolean-yes-format="on";!boolean-no-format="off"@

and

KeepAlive @keep_alive;boolean;;boolean-yes-format="on";boolean-no-format="off"@

None of these worked inside the SAS client. When I tried to enter the default values, the client only gave me the choice of "True" or "False" and when I manually entered "on", it gave me the exception "com.opsware.acm.CMLFieldValidationException: TypeValidationError".

I have not solved this problem yet.

Ahhh, the memories.

While searching for useful information on Opsware, I ran across the below post on Usenet. NCSA Mosiac, packet driver DLLs for Windows 3.11, Novell Netware – those were the days.
Newsgroups: comp.infosystems
From: mfd...@cd4680fs.rrze.uni-erlangen.de (Andreas Bittorf)
Date: Wed, 2 Mar 1994 09:31:35 +0100
Subject: Packetdriver for winmosaic

Hello,
I want to install Mosaic for Windows. For this I need a packetdriver
(Novell, NE2000). Can anybody tell me where I can get one, e.g.
ftp-sites?
Back then, working on SGI boxes was such a delight in comparison to Windows. Now SGI is reduced to selling Linux running on Intel CPUs with NVIDIA graphics cards. Nostalgia is so bittersweet.

[Opsware] Bad Configuration Markup Language (CML) examples in docs

In the PDF Opsware SAS 7.0 Policy Setter's Guide, in "Appendix A: CML Tutorial and Reference", the following example is given.

RejectResponseUrl = @reject_response_url;string;r'(HTTP_URLSCAN_STATUS_HEADER)|(HTTP_URLSCAN_ORIGINAL_VERB)|(HTTP_URLSCAN_ORIGINAL_URL)';optional@

You'll find at least the following two errors, and both problems are with the range specification.

The subtle but annoying error is that single quotes are not allowed, only double-quotes. If you use single quotes, then Opsware Client will give you an error dialog with the message "Invalid range found on line:" and the detail "com.opsware.acm.CMLTemplateSyntaxException".

The obvious problem is the terrible regular expression. The entire thing should be in parenthesis, not each string. If you parenthesize each string, Opsware will really not be happy. You will get an error dialog with the message "An internal runtime error has occured" and the detail "java.lang.NullPointerException".

However, I just noticed that this is not always the case. This line, for example, will cause the null pointer exception.

LogLevel @log_level;string;r"(emerg)|(alert)|(crit)|(error)|(warn)|(notice)|(info)|(debug)"@

But this one will not.

ServerTokens @server_tokens;string;r"(Major)|(Minor)|(Min)|(Prod)|(OS)|(Full)"@

If I'm missing something obvious, feel free to swat me with a newspaper.

2008-10-23

[Opsware] vim syntax file for Configuration Markup Language (CML)

Here is my _very_ simple vim syntax file for Opsware's CML, that is, files that end in ".tpl"



" Vim syntax file
" Language: Opsware's Configuration Markup Language (CML)
" Maintainer: Jeffery Martin
" Last Change: 2008-10-07

" Setup
if version >= 600
if exists("b:current_syntax")
finish
endif
else
syntax clear
endif

syntax match cmlComment /@#.*$/

syntax region cmlComment start=/@##/ end=/#@/
syntax region cmlBlock start=/@[[:digit:]]/ end=/@/
syntax region cmlInstruction start=/@!/ end=/@/
syntax region cmlReplace start=/@[[:alpha:]]/ end=/@/

hi def link cmlBlock Label
hi def link cmlComment Comment
hi def link cmlInstruction PreProc
hi def link cmlReplace Identifier

let b:current_syntax = "cml"