I think there is a bug in the way nw:load-graphml works.
Take this graphml file with 3 nodes and 3 links of an undirected breed "parentals" and 2 links of a directed breed "diffusions" :
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
<!-- Created by igraph -->
<key id="e_breed" for="edge" attr.name="breed" attr.type="string"/>
<graph id="G" edgedefault="undirected">
<node id="n0">
</node>
<node id="n1">
</node>
<node id="n2">
</node>
<edge source="n0" target="n1">
<data key="e_breed">parentals</data>
</edge>
<edge source="n0" target="n2">
<data key="e_breed">parentals</data>
</edge>
<edge source="n1" target="n2">
<data key="e_breed">diffusions</data>
</edge>
<edge source="n0" target="n1">
<data key="e_breed">diffusions</data>
</edge>
</graph>
</graphml>
when you load the file with nw:load-graphml what happens is that all "parentals" links are created, while "diffusions" are only partially created: only "diffusions" links that involves nodes not already linked by parentals links are created, while the others are skipped... is this a bug or an intended behavior in the load-graphml primitive?
this is a short net logo code to demonstrate:
extensions [nw]
undirected-link-breed [parentals parental]
directed-link-breed [diffusions diffusion]
to setup
ca
nw:load-graphml "prova.graphml"
layout-circle turtles 10
end
In your NetLogo code the "diffusion" links are directed. Add directed = "true" attribute to diffusion links in the prova.graphml file:
<edge source="n0" target="n1">
<data key="e_breed">parentals</data>
</edge>
<edge source="n0" target="n2">
<data key="e_breed">parentals</data>
</edge>
<edge directed="true" source="n1" target="n2">
<data key="e_breed">diffusions</data>
</edge>
<edge directed="true" source="n0" target="n1">
<data key="e_breed">diffusions</data>
</edge>
I tried the corrected file and I think the links are OK now:
ask links [show self]
result:
(diffusion 2 1): (diffusion 2 1)
(diffusion 0 2): (diffusion 0 2)
(parental 0 1): (parental 0 1)
(parental 0 2): (parental 0 2)
Edit:
In the current version of NW extension there are some open issues in load-graphml function. I think it is a good idea to add some validation after importing the file to check the links' consistency. Maybe with is-directed-link? reporter for every "directed" links bread and also counting the links and comparing the expected number of links.
Related
I'm trying to add a condition before installing PostgreSQL on Wix bundle.
I'm expecting it to check if there is an installed version of PostgreSQL as you can see on my following code:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Bundle Name="Title" Version="1.0.0.0" Manufacturer="Manufacture" UpgradeCode="5aee5af2-10c7-42d1-bde6-c7dadf736786">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense"/>
<?define InstallPgCommand=--unattendedmodeui minimal --mode unattended --superpassword "super_pwd" --servicename "service_name" --servicepassword "service_pwd" --serverport 5433?>
<Chain>
<!-- Install postgres -->
<ExePackage
SourceFile="ThirdPartyApps\postgresql-14.3-1-windows-x64.exe"
Compressed ="yes"
Vital ="yes"
Permanent ="yes"
InstallCommand="$(var.InstallPgCommand)"
InstallCondition="NOT POSTGRESINSTALLED"
/>
</Chain>
</Bundle>
<Fragment>
<Property Id="POSTGRESINSTALLED">
<RegistrySearch Id="POSTGRESINSTALLED_SEARCH" Key="SOFTWARE\PostgreSQL\Installations\postgresql-x64-14" Root="HKLM" Type="raw" Name="Branding" />
</Property>
</Fragment>
</Wix>
But it didn't work as expect.
Can you tell me what I'm doing wrong ? Thanks everyone
RegistrySearch is for MSI packages. For bundles, use util:RegistrySearch instead.
I'm having troubles viewing my nodes in a fresh rundeck install. resources.xml
<?xml version="1.0" encoding="UTF-8"?>
<project>
<node name="fooweb01"
description="fooweb01" tags="foo,us-east,webserver"
osFamily="unix" osName="Linux"
hostname="fooweb01" username="user"
/>
<node name="fooweb02"
description="fooweb02" tags="foo,us-east,webserver"
osFamily="unix" osName="Linux"
hostname="fooweb02" username="user"
/>
<node name="fooweb03"
description="fooweb03" tags="foo,us-east,webserver"
osFamily="unix" osName="Linux"
hostname="fooweb03" username="user"
/>
<node name="fooweb04"
description="fooweb04" tags="foo,us-east,webserver"
osFamily="unix" osName="Linux"
hostname="fooweb04" username="user"
/>
<node name="foocorp01"
description="foocorp01" tags="foo,us-east,corporate"
osFamily="unix" osName="Linux"
hostname="foocorp01" username="user"
/>
<node name="foocorp02"
description="foocorp02" tags="foo,us-east,corporate"
osFamily="unix" osName="Linux"
hostname="foocorp02" username="user"
/>
<node name="foopartner01"
description="foopartner01" tags="foo,us-east,partner-api"
osFamily="unix" osName="Linux"
hostname="foopartner01" username="user"
/>
<node name="foodb01"
description="foodb01" tags="foo,us-east,cluster-node"
osFamily="unix" osName="Linux"
hostname="foodb01" username="user"
/>
<node name="foodb02"
description="foodb02" tags="foo,us-east,cluster-node"
osFamily="unix" osName="Linux"
hostname="foodb02" username="user"
/>
<node name="foodb03"
description="foodb03" tags="foo,us-east,cluster-node"
osFamily="unix" osName="Linux"
hostname="foodb03" username="user"
/>
<node name="foolb01"
description="foolb03" tags="foo,us-east,haproxy"
osFamily="unix" osName="Linux"
hostname="foolb03" username="user"
/>
<node name="foolb02"
description="foolb03" tags="foo,us-east,haproxy"
osFamily="unix" osName="Linux"
hostname="foolb03" username="user"
/>
<node name="foojobs01"
description="foojobs03" tags="foo,us-east,docker-services"
osFamily="unix" osName="Linux"
hostname="foojobs03" username="user"
/>
<node name="foomonitor"
description="Ops Host" tags="foo,us-east,monitor"
osFamily="unix" osName="Linux"
hostname="foomonitor" username="user"
/>
</project>
project.properties in the same folder
project.resources.file=/var/lib/rundeck/projects/cron_jobs/etc/resources.xml
resources.source.1.type=file
resources.source.1.config.file=/var/lib/rundeck/projects/cron_jobs/etc/resources.xml
resources.source.1.config.format=resourcexml
resources.source.1.config.requireFileExists=true
resources.source.1.config.includeServerNode=true
resources.source.1.config.generateFileAutomatically=true
project.resources.file=/var/lib/rundeck/projects/cron_jobs/etc/resources.xml was a recent test that didn't help. When i load project/cron_jobs/nodes in the browser console i see
XML Parsing Error: syntax error
Location: https://example.org/project/cron_jobs/nodes
Line Number 1: Column 1:
There are no errors in the logs, i have reimported the project each time i make a change to the file, which has not been frequent.
This is driving me crazy, looking for another pair of eyes. All other pages work fine.
Rundeck enumerates their model sources (for example: 1=your resources.xml file, 2=ansible inventory, 3=ec2 nodes, etc.) in your case, the first one is the resources.xml file.
Just delete the project.resources.file=/var/lib/rundeck/projects/cron_jobs/etc/resources.xml line and save.
I created a new project (on Rundeck 3.3.10), deleted the first model source (local), added your resources.xml file (which works like a charm) as first model source and the project.properties looks in the following way:
#Fri Mar 26 08:53:10 CLST 2021
#edit below
project.disable.executions=false
project.disable.schedule=false
project.execution.history.cleanup.batch=500
project.execution.history.cleanup.enabled=false
project.execution.history.cleanup.retention.days=60
project.execution.history.cleanup.retention.minimum=50
project.execution.history.cleanup.schedule=0 0 0 1/1 * ? *
project.jobs.gui.groupExpandLevel=1
project.name=ProjectEXAMPLE
project.nodeCache.enabled=true
project.nodeCache.firstLoadSynch=true
project.output.allowUnsanitized=false
project.ssh-authentication=privateKey
project.ssh-command-timeout=0
project.ssh-connect-timeout=0
project.ssh-keypath=/home/user/.ssh/id_rsa
resources.source.1.config.file=/path/to/your/resources.xml
resources.source.1.config.format=resourcexml
resources.source.1.config.generateFileAutomatically=true
resources.source.1.config.writeable=true
resources.source.1.type=file
service.FileCopier.default.provider=jsch-scp
service.NodeExecutor.default.provider=jsch-ssh
And the nodes on "Nodes" page.
I have nodes abcd1,abcd2,abcd3,abcd4
Input = abcd1,abcd3,abcd4,abcd2
If the rank order ascending - execution follows- abcd1,abcd2,abcd3,abcd4 order
IF the rank order descending - execution follows -abcd4,abcd3,abcd2,abcd1 order
.
I want my executions to follow same order as input i.e, abcd1,abcd3,abcd4,abcd2 . How can this be achieved?
You can use the "Rank Attribute" option on your job definition, for that, just define (or use) some attribute on your node source and Rundeck use it, for example, using this resources.xml (check myorder custom attribute):
<?xml version="1.0" encoding="UTF-8"?>
<project>
<node name="node00" description="Node 00" tags="" myorder="02" hostname="192.168.33.20" osArch="amd64" osFamily="unix" osName="Linux" osVersion="3.10.0-1062.4.1.el7.x86_64" username="vagrant" ssh-key-storage-path="keys/rundeck"/>
<node name="node01" description="Node 01" tags="" myorder="03" hostname="192.168.33.21" osArch="amd64" osFamily="unix" osName="Linux" osVersion="3.10.0-1062.4.1.el7.x86_64" username="vagrant" ssh-key-storage-path="keys/rundeck"/>
<node name="node02" description="Node 02" tags="" myorder="01" hostname="192.168.33.22" osArch="amd64" osFamily="unix" osName="Linux" osVersion="3.10.0-1062.4.1.el7.x86_64" username="vagrant" ssh-key-storage-path="keys/rundeck"/>
</project>
Now set set "Rank Attribute" textbox with myorder attribute, save the job and run again. You can see the order based on that attribute.
More information here.
UPDATE 30/07/2020:
Following the first comment of this answer, exist a way to modify the resource.xml file with a bash script, later update the node definition and later launch the child job to new rankAttribute order using Job Reference Step.
First, the script that changes the Rundeck Model Source (needs xmlstarlet):
#!/bin/bash
path=$RD_OPTION_PATH
myorder=$RD_OPTION_NODE_ORDER
counter=1
Field_Separator=$IFS
# set comma as internal field separator for the string list
IFS=,
for value in $myorder;
do
echo $counter
xmlstarlet ed --inplace -u "/project/node[$counter][#myorder]/#myorder" -v $value $path
counter=$((counter+1))
done
IFS=$Field_Separator
Now, the Parent Job (that calls the script above, refresh the Rundeck Model Source and finally launch the "target" job):
<joblist>
<job>
<context>
<options preserveOrder='true'>
<option name='node_order' value='3,2,1' />
<option name='path' required='true' value='/home/m68k/Rundeck/resources/farm.xml' />
</options>
</context>
<defaultTab>nodes</defaultTab>
<description></description>
<executionEnabled>true</executionEnabled>
<id>860e7189-f399-47c4-ab86-5b47017188dd</id>
<loglevel>INFO</loglevel>
<name>Parent</name>
<nodeFilterEditable>true</nodeFilterEditable>
<plugins />
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='sequential'>
<command>
<description>Just a message</description>
<exec>echo "Starting..."</exec>
</command>
<command>
<description>Call the script</description>
<fileExtension>.sh</fileExtension>
<scriptargs />
<scriptfile>/home/m68k/Downloads/TEST.sh</scriptfile>
<scriptinterpreter>/bin/bash</scriptinterpreter>
</command>
<command>
<description>Refresh Rundeck Model Source</description>
<step-plugin type='source-refresh-plugin'>
<configuration>
<entry key='sleep' value='5' />
</configuration>
</step-plugin>
</command>
<command>
<description>And launch the "target" job against the new node order</description>
<jobref name='Child' nodeStep='true'>
<uuid>0e02890e-c9dd-4a65-ace1-bfe90b9b7a8e</uuid>
</jobref>
</command>
</sequence>
<uuid>860e7189-f399-47c4-ab86-5b47017188dd</uuid>
</job>
</joblist>
And finally, the Child Job, the "target job".
<joblist>
<job>
<defaultTab>nodes</defaultTab>
<description></description>
<dispatch>
<excludePrecedence>true</excludePrecedence>
<keepgoing>false</keepgoing>
<rankAttribute>myorder</rankAttribute>
<rankOrder>ascending</rankOrder>
<successOnEmptyNodeFilter>false</successOnEmptyNodeFilter>
<threadcount>1</threadcount>
</dispatch>
<executionEnabled>true</executionEnabled>
<id>0e02890e-c9dd-4a65-ace1-bfe90b9b7a8e</id>
<loglevel>INFO</loglevel>
<name>Child</name>
<nodeFilterEditable>false</nodeFilterEditable>
<nodefilters>
<filter>node.*</filter>
</nodefilters>
<nodesSelectedByDefault>true</nodesSelectedByDefault>
<plugins />
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='node-first'>
<command>
<exec>echo "Hello ${node.name}"</exec>
</command>
</sequence>
<uuid>0e02890e-c9dd-4a65-ace1-bfe90b9b7a8e</uuid>
</job>
</joblist>
So, if you set 3,1,2 order, you can see the result on myorder attribute on resources.xml file and the child job executes on that order.
<?xml version="1.0"?>
<project>
<node name="node00" description="Node 00" tags="" hostname="192.168.33.20" osArch="amd64" osFamily="unix" osName="Linux" osVersion="3.10.0-1062.4.1.el7.x86_64" username="vagrant" ssh-key-storage-path="keys/rundeck" myorder="3"/>
<node name="node01" description="Node 01" tags="" hostname="192.168.33.21" osArch="amd64" osFamily="unix" osName="Linux" osVersion="3.10.0-1062.4.1.el7.x86_64" username="vagrant" ssh-key-storage-path="keys/rundeck" myorder="1"/>
<node name="node02" description="Node 02" tags="" hostname="192.168.33.22" osArch="amd64" osFamily="unix" osName="Linux" osVersion="3.10.0-1062.4.1.el7.x86_64" username="vagrant" ssh-key-storage-path="keys/rundeck" myorder="2"/>
</project>
Is there anyway i can access the same node via 2 different users (appuser,webuser) to execute scripts?
Will it be ambiguous if there is another entry made for the same node with different username?
test1:
hostname: "10.35.20.76"
nodename: "test1"
osArch: "x86"
osFamily: "unix"
osName: "Solaris"
osVersion: "11.4"
tags: "TEST"
username: "appuser"
A good option to do that is to use a job option pointing to your resources file, in this way:
Job Definition example:
<joblist>
<job>
<context>
<options preserveOrder='true'>
<option name='opt1' value='vagrant' />
</options>
</context>
<defaultTab>nodes</defaultTab>
<description></description>
<dispatch>
<excludePrecedence>true</excludePrecedence>
<keepgoing>false</keepgoing>
<rankOrder>ascending</rankOrder>
<successOnEmptyNodeFilter>false</successOnEmptyNodeFilter>
<threadcount>1</threadcount>
</dispatch>
<executionEnabled>true</executionEnabled>
<id>eaf3f18e-97c0-4c85-b2fd-9a0b8dd8696e</id>
<loglevel>INFO</loglevel>
<name>HelloWorld</name>
<nodeFilterEditable>false</nodeFilterEditable>
<nodefilters>
<filter>name: node00</filter>
</nodefilters>
<nodesSelectedByDefault>true</nodesSelectedByDefault>
<scheduleEnabled>true</scheduleEnabled>
<sequence keepgoing='false' strategy='node-first'>
<command>
<exec>echo "done"</exec>
</command>
</sequence>
<uuid>eaf3f18e-97c0-4c85-b2fd-9a0b8dd8696e</uuid>
</job>
</joblist>
Resources.xml example (check the "username" attribute):
<?xml version="1.0" encoding="UTF-8"?>
<project>
<node name="mylocalhost" description="Rundeck server node" tags="" hostname="mylocalhost" osArch="amd64" osFamily="unix" osName="Linux" osVersion="5.15.0-66-generic" username="jdoe"/>
<node name="node00" description="Node 00" tags="" hostname="192.168.33.20" osArch="amd64" osFamily="unix" osName="Linux" osVersion="4.10.0-1062.4.1.el7.x86_64" username="${option.opt1}" ssh-key-storage-path="keys/rundeck"/>
</project>
Also, you can do the same using passwords. Take a look at this.
The code generation with for the methods works fine, but it seems to me that the grammar part is omitted because no Pojo and JAXB annotations are generated. Do I have to specify some additional configuration? I used this command: wadl2java.bat -p packagename /path/to/wadl
Here is a snippet of the wadl.
<application
xmlns="http://wadl.dev.java.net/2009/02"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.tns.de">
<grammer>
<xsd:include href="file1.xsd"></xsd:include>
<xsd:include href="file2.xsd"></xsd:include>
<xsd:include href="file3.xsd"></xsd:include>
<xsd:include href="file14.xsd"></xsd:include>
</grammer>
<resources base="http:localhost:8080/rest">
<resource path="status/{id}" id="statusId">
<param name="id" type="xsd:unsignedInt" required="true" default="" style="template"/>
<method name="GET" id="getById">
<request>
<representation mediaType="application/json" element="tns:type1"/>
</request>
<response>
<representation mediaType="application/json" element="tns:type2"/>
</response>
</method>
....
I found my mistake. There was a typo in the wadl. Previously I used <grammer> but you have to use <grammars>
Now it works.
<application
xmlns="http://wadl.dev.java.net/2009/02"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.tns.de">
<grammars>
<include href="file1.xsd"></xsd:include>
<include href="file2.xsd"></xsd:include>
<include href="file3.xsd"></xsd:include>
<include href="file14.xsd"></xsd:include>
</grammars>
<resources base="http:localhost:8080/rest">
<resource path="status/{id}" id="statusId">
<param name="id" type="xsd:unsignedInt" required="true" default="" style="template"/>
<method name="GET" id="getById">
<request>
<representation mediaType="application/json" element="tns:type1"/>
</request>
<response>
<representation mediaType="application/json" element="tns:type2"/>
</response>
</method>