Janusgraph - how to assign vertex to a variable - janusgraph

I follow the getting started in .janusgraph.org
terminal 1:
docker run --name janusgraph-default janusgraph/janusgraph:latest
terminal 2:
docker run --rm --link janusgraph-default:janusgraph -e GREMLIN_REMOTE_HOSTS=janusgraph -it janusgraph/janusgraph:latest bash
./bin/gremlin.sh
gremlin> :remote connect tinkerpop.server conf/remote.yaml
gremlin> :remote console
gremlin> graph = JanusGraphFactory.open('conf/janusgraph-berkeleyje-lucene-server.properties')
==>standardjanusgraph[berkeleyje:/var/lib/janusgraph/data]
gremlin> GraphOfTheGodsFactory.load(graph)
==>null
gremlin> g = graph.traversal()
==>graphtraversalsource[standardjanusgraph[berkeleyje:/var/lib/janusgraph/data], standard]
gremlin> saturn = g.V().has('name', 'saturn').next()
==>v[4304]
gremlin> g.V()
==>v[4184]
==>v[8280]
==>v[4224]
==>v[8320]
==>v[4240]
==>v[8336]
==>v[4264]
==>v[8360]
==>v[12456]
==>v[4304]
==>v[8400]
==>v[12496]
gremlin> g.V(saturn)
No such property: saturn for class: Script10
Type ':help' or ':h' for help.
Display stack trace? [yN]
What am I doing wrong? Why I cannot use saturn variable?
The guide sugest conf/janusgraph-berkeleyje-lucene.properties, but in conf dir there are only *-server.properties

I found the answer here How can I use gremlin-console to remotely create and access variables?
I cannot use variables unles connected with a session
the line
:remote connect tinkerpop.server conf/remote.yaml
should be
:remote connect tinkerpop.server conf/remote.yaml session

Related

To get IP addres of the specific host machine in rub

I want to find the IP address of other system. For example, I am executing my code from server wevrs1234 and I want the IP address of server apvrs1234 and store it in variable. Please help me to get this.
ip = IPSocket.getaddress(Socket.gethostname)
is the code I have so far.
AS per suggestion i have made this code but getting error. Please find my code
publish_vm = node['aem_dispatcher_cookbook']['publish'].to_s
nodes = search(:node, 'hostname:publish_vm')
node.default['aem_dispatcher_cookbook']['ip_address'] = 'nodes.first['ipaddress']'
template node['aem_dispatcher_cookbook']['owner']['home'] + '/conf.d/publish_farm.any' do
source 'publish_farm.any.erb'
owner node['aem_dispatcher_cookbook']['owner']['user']
group node['aem_dispatcher_cookbook']['owner']['group']
mode '0755'
variables(
publish_host: node['aem_dispatcher_cookbook']['publish'],
publish_port: node['aem_dispatcher_cookbook']['publish_port'],
ip_addr: node['aem_dispatcher_cookbook']['ip_address']
)
end
Error
[2020-05-20T06:09:52-05:00] DEBUG: Node wevrd64501.uhc.com loading cookbook aem_dispatcher_cookbook's attribute file /root/.chef/local-mode-cache/cache/cookbooks/aem_dispatcher_cookbook/attributes/default.rb
================================================================================
Recipe Compile Error in /root/.chef/local-mode-cache/cache/cookbooks/aem_dispatcher_cookbook/recipes/default.rb
================================================================================
SyntaxError
-----------
/root/.chef/local-mode-cache/cache/cookbooks/aem_dispatcher_cookbook/recipes/default.rb:333: syntax error, unexpected tIDENTIFIER, expecting keyword_end
...ess'] = 'nodes.first['ipaddress']'
... ^~~~~~~~~
System Info:
You tagged the question with [chef] and [chef-recipe], so I understand you are trying to get another machine's IP address inside recipe. If that another machine is also registered with Chef Server, the easiest would be search. You can search for any machine registered on the Chef Server by some attribute, in your case - hostname.
nodes = search(:node, 'hostname:<another_vm_hostname>')
p nodes.first['ipaddress']
Update:
You have an error in your 3rd line. Don't surround nodes.first['ipaddess'] with quotes.
node.default['aem_dispatcher_cookbook']['ip_address'] = nodes.first['ipaddress']
publish_vm = node['aem_dispatcher_cookbook']['publish'].to_s
ruby_block 'get_ip_from_publish' do
block do
Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
command1 = "nslookup #{publish_vm} |grep '^Address' | awk '{print $2}'| tail -1"
command_out = shell_out(command1)
node.run_state['master_ip'] = command_out.stdout
end
action :run
end
This piece of code helped me to get ip address of desired host machine

I need some assistance defining variables in a chef recipe

Here is the LDAP command that I want to run, which works perfectly:
/opt/openldap/setup —cli —no-prompt —rootUserDN "cn=Directory Manager" — rootUserPasswpord secretpass —hostname localhost —ldapPort 389 —adminConnectorPort 4444 —baseDN "dc=example,dc=com" —addBaseEntry —doNotStart —acceptLicense'
Here is the content of my chef attribute file (server.rb)
default["openldap"]["server"]["ROOTDN"] = "cn=Directory Manager"
default["openldap"]["server"]["ROOTPASS"] = "secret pass"
default["openldap"]["server"]["LDAPPORT"] = "389"
default["openldap"]["server"]["ADMINPORT"] = "4444"
default["openldap"]["server"]["BASEDN"] = "dc=example,dc=com"
default["openldap"]["server"]["DJDEST"] = "/opt/openldap"
Here is the content of my chef recipe file (default.rb)
execute 'Ldap: Installing Openldap Instance' do
command node["openldap"]["server"]["DJDEST"]'/setup --cli --no-prompt--rootUserDN "["openldap"]["server"]["ROOTDN"] " --rootUserPassword ["openldap"] ["server"]["ROOTPASS"]--hostname ["openldap"]["server"]["ODJFQDN"] --ldapPort ["openldap"]["server"]["LDAPPORT"] --adminConnectorPort ["openldap"]["server"]["ADMINPORT"] --baseDN "["openldap"]["server"]["BASEDN"]" --addBaseEntry --doNotStart --acceptLicense'
action :run
end
I want to run the execute resource using variables instead of manually hardcoding the ldap script in the code block. Can anyone please advice me on what i am doing wrong?
Assuming that I understand your question right, you want to generate a string from few variables and strings. Then your question is similar to this one.
You could either combine the content of a variable a = "foo" and the string "bar" using:
a = "foo"
b = a + "bar"
Or you can use string interpolation (probably more common):
a = "foo"
b = "#{a}bar"
The result in both cases is "foobar".
Translated to your chef context, the resulting execute resource would be:
execute 'Ldap: Installing Openldap Instance' do
command "#{node['openldap']['server']['DJDEST']}/setup --cli --no-prompt--rootUserDN "#{node['openldap']['server']['ROOTDN']}" --rootUserPassword #{node['openldap']['server']['ROOTPASS']} --hostname #{node['openldap']['server']['ODJFQDN']} --ldapPort #{node['openldap']['server']['LDAPPORT']} --adminConnectorPort #{node['openldap']['server']['ADMINPORT']} --baseDN "#{node['openldap']['server']['BASEDN']}" --addBaseEntry --doNotStart --acceptLicense"
action :run
end
If it makes it easier for you, you can also extract this into a variable:
installLdapCommand = "#{node['openldap']['server']['DJDEST']}/setup --cli --no-prompt--rootUserDN #{node['openldap']['server']['ROOTDN']} --rootUserPassword #{node['openldap']['server']['ROOTPASS']} --hostname #{node['openldap']['server']['ODJFQDN']} --ldapPort #{node['openldap']['server']['LDAPPORT']} --adminConnectorPort #{node['openldap']['server']['ADMINPORT']} --baseDN "#{node['openldap']['server']['BASEDN']}" --addBaseEntry --doNotStart --acceptLicense"
execute 'Ldap: Installing Openldap Instance' do
command installLdapCommand
action :run
end
Instead of
'["openldap"]["server"]["ROOTDN"] --option'
try using ruby's string interpolation
"#{node['openldap']['server"]['ROOTDN']} --option"
Like so:
execute 'Ldap: Installing Openldap Instance' do
command "#{node['openldap']['server']['DJDEST']}/setup --cli --no-prompt--rootUserDN #{node['openldap']['server']['ROOTDN']} --rootUserPassword #{node['openldap']['server']['ROOTPASS']} --hostname #{node['openldap']['server']['ODJFQDN']} --ldapPort #{node['openldap']['server']['LDAPPORT']} --adminConnectorPort #{node['openldap']['server']['ADMINPORT']} --baseDN #{node['openldap']['server']['BASEDN']} --addBaseEntry --doNotStart --acceptLicense"
action :run
end

How can I disable MongoDB log messages in console?

I have this little test script:
require 'mongo'
mongo_client = Mongo::Client.new(['127.0.0.1:27017'], :database => 'test')
mongo_client[:collection].insert_one({a: 1})
An this is the console output:
$ ruby test.rb
D, [2015-05-17T21:12:05.504986 #25257] DEBUG -- : MONGODB | Adding 127.0.0.1:27017 to the cluster. | runtime: 0.0212ms
D, [2015-05-17T21:12:05.531238 #25257] DEBUG -- : MONGODB | COMMAND | namespace=admin.$cmd selector={:ismaster=>1} flags=[] limit=-1 skip=0 project=nil | runtime: 24.5481ms
D, [2015-05-17T21:12:05.554532 #25257] DEBUG -- : MONGODB | COMMAND | namespace=test.$cmd selector={:insert=>"collection", :documents=>[{:a=>1, :_id=><BSON::ObjectId:0x21935660 data=5558e80553657262a9000000>}], :writeConcern=>{:w=>1}, :ordered=>true} flags=[] limit=-1 skip=0 project=nil | runtime: 21.1718ms
I want to disable those log messages, I don't want a dirty STDOUT. I didn't found any option for this in the ruby driver, and also I've tried to edit /etc/mongod.conf with these directives (but it didn't fix it):
verbose = false
diaglog = 0
Any idea? I don't know what else I can try!
This logging is coming from the Ruby Mongo driver. The default logging level seems to be Logger::DEBUG. Change it to something higher to disable the debug output:
Mongo::Logger.logger.level = Logger::FATAL
To make the driver log to a logfile instead:
Mongo::Logger.logger = Logger.new('mongo.log')
Mongo::Logger.logger.level = Logger::INFO
Note that if you're using the Mongoid ODM, then you may want to adjust logging there too:
Mongoid.logger = Logger.new('mongoid.log')
Mongoid.logger.level = Logger::INFO
For Rails + Mongoid in application.rb:
config.mongoid.logger = Logger.new(Rails.root + '/log/mongoid.log', :warn)
# ...or change the logging level without a new file destination
config.mongoid.logger.level = Logger::INFO
To disable the debug output for Ruby Mongo Driver(mongoid)
we can add it specific environment file as
config.mongoid.logger.level = Logger::INFO
The other answers didn't work for me.
This works for newer Ruby / Rails Versions:
config.mongoid.logger = Logger.new(Rails.root.join('log/mongoid.log'), level: :warn)

MapR installation failing for single node cluster

I was referring quick installation guide for single node cluster. For this i used 20GB storage file for MaprFS but while on installation , it is giving ' Unable to find disks: /maprfs/storagefile' .
Here is my configuration file.
# Each Node section can specify nodes in the following format
# Hostname: disk1, disk2, disk3
# Specifying disks is optional. If not provided, the installer will use the values of 'disks' from the Defaults section
[Control_Nodes]
maprlocal.td.td.com: /maprfs/storagefile
#control-node2.mydomain: /dev/disk3, /dev/disk9
#control-node3.mydomain: /dev/sdb, /dev/sdc, /dev/sdd
[Data_Nodes]
#data-node1.mydomain
#data-node2.mydomain: /dev/sdb, /dev/sdc, /dev/sdd
#data-node3.mydomain: /dev/sdd
#data-node4.mydomain: /dev/sdb, /dev/sdd
[Client_Nodes]
#client1.mydomain
#client2.mydomain
#client3.mydomain
[Options]
MapReduce1 = true
YARN = true
HBase = true
MapR-DB = true
ControlNodesAsDataNodes = true
WirelevelSecurity = false
LocalRepo = false
[Defaults]
ClusterName = my.cluster.com
User = mapr
Group = mapr
Password = mapr
UID = 2000
GID = 2000
Disks = /maprfs/storagefile
StripeWidth = 3
ForceFormat = false
CoreRepoURL = http://package.mapr.com/releases
EcoRepoURL = http://package.mapr.com/releases/ecosystem-4.x
Version = 4.0.2
MetricsDBHost =
MetricsDBUser =
MetricsDBPassword =
MetricsDBSchema =
Below is the error that i am getting.
2015-04-16 08:18:03,659 callbacks 42 [INFO]: Running task: [Verify Pre-Requisites]
2015-04-16 08:18:03,661 callbacks 87 [ERROR]: maprlocal.td.td.com: Unable to find disks: /maprfs/storagefile from /maprfs/storagefile remove disks: /dev/sda,/dev/sda1,/dev/sda2,/dev/sda3 and retry
2015-04-16 08:18:03,662 callbacks 91 [ERROR]: failed: [maprlocal.td.td.com] => {"failed": true}
2015-04-16 08:18:03,667 installrunner 199 [ERROR]: Host: maprlocal.td.td.com has 1 failures
2015-04-16 08:18:03,668 common 203 [ERROR]: Control Nodes have failures. Please fix the failures and re-run the installation. For more information refer to the installer log at /opt/mapr-installer/var/mapr-installer.log
Please help me here.
Thanks
Shashi
Error is resolved by adding skip-check new option after install
/opt/mapr-installer/bin/install --skip-checks new

Chef server: error "ArgumentError" when adding /etc/chef-server/chef-server.rb

i'm trying to learn about chef (i use to wok with CFengine).
So i wanted to install a chef-server on my ubuntu 12.10 box.
I have follow this documentation:
http://docs.opscode.com/install_server.html
All works fine, except i already have a web server listening on port 80. So i wanted nginx (from chef server) to listen on 8080. To do that, i have added "/etc/chef-server/chef-server.rb" with:
default['chef_server']['api_version'] = "11.0.2"
default['chef_server']['flavor'] = "osc" # Open Source Chef
default['chef_server']['notification_email'] = "XXXXXX#SPAM.XXXXX"
default['chef_server']['bootstrap']['enable'] = true
####
# The Chef User that services run as
####
# The username for the chef services user
default['chef_server']['user']['username'] = "chef_server"
# The shell for the chef services user
default['chef_server']['user']['shell'] = "/bin/sh"
# The home directory for the chef services user
default['chef_server']['user']['home'] = "/opt/chef-server/embedded"
####
# Nginx
####
default['chef_server']['nginx']['enable'] = true
default['chef_server']['nginx']['ha'] = false
default['chef_server']['nginx']['dir'] = "/var/opt/chef-server/nginx"
default['chef_server']['nginx']['log_directory'] = "/var/log/chef-server/nginx"
default['chef_server']['nginx']['ssl_port'] = 443
default['chef_server']['nginx']['enable_non_ssl'] = false
default['chef_server']['nginx']['non_ssl_port'] = 8080
default['chef_server']['nginx']['server_name'] = node['fqdn']
default['chef_server']['nginx']['url'] = "https://#{node['fqdn']}"
And when i try: chef-server-ctl reconfigure
I got:
root#goldorak:/etc/chef-server# chef-server-ctl reconfigure
Starting Chef Client, version 11.6.0
Compiling Cookbooks...
Recipe: chef-server::default
* directory[/etc/chef-server] action create (up to date)
================================================================================
Recipe Compile Error in /opt/chef-server/embedded/cookbooks/chef-server/recipes/default.rb
================================================================================
ArgumentError
-------------
wrong number of arguments (0 for 1)
Cookbook Trace:
---------------
/opt/chef-server/embedded/cookbooks/chef-server/recipes/default.rb:34:in `from_file'
Relevant File Content:
----------------------
/opt/chef-server/embedded/cookbooks/chef-server/recipes/default.rb:
27: end.run_action(:create)
28:
29: if File.exists?("/etc/chef-server/chef-server.json")
30: Chef::Log.warn("Please move to /etc/chef-server/chef-server.rb for configuration - /etc/chef-server/chef-server.json is deprecated.")
31: else
32: ChefServer[:node] = node
33: if File.exists?("/etc/chef-server/chef-server.rb")
34>> ChefServer.from_file("/etc/chef-server/chef-server.rb")
35: end
36: node.consume_attributes(ChefServer.generate_config(node['fqdn']))
37: end
38:
39: if File.exists?("/var/opt/chef-server/bootstrapped")
40: node.set['chef_server']['bootstrap']['enable'] = false
41: end
42:
43: # Create the Chef User
[2014-01-30T17:09:54+01:00] ERROR: Running exception handlers
[2014-01-30T17:09:54+01:00] ERROR: Exception handlers complete
[2014-01-30T17:09:54+01:00] FATAL: Stacktrace dumped to /opt/chef-server/embedded/cookbooks/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated
[2014-01-30T17:09:54+01:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Ok answer myself, bad syntax in chef-server.rb. Don't need "default['chef_server']" prefix.
For example:
nginx['non_ssl_port'] = 8080

Resources