Tuesday, 10 October 2017

Argh, I hate macOS when it comes to the apostrophe character

It's days like this when I hate the way that macOS handles the apostrophe, also known as the single quote character.

Specifically, I mean this character: -

'

or do I mean THIS character: -

'

?

Yes, it's the latter and, for some annoying reason, macOS likes to switch from one to t'other, just to annoy me.

So I'm trying to run a Jython script: -

cellID=AdminControl.getCell()
nodeNames = AdminTask.listNodes().splitlines()
for nodeName in nodeNames:
 AdminControl.invoke('WebSphere:name=repository,process=nodeagent,platform=common,node='+nodeName+',version=5.0,type=ConfigRepository,mbeanIdentifier=repository,cell='+cellID+',spec=1.0','refreshRepositoryEpoch'


but I keep getting: -

Traceback (innermost last):
  (no code object) at line 0
  File "<input>", line 2
 AdminControl.invoke('WebSphere:name=repository,process=nodeagent,platform=common,node='+nodeName+',version=5.0,type=ConfigRepository,mbeanIdentifier=repository,cell='+cellID+',spec=1.0','refreshRepositoryEpoch')
                                                                                                                                                                                         ^
SyntaxError: invalid syntax

It took me an AGE to see where I was going wrong.

Once I fixed my syntax : -

cellID=AdminControl.getCell()
nodeNames = AdminTask.listNodes().splitlines()
for nodeName in nodeNames:
 AdminControl.invoke('WebSphere:name=repository,process=nodeagent,platform=common,node='+nodeName+',version=5.0,type=ConfigRepository,mbeanIdentifier=repository,cell='+cellID+',spec=1.0','refreshRepositoryEpoch') 

things moved along.

I then saw this: -

WASX7015E: Exception running command: ""; exception information:
javax.management.InstanceNotFoundException: WebSphere:name=repository,process=nodeagent,platform=common,node=Dmgr,version=5.0,type=ConfigRepository,mbeanIdentifier=repository,cell=PCCell1,spec=1.0


which makes sense, as I'm trying to synchronise a Deployment Manager ( there are two nodes within my cell, and my loop doesn't distinguish between them ).

I further fixed my script: -

cellID=AdminControl.getCell()
nodeNames = AdminTask.listNodes().splitlines()
for nodeName in nodeNames:
 if nodeName.find('D') == -1:
  AdminControl.invoke('WebSphere:name=repository,process=nodeagent,platform=common,node='+nodeName+',version=5.0,type=ConfigRepository,mbeanIdentifier=repository,cell='+cellID+',spec=1.0','refreshRepositoryEpoch')

and now have something that works ( it's primitive, in that it ignores nodes that begin with D e.g. Deployment Manager == Dmgr01

2 comments:

Ben Langhinrichs said...

Of course, it means that while the syntax checking and such may catch most errors, you never know when the same problem might cause an invisible error - one that raises no errors, but gives invalid results or causes damage while running.

After 30+ years of programming, I love the bugs that actually show up when compiling or running. Give me a crash any day over an invisible error.

Dave Hay said...

Ben

Yep, that's SO true.

And, after all this time, I really should know better, and validate my inputs :-)

And yet ...... sigh

Cheers, Dave

Note to self - use kubectl to query images in a pod or deployment

In both cases, we use JSON ... For a deployment, we can do this: - kubectl get deployment foobar --namespace snafu --output jsonpath="{...