You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Dalrymple, Craig - OCIO-ITS, Kansas City, MO" <Cr...@kcc.usda.gov> on 2012/10/02 00:01:39 UTC

Having trouble doing math with values retrieved from external data source

First, I apologize if this question has come up before, but after doing some lengthy searching, I was unable to find anything related to the issue I am having.

I have included the segment of the template that is causing my headache below.  Let me explain a little what I am doing, and give a background on why.

The client I work for has a product from Cisco (Cisco Configuration Engine) for configuring large numbers of network devices.  We are trying to make this rather cumbersome tool a bit easier to use.  Basically what it does is keep a database of information about each object that can be included into templates, which are then deployed to those objects to keep configurations close to a uniform standard.  This tool supports two template formats, the legacy and proprietary .cfgtpl, and .vm which is based on the Velocity Template Engine.  Their legacy format allows for some simplification with #include directives and very limited conditional checking --
#if (a == b)
  Do this
#else
  Do something else
#endif

By limited I mean you can check for equality, and thats all you can check.  Oh, and you cannot have nested condition tests.  Obviously, Velocity doesn't have this limitation, even on the older version that Cisco has deployed (1.4).

One of the simplifications we would like to include is to handle IP addressing for these network elements.  Currently this is input by users, and may or may not be accurate.  Since the clients IP addresses conform to a pretty strict standard, the only information we really need is the subnet, and the subnet mask.  With this, we can compute the IP addresses.

Below is the segment that has me going even more prematurely bald.  I am trying to break an IP4 address into its four parts given the subnet information, then assign the CER IP address (my side of the MPLS connection) by adding 1 to this value, and the PER (carrier side) by adding 2.  I have managed to break the address up into a list, and can access the elements directly.  However, when I try to manipulate the values it becomes really obvious that I am trying to do addition to strings and not integers.

#set ( $wanSubnet = $!{dsobj.getValue('WAN-Subnet')} ) ## retrieves data from database
! breakupIP($wanSubnet) ## this is a Cisco IOS comment line.  It is the only way I can really debug my code, and is included so I can verify that I am getting data.
#breakupIP($wanSubnet) ## macro to break apart the IP address.
! third octet is $addressParts.get(2) ##same as above.
#set ( $octetFour = $addressParts.get(3) ) ## I don't want to change the original value.
! octetFour is $octetFour ## yet another display
#set ( $wanCEIP = $octetFour + 1) ## the math
#set ( $wanPEIP = $octetFour + 2 )
! wanCEIP = $wanCEIP ## display the results.
! wanPEIP = $wanPEIP

The output generated is below.  Realize this is part of a much larger template, and I pretty much have to work within the limitations of the tool.

!
! breakupIP(192.168.100.100)
! third octet is 100
! octetFour is 100
! wanCEIP = $wanCEIP
! wanPEIP = $wanPEIP
!

Any help would be appreciated; I am just learning how to do this.


Craig K. Dalrymple
Information Services Consultant (Contractor)
FMI/Unisys Inc. working for
USDA/OCIO/ITS/IOD/NOB
FMI(BPA # AG-3144-B-12-0003)
6501 Beacon Drive
Kansas City, MO 64113
816-926-8819  (W)





This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


RE: Having trouble doing math with values retrieved from external data source

Posted by "Dalrymple, Craig - OCIO-ITS, Kansas City, MO" <Cr...@kcc.usda.gov>.
Yes.  Good to see my dyslexia is working at 100%.

I will sheepishly crawl back under my rock now....

Craig K. Dalrymple
Information Services Consultant (Contractor)
FMI/Unisys Inc. working for
USDA/OCIO/ITS/IOD/NOB
FMI(BPA # AG-3144-B-12-0003)
6501 Beacon Drive
Kansas City, MO 64113
816-926-8819  (W)


-----Original Message-----
From: Sergiu Dumitriu [mailto:sergiu.dumitriu@gmail.com]
Sent: Tuesday, October 02, 2012 1:03 PM
To: Velocity Users List
Subject: Re: Having trouble doing math with values retrieved from external data source

On 10/02/2012 01:55 PM, Dalrymple, Craig - OCIO-ITS, Kansas City, MO wrote:
> Could the following issue be related to the 1.4 engine, or to the way Cisco has it implemented?
>
> Source:
> #set ($county=$!{dsobj.getValue('Location-CountyName')})
> #set ($county=$county.toLowerCase())
> #if ($county.lentgh() > 8) ## check to see if the county name is longer than 8

Do you really have lentgh instead of length in your code?

>    ! true
>    hostname $county.substring(0,8)$!{dsobj.getValue('Location-FIPSCode')}$!{dsobj.getValue('Device-Instance')}
> #else
>    ! false
>    hostname $county$!{dsobj.getValue('Location-FIPSCode')}$!{dsobj.getValue('Device-Instance')}
> #end
>
> Output:
> ! false
> hostname stelsewhere99
> !
>
> Clearly, the length is more than 8....
>


--
Sergiu Dumitriu
http://purl.org/net/sergiu/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org






This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.

Re: Having trouble doing math with values retrieved from external data source

Posted by Sergiu Dumitriu <se...@gmail.com>.
On 10/02/2012 01:55 PM, Dalrymple, Craig - OCIO-ITS, Kansas City, MO wrote:
> Could the following issue be related to the 1.4 engine, or to the way Cisco has it implemented?
>
> Source:
> #set ($county=$!{dsobj.getValue('Location-CountyName')})
> #set ($county=$county.toLowerCase())
> #if ($county.lentgh() > 8) ## check to see if the county name is longer than 8

Do you really have lentgh instead of length in your code?

>    ! true
>    hostname $county.substring(0,8)$!{dsobj.getValue('Location-FIPSCode')}$!{dsobj.getValue('Device-Instance')}
> #else
>    ! false
>    hostname $county$!{dsobj.getValue('Location-FIPSCode')}$!{dsobj.getValue('Device-Instance')}
> #end
>
> Output:
> ! false
> hostname stelsewhere99
> !
>
> Clearly, the length is more than 8....
> 	


-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


RE: Having trouble doing math with values retrieved from external data source

Posted by "Dalrymple, Craig - OCIO-ITS, Kansas City, MO" <Cr...@kcc.usda.gov>.
Could the following issue be related to the 1.4 engine, or to the way Cisco has it implemented?

Source:
#set ($county=$!{dsobj.getValue('Location-CountyName')})
#set ($county=$county.toLowerCase())
#if ($county.lentgh() > 8) ## check to see if the county name is longer than 8 
  ! true
  hostname $county.substring(0,8)$!{dsobj.getValue('Location-FIPSCode')}$!{dsobj.getValue('Device-Instance')}
#else
  ! false
  hostname $county$!{dsobj.getValue('Location-FIPSCode')}$!{dsobj.getValue('Device-Instance')}
#end

Output:
! false
hostname stelsewhere99
!

Clearly, the length is more than 8....
	

Craig K. Dalrymple
Information Services Consultant (Contractor)
FMI/Unisys Inc. working for
USDA/OCIO/ITS/IOD/NOB
FMI(BPA # AG-3144-B-12-0003)
6501 Beacon Drive
Kansas City, MO 64113
816-926-8819  (W)


-----Original Message-----
From: Nathan Bubna [mailto:nbubna@gmail.com] 
Sent: Tuesday, October 02, 2012 11:25 AM
To: Velocity Users List
Subject: Re: Having trouble doing math with values retrieved from external data source

Well, so long as you have other reasons too. :)  Just stay far away
from 1.5.  1.6 or 1.7 have far fewer issues.

On Tue, Oct 2, 2012 at 8:53 AM, Dalrymple, Craig - OCIO-ITS, Kansas
City, MO <Cr...@kcc.usda.gov> wrote:
> There are some other things that are available with later releases that I would like to take advantage of, like the $foreach.count.  That appears to be a 1.6 and later capablility.
>
> Craig K. Dalrymple
> Information Services Consultant (Contractor)
> FMI/Unisys Inc. working for
> USDA/OCIO/ITS/IOD/NOB
> FMI(BPA # AG-3144-B-12-0003)
> 6501 Beacon Drive
> Kansas City, MO 64113
> 816-926-8819  (W)
>
>
> -----Original Message-----
> From: Nathan Bubna [mailto:nbubna@gmail.com]
> Sent: Tuesday, October 02, 2012 10:47 AM
> To: Velocity Users List
> Subject: Re: Having trouble doing math with values retrieved from external data source
>
> Glad it worked for you.  If you're not doing new dev and this is your
> only issue, i'd stick with 1.4, despite its inferiority.  Never
> upgrade just for the sake of upgrading.
>
> On Tue, Oct 2, 2012 at 8:19 AM, Dalrymple, Craig - OCIO-ITS, Kansas
> City, MO <Cr...@kcc.usda.gov> wrote:
>> Thanks, this might actually work, however my test device was removed, so now I have other issues.  However, this is basically what I was trying to do, but you came up with a different approach.
>>
>> At last check, Cisco has no plans to go any higher than 1.4.  It's not a product that accounts for much (any?) revenue, so why pursue it?  I am considering doing the upgrade myself, but I need to stand up another test box to make sure I don't break anything else -- the software appears pretty fickle to changes.
>>
>> Craig K. Dalrymple
>> Information Services Consultant (Contractor)
>> FMI/Unisys Inc. working for
>> USDA/OCIO/ITS/IOD/NOB
>> FMI(BPA # AG-3144-B-12-0003)
>> 6501 Beacon Drive
>> Kansas City, MO 64113
>> 816-926-8819  (W)
>>
>> -----Original Message-----
>> From: Nathan Bubna [mailto:nbubna@gmail.com]
>> Sent: Monday, October 01, 2012 6:18 PM
>> To: Velocity Users List
>> Subject: Re: Having trouble doing math with values retrieved from external data source
>>
>> Velocity 1.4, eh?  I suppose upgrading to 1.7 isn't an option?
>>
>> With 1.4, you have a hack:
>>
>> #set( $Integer = 1 )
>> #set( $wanCEIP = $Integer.parseInt($octetFour) + 1)
>>
>> or you can google for VelocityTools' MathTool, drop an instance in the
>> context and use that to handle the parsing and/or addition in a
>> cleaner way:
>>
>> #set( $wanCEIP = $math.add($octetFour, 1) )
>>
>> On Mon, Oct 1, 2012 at 3:01 PM, Dalrymple, Craig - OCIO-ITS, Kansas
>> City, MO <Cr...@kcc.usda.gov> wrote:
>>> First, I apologize if this question has come up before, but after doing some lengthy searching, I was unable to find anything related to the issue I am having.
>>>
>>> I have included the segment of the template that is causing my headache below.  Let me explain a little what I am doing, and give a background on why.
>>>
>>> The client I work for has a product from Cisco (Cisco Configuration Engine) for configuring large numbers of network devices.  We are trying to make this rather cumbersome tool a bit easier to use.  Basically what it does is keep a database of information about each object that can be included into templates, which are then deployed to those objects to keep configurations close to a uniform standard.  This tool supports two template formats, the legacy and proprietary .cfgtpl, and .vm which is based on the Velocity Template Engine.  Their legacy format allows for some simplification with #include directives and very limited conditional checking --
>>> #if (a == b)
>>>   Do this
>>> #else
>>>   Do something else
>>> #endif
>>>
>>> By limited I mean you can check for equality, and thats all you can check.  Oh, and you cannot have nested condition tests.  Obviously, Velocity doesn't have this limitation, even on the older version that Cisco has deployed (1.4).
>>>
>>> One of the simplifications we would like to include is to handle IP addressing for these network elements.  Currently this is input by users, and may or may not be accurate.  Since the clients IP addresses conform to a pretty strict standard, the only information we really need is the subnet, and the subnet mask.  With this, we can compute the IP addresses.
>>>
>>> Below is the segment that has me going even more prematurely bald.  I am trying to break an IP4 address into its four parts given the subnet information, then assign the CER IP address (my side of the MPLS connection) by adding 1 to this value, and the PER (carrier side) by adding 2.  I have managed to break the address up into a list, and can access the elements directly.  However, when I try to manipulate the values it becomes really obvious that I am trying to do addition to strings and not integers.
>>>
>>> #set ( $wanSubnet = $!{dsobj.getValue('WAN-Subnet')} ) ## retrieves data from database
>>> ! breakupIP($wanSubnet) ## this is a Cisco IOS comment line.  It is the only way I can really debug my code, and is included so I can verify that I am getting data.
>>> #breakupIP($wanSubnet) ## macro to break apart the IP address.
>>> ! third octet is $addressParts.get(2) ##same as above.
>>> #set ( $octetFour = $addressParts.get(3) ) ## I don't want to change the original value.
>>> ! octetFour is $octetFour ## yet another display
>>> #set ( $wanCEIP = $octetFour + 1) ## the math
>>> #set ( $wanPEIP = $octetFour + 2 )
>>> ! wanCEIP = $wanCEIP ## display the results.
>>> ! wanPEIP = $wanPEIP
>>>
>>> The output generated is below.  Realize this is part of a much larger template, and I pretty much have to work within the limitations of the tool.
>>>
>>> !
>>> ! breakupIP(192.168.100.100)
>>> ! third octet is 100
>>> ! octetFour is 100
>>> ! wanCEIP = $wanCEIP
>>> ! wanPEIP = $wanPEIP
>>> !
>>>
>>> Any help would be appreciated; I am just learning how to do this.
>>>
>>>
>>> Craig K. Dalrymple
>>> Information Services Consultant (Contractor)
>>> FMI/Unisys Inc. working for
>>> USDA/OCIO/ITS/IOD/NOB
>>> FMI(BPA # AG-3144-B-12-0003)
>>> 6501 Beacon Drive
>>> Kansas City, MO 64113
>>> 816-926-8819  (W)
>>>
>>>
>>>
>>>
>>>
>>> This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: Having trouble doing math with values retrieved from external data source

Posted by Nathan Bubna <nb...@gmail.com>.
Well, so long as you have other reasons too. :)  Just stay far away
from 1.5.  1.6 or 1.7 have far fewer issues.

On Tue, Oct 2, 2012 at 8:53 AM, Dalrymple, Craig - OCIO-ITS, Kansas
City, MO <Cr...@kcc.usda.gov> wrote:
> There are some other things that are available with later releases that I would like to take advantage of, like the $foreach.count.  That appears to be a 1.6 and later capablility.
>
> Craig K. Dalrymple
> Information Services Consultant (Contractor)
> FMI/Unisys Inc. working for
> USDA/OCIO/ITS/IOD/NOB
> FMI(BPA # AG-3144-B-12-0003)
> 6501 Beacon Drive
> Kansas City, MO 64113
> 816-926-8819  (W)
>
>
> -----Original Message-----
> From: Nathan Bubna [mailto:nbubna@gmail.com]
> Sent: Tuesday, October 02, 2012 10:47 AM
> To: Velocity Users List
> Subject: Re: Having trouble doing math with values retrieved from external data source
>
> Glad it worked for you.  If you're not doing new dev and this is your
> only issue, i'd stick with 1.4, despite its inferiority.  Never
> upgrade just for the sake of upgrading.
>
> On Tue, Oct 2, 2012 at 8:19 AM, Dalrymple, Craig - OCIO-ITS, Kansas
> City, MO <Cr...@kcc.usda.gov> wrote:
>> Thanks, this might actually work, however my test device was removed, so now I have other issues.  However, this is basically what I was trying to do, but you came up with a different approach.
>>
>> At last check, Cisco has no plans to go any higher than 1.4.  It's not a product that accounts for much (any?) revenue, so why pursue it?  I am considering doing the upgrade myself, but I need to stand up another test box to make sure I don't break anything else -- the software appears pretty fickle to changes.
>>
>> Craig K. Dalrymple
>> Information Services Consultant (Contractor)
>> FMI/Unisys Inc. working for
>> USDA/OCIO/ITS/IOD/NOB
>> FMI(BPA # AG-3144-B-12-0003)
>> 6501 Beacon Drive
>> Kansas City, MO 64113
>> 816-926-8819  (W)
>>
>> -----Original Message-----
>> From: Nathan Bubna [mailto:nbubna@gmail.com]
>> Sent: Monday, October 01, 2012 6:18 PM
>> To: Velocity Users List
>> Subject: Re: Having trouble doing math with values retrieved from external data source
>>
>> Velocity 1.4, eh?  I suppose upgrading to 1.7 isn't an option?
>>
>> With 1.4, you have a hack:
>>
>> #set( $Integer = 1 )
>> #set( $wanCEIP = $Integer.parseInt($octetFour) + 1)
>>
>> or you can google for VelocityTools' MathTool, drop an instance in the
>> context and use that to handle the parsing and/or addition in a
>> cleaner way:
>>
>> #set( $wanCEIP = $math.add($octetFour, 1) )
>>
>> On Mon, Oct 1, 2012 at 3:01 PM, Dalrymple, Craig - OCIO-ITS, Kansas
>> City, MO <Cr...@kcc.usda.gov> wrote:
>>> First, I apologize if this question has come up before, but after doing some lengthy searching, I was unable to find anything related to the issue I am having.
>>>
>>> I have included the segment of the template that is causing my headache below.  Let me explain a little what I am doing, and give a background on why.
>>>
>>> The client I work for has a product from Cisco (Cisco Configuration Engine) for configuring large numbers of network devices.  We are trying to make this rather cumbersome tool a bit easier to use.  Basically what it does is keep a database of information about each object that can be included into templates, which are then deployed to those objects to keep configurations close to a uniform standard.  This tool supports two template formats, the legacy and proprietary .cfgtpl, and .vm which is based on the Velocity Template Engine.  Their legacy format allows for some simplification with #include directives and very limited conditional checking --
>>> #if (a == b)
>>>   Do this
>>> #else
>>>   Do something else
>>> #endif
>>>
>>> By limited I mean you can check for equality, and thats all you can check.  Oh, and you cannot have nested condition tests.  Obviously, Velocity doesn't have this limitation, even on the older version that Cisco has deployed (1.4).
>>>
>>> One of the simplifications we would like to include is to handle IP addressing for these network elements.  Currently this is input by users, and may or may not be accurate.  Since the clients IP addresses conform to a pretty strict standard, the only information we really need is the subnet, and the subnet mask.  With this, we can compute the IP addresses.
>>>
>>> Below is the segment that has me going even more prematurely bald.  I am trying to break an IP4 address into its four parts given the subnet information, then assign the CER IP address (my side of the MPLS connection) by adding 1 to this value, and the PER (carrier side) by adding 2.  I have managed to break the address up into a list, and can access the elements directly.  However, when I try to manipulate the values it becomes really obvious that I am trying to do addition to strings and not integers.
>>>
>>> #set ( $wanSubnet = $!{dsobj.getValue('WAN-Subnet')} ) ## retrieves data from database
>>> ! breakupIP($wanSubnet) ## this is a Cisco IOS comment line.  It is the only way I can really debug my code, and is included so I can verify that I am getting data.
>>> #breakupIP($wanSubnet) ## macro to break apart the IP address.
>>> ! third octet is $addressParts.get(2) ##same as above.
>>> #set ( $octetFour = $addressParts.get(3) ) ## I don't want to change the original value.
>>> ! octetFour is $octetFour ## yet another display
>>> #set ( $wanCEIP = $octetFour + 1) ## the math
>>> #set ( $wanPEIP = $octetFour + 2 )
>>> ! wanCEIP = $wanCEIP ## display the results.
>>> ! wanPEIP = $wanPEIP
>>>
>>> The output generated is below.  Realize this is part of a much larger template, and I pretty much have to work within the limitations of the tool.
>>>
>>> !
>>> ! breakupIP(192.168.100.100)
>>> ! third octet is 100
>>> ! octetFour is 100
>>> ! wanCEIP = $wanCEIP
>>> ! wanPEIP = $wanPEIP
>>> !
>>>
>>> Any help would be appreciated; I am just learning how to do this.
>>>
>>>
>>> Craig K. Dalrymple
>>> Information Services Consultant (Contractor)
>>> FMI/Unisys Inc. working for
>>> USDA/OCIO/ITS/IOD/NOB
>>> FMI(BPA # AG-3144-B-12-0003)
>>> 6501 Beacon Drive
>>> Kansas City, MO 64113
>>> 816-926-8819  (W)
>>>
>>>
>>>
>>>
>>>
>>> This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>>> For additional commands, e-mail: user-help@velocity.apache.org
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


RE: Having trouble doing math with values retrieved from external data source

Posted by "Dalrymple, Craig - OCIO-ITS, Kansas City, MO" <Cr...@kcc.usda.gov>.
There are some other things that are available with later releases that I would like to take advantage of, like the $foreach.count.  That appears to be a 1.6 and later capablility.

Craig K. Dalrymple
Information Services Consultant (Contractor)
FMI/Unisys Inc. working for
USDA/OCIO/ITS/IOD/NOB
FMI(BPA # AG-3144-B-12-0003)
6501 Beacon Drive
Kansas City, MO 64113
816-926-8819  (W)


-----Original Message-----
From: Nathan Bubna [mailto:nbubna@gmail.com] 
Sent: Tuesday, October 02, 2012 10:47 AM
To: Velocity Users List
Subject: Re: Having trouble doing math with values retrieved from external data source

Glad it worked for you.  If you're not doing new dev and this is your
only issue, i'd stick with 1.4, despite its inferiority.  Never
upgrade just for the sake of upgrading.

On Tue, Oct 2, 2012 at 8:19 AM, Dalrymple, Craig - OCIO-ITS, Kansas
City, MO <Cr...@kcc.usda.gov> wrote:
> Thanks, this might actually work, however my test device was removed, so now I have other issues.  However, this is basically what I was trying to do, but you came up with a different approach.
>
> At last check, Cisco has no plans to go any higher than 1.4.  It's not a product that accounts for much (any?) revenue, so why pursue it?  I am considering doing the upgrade myself, but I need to stand up another test box to make sure I don't break anything else -- the software appears pretty fickle to changes.
>
> Craig K. Dalrymple
> Information Services Consultant (Contractor)
> FMI/Unisys Inc. working for
> USDA/OCIO/ITS/IOD/NOB
> FMI(BPA # AG-3144-B-12-0003)
> 6501 Beacon Drive
> Kansas City, MO 64113
> 816-926-8819  (W)
>
> -----Original Message-----
> From: Nathan Bubna [mailto:nbubna@gmail.com]
> Sent: Monday, October 01, 2012 6:18 PM
> To: Velocity Users List
> Subject: Re: Having trouble doing math with values retrieved from external data source
>
> Velocity 1.4, eh?  I suppose upgrading to 1.7 isn't an option?
>
> With 1.4, you have a hack:
>
> #set( $Integer = 1 )
> #set( $wanCEIP = $Integer.parseInt($octetFour) + 1)
>
> or you can google for VelocityTools' MathTool, drop an instance in the
> context and use that to handle the parsing and/or addition in a
> cleaner way:
>
> #set( $wanCEIP = $math.add($octetFour, 1) )
>
> On Mon, Oct 1, 2012 at 3:01 PM, Dalrymple, Craig - OCIO-ITS, Kansas
> City, MO <Cr...@kcc.usda.gov> wrote:
>> First, I apologize if this question has come up before, but after doing some lengthy searching, I was unable to find anything related to the issue I am having.
>>
>> I have included the segment of the template that is causing my headache below.  Let me explain a little what I am doing, and give a background on why.
>>
>> The client I work for has a product from Cisco (Cisco Configuration Engine) for configuring large numbers of network devices.  We are trying to make this rather cumbersome tool a bit easier to use.  Basically what it does is keep a database of information about each object that can be included into templates, which are then deployed to those objects to keep configurations close to a uniform standard.  This tool supports two template formats, the legacy and proprietary .cfgtpl, and .vm which is based on the Velocity Template Engine.  Their legacy format allows for some simplification with #include directives and very limited conditional checking --
>> #if (a == b)
>>   Do this
>> #else
>>   Do something else
>> #endif
>>
>> By limited I mean you can check for equality, and thats all you can check.  Oh, and you cannot have nested condition tests.  Obviously, Velocity doesn't have this limitation, even on the older version that Cisco has deployed (1.4).
>>
>> One of the simplifications we would like to include is to handle IP addressing for these network elements.  Currently this is input by users, and may or may not be accurate.  Since the clients IP addresses conform to a pretty strict standard, the only information we really need is the subnet, and the subnet mask.  With this, we can compute the IP addresses.
>>
>> Below is the segment that has me going even more prematurely bald.  I am trying to break an IP4 address into its four parts given the subnet information, then assign the CER IP address (my side of the MPLS connection) by adding 1 to this value, and the PER (carrier side) by adding 2.  I have managed to break the address up into a list, and can access the elements directly.  However, when I try to manipulate the values it becomes really obvious that I am trying to do addition to strings and not integers.
>>
>> #set ( $wanSubnet = $!{dsobj.getValue('WAN-Subnet')} ) ## retrieves data from database
>> ! breakupIP($wanSubnet) ## this is a Cisco IOS comment line.  It is the only way I can really debug my code, and is included so I can verify that I am getting data.
>> #breakupIP($wanSubnet) ## macro to break apart the IP address.
>> ! third octet is $addressParts.get(2) ##same as above.
>> #set ( $octetFour = $addressParts.get(3) ) ## I don't want to change the original value.
>> ! octetFour is $octetFour ## yet another display
>> #set ( $wanCEIP = $octetFour + 1) ## the math
>> #set ( $wanPEIP = $octetFour + 2 )
>> ! wanCEIP = $wanCEIP ## display the results.
>> ! wanPEIP = $wanPEIP
>>
>> The output generated is below.  Realize this is part of a much larger template, and I pretty much have to work within the limitations of the tool.
>>
>> !
>> ! breakupIP(192.168.100.100)
>> ! third octet is 100
>> ! octetFour is 100
>> ! wanCEIP = $wanCEIP
>> ! wanPEIP = $wanPEIP
>> !
>>
>> Any help would be appreciated; I am just learning how to do this.
>>
>>
>> Craig K. Dalrymple
>> Information Services Consultant (Contractor)
>> FMI/Unisys Inc. working for
>> USDA/OCIO/ITS/IOD/NOB
>> FMI(BPA # AG-3144-B-12-0003)
>> 6501 Beacon Drive
>> Kansas City, MO 64113
>> 816-926-8819  (W)
>>
>>
>>
>>
>>
>> This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: Having trouble doing math with values retrieved from external data source

Posted by Nathan Bubna <nb...@gmail.com>.
Glad it worked for you.  If you're not doing new dev and this is your
only issue, i'd stick with 1.4, despite its inferiority.  Never
upgrade just for the sake of upgrading.

On Tue, Oct 2, 2012 at 8:19 AM, Dalrymple, Craig - OCIO-ITS, Kansas
City, MO <Cr...@kcc.usda.gov> wrote:
> Thanks, this might actually work, however my test device was removed, so now I have other issues.  However, this is basically what I was trying to do, but you came up with a different approach.
>
> At last check, Cisco has no plans to go any higher than 1.4.  It's not a product that accounts for much (any?) revenue, so why pursue it?  I am considering doing the upgrade myself, but I need to stand up another test box to make sure I don't break anything else -- the software appears pretty fickle to changes.
>
> Craig K. Dalrymple
> Information Services Consultant (Contractor)
> FMI/Unisys Inc. working for
> USDA/OCIO/ITS/IOD/NOB
> FMI(BPA # AG-3144-B-12-0003)
> 6501 Beacon Drive
> Kansas City, MO 64113
> 816-926-8819  (W)
>
> -----Original Message-----
> From: Nathan Bubna [mailto:nbubna@gmail.com]
> Sent: Monday, October 01, 2012 6:18 PM
> To: Velocity Users List
> Subject: Re: Having trouble doing math with values retrieved from external data source
>
> Velocity 1.4, eh?  I suppose upgrading to 1.7 isn't an option?
>
> With 1.4, you have a hack:
>
> #set( $Integer = 1 )
> #set( $wanCEIP = $Integer.parseInt($octetFour) + 1)
>
> or you can google for VelocityTools' MathTool, drop an instance in the
> context and use that to handle the parsing and/or addition in a
> cleaner way:
>
> #set( $wanCEIP = $math.add($octetFour, 1) )
>
> On Mon, Oct 1, 2012 at 3:01 PM, Dalrymple, Craig - OCIO-ITS, Kansas
> City, MO <Cr...@kcc.usda.gov> wrote:
>> First, I apologize if this question has come up before, but after doing some lengthy searching, I was unable to find anything related to the issue I am having.
>>
>> I have included the segment of the template that is causing my headache below.  Let me explain a little what I am doing, and give a background on why.
>>
>> The client I work for has a product from Cisco (Cisco Configuration Engine) for configuring large numbers of network devices.  We are trying to make this rather cumbersome tool a bit easier to use.  Basically what it does is keep a database of information about each object that can be included into templates, which are then deployed to those objects to keep configurations close to a uniform standard.  This tool supports two template formats, the legacy and proprietary .cfgtpl, and .vm which is based on the Velocity Template Engine.  Their legacy format allows for some simplification with #include directives and very limited conditional checking --
>> #if (a == b)
>>   Do this
>> #else
>>   Do something else
>> #endif
>>
>> By limited I mean you can check for equality, and thats all you can check.  Oh, and you cannot have nested condition tests.  Obviously, Velocity doesn't have this limitation, even on the older version that Cisco has deployed (1.4).
>>
>> One of the simplifications we would like to include is to handle IP addressing for these network elements.  Currently this is input by users, and may or may not be accurate.  Since the clients IP addresses conform to a pretty strict standard, the only information we really need is the subnet, and the subnet mask.  With this, we can compute the IP addresses.
>>
>> Below is the segment that has me going even more prematurely bald.  I am trying to break an IP4 address into its four parts given the subnet information, then assign the CER IP address (my side of the MPLS connection) by adding 1 to this value, and the PER (carrier side) by adding 2.  I have managed to break the address up into a list, and can access the elements directly.  However, when I try to manipulate the values it becomes really obvious that I am trying to do addition to strings and not integers.
>>
>> #set ( $wanSubnet = $!{dsobj.getValue('WAN-Subnet')} ) ## retrieves data from database
>> ! breakupIP($wanSubnet) ## this is a Cisco IOS comment line.  It is the only way I can really debug my code, and is included so I can verify that I am getting data.
>> #breakupIP($wanSubnet) ## macro to break apart the IP address.
>> ! third octet is $addressParts.get(2) ##same as above.
>> #set ( $octetFour = $addressParts.get(3) ) ## I don't want to change the original value.
>> ! octetFour is $octetFour ## yet another display
>> #set ( $wanCEIP = $octetFour + 1) ## the math
>> #set ( $wanPEIP = $octetFour + 2 )
>> ! wanCEIP = $wanCEIP ## display the results.
>> ! wanPEIP = $wanPEIP
>>
>> The output generated is below.  Realize this is part of a much larger template, and I pretty much have to work within the limitations of the tool.
>>
>> !
>> ! breakupIP(192.168.100.100)
>> ! third octet is 100
>> ! octetFour is 100
>> ! wanCEIP = $wanCEIP
>> ! wanPEIP = $wanPEIP
>> !
>>
>> Any help would be appreciated; I am just learning how to do this.
>>
>>
>> Craig K. Dalrymple
>> Information Services Consultant (Contractor)
>> FMI/Unisys Inc. working for
>> USDA/OCIO/ITS/IOD/NOB
>> FMI(BPA # AG-3144-B-12-0003)
>> 6501 Beacon Drive
>> Kansas City, MO 64113
>> 816-926-8819  (W)
>>
>>
>>
>>
>>
>> This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
>> For additional commands, e-mail: user-help@velocity.apache.org
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


RE: Having trouble doing math with values retrieved from external data source

Posted by "Dalrymple, Craig - OCIO-ITS, Kansas City, MO" <Cr...@kcc.usda.gov>.
Thanks, this might actually work, however my test device was removed, so now I have other issues.  However, this is basically what I was trying to do, but you came up with a different approach.

At last check, Cisco has no plans to go any higher than 1.4.  It's not a product that accounts for much (any?) revenue, so why pursue it?  I am considering doing the upgrade myself, but I need to stand up another test box to make sure I don't break anything else -- the software appears pretty fickle to changes.

Craig K. Dalrymple
Information Services Consultant (Contractor)
FMI/Unisys Inc. working for
USDA/OCIO/ITS/IOD/NOB
FMI(BPA # AG-3144-B-12-0003)
6501 Beacon Drive
Kansas City, MO 64113
816-926-8819  (W)

-----Original Message-----
From: Nathan Bubna [mailto:nbubna@gmail.com] 
Sent: Monday, October 01, 2012 6:18 PM
To: Velocity Users List
Subject: Re: Having trouble doing math with values retrieved from external data source

Velocity 1.4, eh?  I suppose upgrading to 1.7 isn't an option?

With 1.4, you have a hack:

#set( $Integer = 1 )
#set( $wanCEIP = $Integer.parseInt($octetFour) + 1)

or you can google for VelocityTools' MathTool, drop an instance in the
context and use that to handle the parsing and/or addition in a
cleaner way:

#set( $wanCEIP = $math.add($octetFour, 1) )

On Mon, Oct 1, 2012 at 3:01 PM, Dalrymple, Craig - OCIO-ITS, Kansas
City, MO <Cr...@kcc.usda.gov> wrote:
> First, I apologize if this question has come up before, but after doing some lengthy searching, I was unable to find anything related to the issue I am having.
>
> I have included the segment of the template that is causing my headache below.  Let me explain a little what I am doing, and give a background on why.
>
> The client I work for has a product from Cisco (Cisco Configuration Engine) for configuring large numbers of network devices.  We are trying to make this rather cumbersome tool a bit easier to use.  Basically what it does is keep a database of information about each object that can be included into templates, which are then deployed to those objects to keep configurations close to a uniform standard.  This tool supports two template formats, the legacy and proprietary .cfgtpl, and .vm which is based on the Velocity Template Engine.  Their legacy format allows for some simplification with #include directives and very limited conditional checking --
> #if (a == b)
>   Do this
> #else
>   Do something else
> #endif
>
> By limited I mean you can check for equality, and thats all you can check.  Oh, and you cannot have nested condition tests.  Obviously, Velocity doesn't have this limitation, even on the older version that Cisco has deployed (1.4).
>
> One of the simplifications we would like to include is to handle IP addressing for these network elements.  Currently this is input by users, and may or may not be accurate.  Since the clients IP addresses conform to a pretty strict standard, the only information we really need is the subnet, and the subnet mask.  With this, we can compute the IP addresses.
>
> Below is the segment that has me going even more prematurely bald.  I am trying to break an IP4 address into its four parts given the subnet information, then assign the CER IP address (my side of the MPLS connection) by adding 1 to this value, and the PER (carrier side) by adding 2.  I have managed to break the address up into a list, and can access the elements directly.  However, when I try to manipulate the values it becomes really obvious that I am trying to do addition to strings and not integers.
>
> #set ( $wanSubnet = $!{dsobj.getValue('WAN-Subnet')} ) ## retrieves data from database
> ! breakupIP($wanSubnet) ## this is a Cisco IOS comment line.  It is the only way I can really debug my code, and is included so I can verify that I am getting data.
> #breakupIP($wanSubnet) ## macro to break apart the IP address.
> ! third octet is $addressParts.get(2) ##same as above.
> #set ( $octetFour = $addressParts.get(3) ) ## I don't want to change the original value.
> ! octetFour is $octetFour ## yet another display
> #set ( $wanCEIP = $octetFour + 1) ## the math
> #set ( $wanPEIP = $octetFour + 2 )
> ! wanCEIP = $wanCEIP ## display the results.
> ! wanPEIP = $wanPEIP
>
> The output generated is below.  Realize this is part of a much larger template, and I pretty much have to work within the limitations of the tool.
>
> !
> ! breakupIP(192.168.100.100)
> ! third octet is 100
> ! octetFour is 100
> ! wanCEIP = $wanCEIP
> ! wanPEIP = $wanPEIP
> !
>
> Any help would be appreciated; I am just learning how to do this.
>
>
> Craig K. Dalrymple
> Information Services Consultant (Contractor)
> FMI/Unisys Inc. working for
> USDA/OCIO/ITS/IOD/NOB
> FMI(BPA # AG-3144-B-12-0003)
> 6501 Beacon Drive
> Kansas City, MO 64113
> 816-926-8819  (W)
>
>
>
>
>
> This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


RE: Having trouble doing math with values retrieved from external data source

Posted by "Dalrymple, Craig - OCIO-ITS, Kansas City, MO" <Cr...@kcc.usda.gov>.
Thank you, this did the trick!  Now I just need to string it all back together.

Craig K. Dalrymple
Information Services Consultant (Contractor)
FMI/Unisys Inc. working for
USDA/OCIO/ITS/IOD/NOB
FMI(BPA # AG-3144-B-12-0003)
6501 Beacon Drive
Kansas City, MO 64113
816-926-8819  (W)


-----Original Message-----
From: Nathan Bubna [mailto:nbubna@gmail.com] 
Sent: Monday, October 01, 2012 6:18 PM
To: Velocity Users List
Subject: Re: Having trouble doing math with values retrieved from external data source

Velocity 1.4, eh?  I suppose upgrading to 1.7 isn't an option?

With 1.4, you have a hack:

#set( $Integer = 1 )
#set( $wanCEIP = $Integer.parseInt($octetFour) + 1)

or you can google for VelocityTools' MathTool, drop an instance in the
context and use that to handle the parsing and/or addition in a
cleaner way:

#set( $wanCEIP = $math.add($octetFour, 1) )

On Mon, Oct 1, 2012 at 3:01 PM, Dalrymple, Craig - OCIO-ITS, Kansas
City, MO <Cr...@kcc.usda.gov> wrote:
> First, I apologize if this question has come up before, but after doing some lengthy searching, I was unable to find anything related to the issue I am having.
>
> I have included the segment of the template that is causing my headache below.  Let me explain a little what I am doing, and give a background on why.
>
> The client I work for has a product from Cisco (Cisco Configuration Engine) for configuring large numbers of network devices.  We are trying to make this rather cumbersome tool a bit easier to use.  Basically what it does is keep a database of information about each object that can be included into templates, which are then deployed to those objects to keep configurations close to a uniform standard.  This tool supports two template formats, the legacy and proprietary .cfgtpl, and .vm which is based on the Velocity Template Engine.  Their legacy format allows for some simplification with #include directives and very limited conditional checking --
> #if (a == b)
>   Do this
> #else
>   Do something else
> #endif
>
> By limited I mean you can check for equality, and thats all you can check.  Oh, and you cannot have nested condition tests.  Obviously, Velocity doesn't have this limitation, even on the older version that Cisco has deployed (1.4).
>
> One of the simplifications we would like to include is to handle IP addressing for these network elements.  Currently this is input by users, and may or may not be accurate.  Since the clients IP addresses conform to a pretty strict standard, the only information we really need is the subnet, and the subnet mask.  With this, we can compute the IP addresses.
>
> Below is the segment that has me going even more prematurely bald.  I am trying to break an IP4 address into its four parts given the subnet information, then assign the CER IP address (my side of the MPLS connection) by adding 1 to this value, and the PER (carrier side) by adding 2.  I have managed to break the address up into a list, and can access the elements directly.  However, when I try to manipulate the values it becomes really obvious that I am trying to do addition to strings and not integers.
>
> #set ( $wanSubnet = $!{dsobj.getValue('WAN-Subnet')} ) ## retrieves data from database
> ! breakupIP($wanSubnet) ## this is a Cisco IOS comment line.  It is the only way I can really debug my code, and is included so I can verify that I am getting data.
> #breakupIP($wanSubnet) ## macro to break apart the IP address.
> ! third octet is $addressParts.get(2) ##same as above.
> #set ( $octetFour = $addressParts.get(3) ) ## I don't want to change the original value.
> ! octetFour is $octetFour ## yet another display
> #set ( $wanCEIP = $octetFour + 1) ## the math
> #set ( $wanPEIP = $octetFour + 2 )
> ! wanCEIP = $wanCEIP ## display the results.
> ! wanPEIP = $wanPEIP
>
> The output generated is below.  Realize this is part of a much larger template, and I pretty much have to work within the limitations of the tool.
>
> !
> ! breakupIP(192.168.100.100)
> ! third octet is 100
> ! octetFour is 100
> ! wanCEIP = $wanCEIP
> ! wanPEIP = $wanPEIP
> !
>
> Any help would be appreciated; I am just learning how to do this.
>
>
> Craig K. Dalrymple
> Information Services Consultant (Contractor)
> FMI/Unisys Inc. working for
> USDA/OCIO/ITS/IOD/NOB
> FMI(BPA # AG-3144-B-12-0003)
> 6501 Beacon Drive
> Kansas City, MO 64113
> 816-926-8819  (W)
>
>
>
>
>
> This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Re: Having trouble doing math with values retrieved from external data source

Posted by Nathan Bubna <nb...@gmail.com>.
Velocity 1.4, eh?  I suppose upgrading to 1.7 isn't an option?

With 1.4, you have a hack:

#set( $Integer = 1 )
#set( $wanCEIP = $Integer.parseInt($octetFour) + 1)

or you can google for VelocityTools' MathTool, drop an instance in the
context and use that to handle the parsing and/or addition in a
cleaner way:

#set( $wanCEIP = $math.add($octetFour, 1) )

On Mon, Oct 1, 2012 at 3:01 PM, Dalrymple, Craig - OCIO-ITS, Kansas
City, MO <Cr...@kcc.usda.gov> wrote:
> First, I apologize if this question has come up before, but after doing some lengthy searching, I was unable to find anything related to the issue I am having.
>
> I have included the segment of the template that is causing my headache below.  Let me explain a little what I am doing, and give a background on why.
>
> The client I work for has a product from Cisco (Cisco Configuration Engine) for configuring large numbers of network devices.  We are trying to make this rather cumbersome tool a bit easier to use.  Basically what it does is keep a database of information about each object that can be included into templates, which are then deployed to those objects to keep configurations close to a uniform standard.  This tool supports two template formats, the legacy and proprietary .cfgtpl, and .vm which is based on the Velocity Template Engine.  Their legacy format allows for some simplification with #include directives and very limited conditional checking --
> #if (a == b)
>   Do this
> #else
>   Do something else
> #endif
>
> By limited I mean you can check for equality, and thats all you can check.  Oh, and you cannot have nested condition tests.  Obviously, Velocity doesn't have this limitation, even on the older version that Cisco has deployed (1.4).
>
> One of the simplifications we would like to include is to handle IP addressing for these network elements.  Currently this is input by users, and may or may not be accurate.  Since the clients IP addresses conform to a pretty strict standard, the only information we really need is the subnet, and the subnet mask.  With this, we can compute the IP addresses.
>
> Below is the segment that has me going even more prematurely bald.  I am trying to break an IP4 address into its four parts given the subnet information, then assign the CER IP address (my side of the MPLS connection) by adding 1 to this value, and the PER (carrier side) by adding 2.  I have managed to break the address up into a list, and can access the elements directly.  However, when I try to manipulate the values it becomes really obvious that I am trying to do addition to strings and not integers.
>
> #set ( $wanSubnet = $!{dsobj.getValue('WAN-Subnet')} ) ## retrieves data from database
> ! breakupIP($wanSubnet) ## this is a Cisco IOS comment line.  It is the only way I can really debug my code, and is included so I can verify that I am getting data.
> #breakupIP($wanSubnet) ## macro to break apart the IP address.
> ! third octet is $addressParts.get(2) ##same as above.
> #set ( $octetFour = $addressParts.get(3) ) ## I don't want to change the original value.
> ! octetFour is $octetFour ## yet another display
> #set ( $wanCEIP = $octetFour + 1) ## the math
> #set ( $wanPEIP = $octetFour + 2 )
> ! wanCEIP = $wanCEIP ## display the results.
> ! wanPEIP = $wanPEIP
>
> The output generated is below.  Realize this is part of a much larger template, and I pretty much have to work within the limitations of the tool.
>
> !
> ! breakupIP(192.168.100.100)
> ! third octet is 100
> ! octetFour is 100
> ! wanCEIP = $wanCEIP
> ! wanPEIP = $wanPEIP
> !
>
> Any help would be appreciated; I am just learning how to do this.
>
>
> Craig K. Dalrymple
> Information Services Consultant (Contractor)
> FMI/Unisys Inc. working for
> USDA/OCIO/ITS/IOD/NOB
> FMI(BPA # AG-3144-B-12-0003)
> 6501 Beacon Drive
> Kansas City, MO 64113
> 816-926-8819  (W)
>
>
>
>
>
> This electronic message contains information generated by the USDA solely for the intended recipients. Any unauthorized interception of this message or the use or disclosure of the information it contains may violate the law and subject the violator to civil or criminal penalties. If you believe you have received this message in error, please notify the sender and delete the email immediately.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org