Unable to run JaCaMo project: how to configure it properly? - agent

I already have a jason project which is running well in Jason and now I am trying to run using JaCaMo. I have both plugins (Jason and JaCaMo) in eclipse. What I am trying to do is in a simple way to compile this current Jason project in JaCaMo for further improvements.
My mas2j file which is running well:
MAS tp_cnp {
infrastructure: Centralised
agents:
i initiator [beliefs="expectedResponses(2)"] #2;
p participant #2;
r rejector #1;
c controller [beliefs="expectedDones(2)"] #1;
aslSourcePath:
"src/asl";
}
The jcm I've created:
mas tp_cnp {
agent i : initiator {
beliefs: message("expectedResponses(2)"),
instances: 2
}
agent p : participant {
instances: 2
}
agent r : rejector
agent c : controller {
beliefs: message("expectedDones(2)"),
}
asl-path: src/asl
}
When I've tryed to run this JaCaMo project the system returned this:
BUILD SUCCESSFUL
Total time: 2 seconds
Launching tp_cnp
reading from file /home/cleber/Projetos/tp_cnp/tp_cnp.jcm ...
JaCaMo is not configured, creating a default configuration.
Wrong configuration for jacamo, current is null
jacamo not found
Wrong configuration for jason, current is null
jason not found
Wrong configuration for jade, current is null
jade not found
Wrong configuration for jason, current is null
jason not found
file /home/cleber/Projetos/tp_cnp/tp_cnp.jcm parsed successfully!
Ant is not properly configured! Current value is /libs
Problem defining the command to run the MAS!
How to configure JaCaMo properly? Is this "translation" (mas2j to jcm) right?

you can configure JaCaMo by running jacamo-XXX.jar application (where XXX is the version). You can either double click on the jar file or run
java -jar jacamo-XXX.jar
You find more details in the JaCaMo "hello world" tutorial, where links for configuring the eclipse plugin or the shell command environment are provided.
Regarding your .jcm file, file names (after ":") must include the .asl:
...
agent i : initiator.asl {
beliefs: message("expectedResponses(2)"),
instances: 2
}
Best,
Jomi

Related

Getting error " not enough arguments in call to s.statsd.SendLoop" when running "go build" command

I'm trying to run go build command for my project but it exits with below error.
alpha#GHOST-RIDER:~/GoWorkspace/src/github.com/hyperledger/firstproject$ go build
# github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric/core/operations
../fabric-sdk-go/internal/github.com/hyperledger/fabric/core/operations/system.go:227:23: not enough arguments in call to s.statsd.SendLoop
have (<-chan time.Time, string, string)
want (context.Context, <-chan time.Time, string, string)
Any help would be appreciated.
As per code fabric is using the different version of this library: github.com/go-kit/kit/metrics/statsd. If you follow the System struct's statsd attribute, you can reach the reference on imports.
In master branch of this lib, SendLoop function requires 4 attributes, so that's the root cause. So this causes error when you compile on your local environment.
I had the same issue and worked around it by checking out a tag of library as below:
cd $GOPATH/src/github.com/go-kit/kit
git fetch --tags
git checkout v0.8.0
found a solution on the hyperledger-fabric-go-sdk group chat.
Add context.Background() in s.statsd.SendLoop like below
s.statsd.SendLoop(context.Background(), s.sendTicker.C, network, address)
in fabric-sdk-go/internal/github.com/hyperledger/fabric/core/operations/system.go file at line 227.
I had a same issue, my solution worked and don't need edit fabric source code.
specify github.com/go-kit/kit to v0.8.0, modify go.mod:
replace github.com/go-kit/kit => github.com/go-kit/kit v0.8.0 // you specific version
require (
... ...
// Maybe other version, go mod tidy update automatically, don't care it.
github.com/go-kit/kit v0.9.0 // indirect
... ...
)
then it worked.

Can't use augeas to create a new entry in hosts.allow

I try to create a new entry in hosts.allow
augeas { "Add in hosts allow" :
context => '/files/etc/hosts.allow',
changes => [
'ins 01 after *[last()]',
'set 01/process[1] ssh',
'set 01/process[2] ssh2',
'set 01/client ipaddr'
],
}
But it doesn't work I get this error
Notice: Compiled catalog for server.local in environment production in 0.96 seconds
Error: /Stage[main]/Nfs::Server/Augeas[Add in hosts allow]: Could not evaluate: Error sending
command 'ins' with params ["01", "after", "/files/etc/hosts.allow/*[last()]"]/Error sending
command 'ins' with params ["01", "after", "/files/etc/hosts.allow/*[last()]"]
I can't see how to use the ins command, the message don't let me know what's went wrong.
CentOS6.4
Puppet version: 3.3.1
augeasversion (from facter): 0.9.0
I Can't find the version of augtools and I can't either execute a command as it is not installed (I don't know how puppet invoke it)
Try adding a leading "/" to the context?
(The logging is slightly odd, it doesn't show the "files" prefix at all, I wonder if your code sample and logging match.)

unable to run locally orchard azure project ysod fresh off sources

I am trying to run locally Orchard.Azure.CloudService project without any code changes to the official stable release 1.7.1 (58c21815). full source address is # https://git01.codeplex.com/orchard .
Here is the steps to reproduce the error:
launch the Orchard.Azure solution
select "Debug" build
click on press F5 start debugging
the page will show "Server Error in '/' Application."
None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Orchard.Environment.DefaultOrchardShell' can be invoked with the available services and parameters: Cannot resolve parameter 'Orchard.Mvc.Routes.IRoutePublisher routePublisher' of constructor 'Void .ctor(System.Func1[Autofac.Features.OwnedInstances.Owned1[Orchard.Environment.IOrchardShellEvents]], System.Collections.Generic.IEnumerable1[Orchard.Mvc.Routes.IRouteProvider], System.Collections.Generic.IEnumerable1[Orchard.WebApi.Routes.IHttpRouteProvider], Orchard.Mvc.Routes.IRoutePublisher, System.Collections.Generic.IEnumerable`1[Orchard.Mvc.ModelBinders.IModelBinderProvider], Orchard.Mvc.ModelBinders.IModelBinderPublisher, Orchard.Tasks.ISweepGenerator)'.
Source Error:
Line 111: var shellScope = _shellContainerFactory.CreateContainer(settings, blueprint);
Line 112:
Line 113: return new ShellContext {
Line 114: Settings = settings,
Line 115: Descriptor = descriptor,
Source File: c:\projects\orchard\src\Orchard\Environment\ShellBuilders\ShellContextFactory.cs Line: 113
`
... "
Windows 8, x64
VS2012.3 Azure SDK 2.1
source code version hash: 58c21815
It is a known issue that the solution can't run in the emulator. This is caused by the structure of the solution, and the fact the emulator doesn't run the cspack file. This script is used to copy modules and themes into the package for Azure deployment. When the emulator runs it simply mounts the Orchard.Azure.Web project which is almost empty and doesn't have all the files necessary to run the solution.
See this discussion on CodePlex for more detail.
I don't believe you should be running that solution but the main Orchard solution.
ie, you don't need to develop specifically for Azure, just deploy for Azure.
I think ^_^

Puppet breaks with multiple node inheritances

Puppet on the tst-01 works fine when using:
node "tst-01" inherits basenode {
But it breaks when I try to organize servers into groups with this configuration:
node "tst-01" inherits redhat6server {
The error with "inherits redhat6server" is:
err: Could not retrieve catalog; skipping run
[root#tst-01 ~]# puppet agent --test
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template ldap/access.conf: Could not find value for 'netgroup' at 124:/etc/puppet/modules/ldap/templates/access.conf at /etc/puppet/modules/ldap/manifests/init.pp:82 on node tst-01.tst.it.test.com
warning: Not using cache on failed catalog
err: Could not retrieve catalog; skipping run
This is the access.conf file, that works fine if inherits is set to "inherits basenode".
[root#puppet]# grep -v "#" /etc/puppet/modules/ldap/templates/access.conf
+ : root : LOCAL
+ : #<%= netgroup %> : ALL
- : ALL : ALL
[root#puppet]#
This is the configuration in /etc/puppet/manifests/nodes.pp.
# Basenode configuration
node "basenode" {
include resolv_conf
include sshd
include ntpd
include motd
}
# Groups
node "redhat6server" inherits basenode {
include ldap_auth
}
# Testservers
node "tst-01" inherits redhat6server {
$netgroup = tst-01
}
I am planning to bring more organisation (read: avoid configuration repetition) in the nodes.pp by grouping machines, e.g. RH5 and RH6 machines instead of adding multiple lines of includes for all RH5 and RH6 servers.
Your running into a variable scoping problem. The official documentation discusses this issue.
In short, redhat6server doesn't have access to the netgroup variable.
The method I employ to work around this is to use hiera. With this, the ldap_auth module can be defined this way, and it will pull the value from a hiera configuration file (typically a yaml file in /etc/puppet/hiera).
You would defined ldap_auth like this:
ldap_auth/manifests/init.pp:
class ldap_auth($netgroup=hiera('netgroup')) {
...
}
Or if your on puppet 3.x, you can use automatic parameter lookup:
class ldap_auth($netgroup) {
...
}
And have a yaml file with:
ldap_auth::netgroup = 'netgroup'

How do you get the path of the running script in groovy?

I'm writing a groovy script that I want to be controlled via a properties file stored in the same folder. However, I want to be able to call this script from anywhere. When I run the script it always looks for the properties file based on where it is run from, not where the script is.
How can I access the path of the script file from within the script?
You are correct that new File(".").getCanonicalPath() does not work. That returns the working directory.
To get the script directory
scriptDir = new File(getClass().protectionDomain.codeSource.location.path).parent
To get the script file path
scriptFile = getClass().protectionDomain.codeSource.location.path
As of Groovy 2.3.0 the #SourceURI annotation can be used to populate a variable with the URI of the script's location. This URI can then be used to get the path to the script:
import groovy.transform.SourceURI
import java.nio.file.Path
import java.nio.file.Paths
#SourceURI
URI sourceUri
Path scriptLocation = Paths.get(sourceUri)
Note that this will only work if the URI is a file: URI (or another URI scheme type with an installed FileSystemProvider), otherwise a FileSystemNotFoundException will be thrown by the Paths.get(URI) call. In particular, certain Groovy runtimes such as groovyshell and nextflow return a data: URI, which will not typically match an installed FileSystemProvider.
This makes sense if you are running the Groovy code as a script, otherwise the whole idea gets a little confusing, IMO. The workaround is here: https://issues.apache.org/jira/browse/GROOVY-1642
Basically this involves changing startGroovy.sh to pass in the location of the Groovy script as an environment variable.
As long as this information is not provided directly by Groovy, it's possible to modify the groovy.(sh|bat) starter script to make this property available as system property:
For unix boxes just change $GROOVY_HOME/bin/groovy (the sh script) to do
export JAVA_OPTS="$JAVA_OPTS -Dscript.name=$0"
before calling startGroovy
For Windows:
In startGroovy.bat add the following 2 lines right after the line with
the :init label (just before the parameter slurping starts):
#rem get name of script to launch with full path
set GROOVY_SCRIPT_NAME=%~f1
A bit further down in the batch file after the line that says "set
JAVA_OPTS=%JAVA_OPTS% -Dgroovy.starter.conf="%STARTER_CONF%" add the
line
set JAVA_OPTS=%JAVA_OPTS% -Dscript.name="%GROOVY_SCRIPT_NAME%"
For gradle user
I have same issue when I'm starting to work with gradle. I want to compile my thrift by remote thrift compiler (custom by my company).
Below is how I solved my issue:
task compileThrift {
doLast {
def projectLocation = projectDir.getAbsolutePath(); // HERE is what you've been looking for.
ssh.run {
session(remotes.compilerServer) {
// Delete existing thrift file.
cleanGeneratedFiles()
new File("$projectLocation/thrift/").eachFile() { f ->
def fileName=f.getName()
if(f.absolutePath.endsWith(".thrift")){
put from: f, into: "$compilerLocation/$fileName"
}
}
execute "mkdir -p $compilerLocation/gen-java"
def compileResult = execute "bash $compilerLocation/genjar $serviceName", logging: 'stdout', pty: true
assert compileResult.contains('SUCCESSFUL')
get from: "$compilerLocation/$serviceName" + '.jar', into: "$projectLocation/libs/"
}
}
}
}
One more solution. It works perfect even you run the script using GrovyConsole
File getScriptFile(){
new File(this.class.classLoader.getResourceLoader().loadGroovySource(this.class.name).toURI())
}
println getScriptFile()
workaround: for us it was running in an ANT environment and storing some location parent (knowing the subpath) in the Java environment properties (System.setProperty( "dirAncestor", "/foo" )) we could access the dir ancestor via Groovy's properties.get('dirAncestor').
maybe this will help for some scenarios mentioned here.

Resources