VirtualBox Java API - Get IP Address of VM in VirtualBox - java

I have question related to getting IP address, I referred to few online resources and some answers already but I was not able to still fix it,
https://forums.virtualbox.org/viewtopic.php?f=34&t=65910 - link that most matched with my question.
Configuration :
Host Machine : Windows 8
Guest : Slitaz 4.0
VirtualBox : 4.3.24
VirtualBox Java API : 4.3
Adapter in VM : Host Only Adapter
Slitaz Guest Additions are also installed.
I have created a Java program using VirtualBox API and I can basically connect, clone and start a VM in VirtualBox. But what I was not able to do is get the IP address of machine. (Why I need IP is because I want to SSH into that machine, using JSCH java library and execute some processes)
This is what I tried so far,
Based on the link mentioned above,
machine.getGuestPropertyValue("/VirtualBox/GuestInfo/Net/<nicid>/V4/IP") - returns empty result
machine.getGuestPropertyValue("/VirtualBox/GuestInfo/Net/Count") - returns empty result
machine.getGuestPropertyValue("/VirtualBox/GuestInfo/Net/<nicid>/MAC") - return empty result
machine.getGuestPropertyValue("/VirtualBox/GuestInfo/OS/Release") - this gives me release version of linux - which is ok
I tried this one more thing, how many properties are exactly available
org.virtualbox_4_3.Holder<List<String>> tempList = new Holder<List<String>>();
org.virtualbox_4_3.Holder<List<String>> tempList1 = new Holder<List<String>>();
Holder<List<Long>> tempList2 = new Holder<List<Long>>();
org.virtualbox_4_3.Holder<List<String>> tempList3 = new Holder<List<String>>();
machine.enumerateGuestProperties("",tempList, tempList1,tempList2,tempList3);
Now in templist, I get name of all properties available and in tempList1 it's values.
[/VirtualBox/GuestInfo/OS/Product, /VirtualBox/HostInfo/GUI/LanguageID, /VirtualBox/HostInfo/VBoxVerExt, /VirtualBox/GuestAdd/Vbgl/Video/SavedMode, /VirtualBox/GuestInfo/OS/Version, /VirtualBox/GuestAdd/VersionExt, /VirtualBox/GuestAdd/Revision, /VirtualBox/HostGuest/SysprepExec, /VirtualBox/GuestAdd/Vbgl/Video/0, /VirtualBox/HostGuest/SysprepArgs, /VirtualBox/GuestAdd/Version, /VirtualBox/HostInfo/VBoxRev, /VirtualBox/HostInfo/VBoxVer, /VirtualBox/GuestInfo/OS/Release, /VirtualBox/GuestAdd/HostVerLastChecked]
That is the reason, I think this works
machine.getGuestPropertyValue("/VirtualBox/GuestInfo/OS/Release") - this gives me release version of linux - which is ok
But there is no property related to IP. Also I am not sure what exactly here is nicid and how to get this using API, is it mac address of adapter in VM, or something else.
machine.getGuestPropertyValue("/VirtualBox/GuestInfo/Net/<nicid>/V4/IP")
Can somebody please help me out here or guide in appropriate direction.

Thanks to virtual box forum, for solving the issue here is the link
https://forums.virtualbox.org/viewtopic.php?f=34&t=66788&sid=bc4d34a5ad65fe3ff5006f91c8690817
But to summarize the solution,
It was made sure that guest additions on slitaz are compatible (correct versions) with the one matching with virtual box version.
Problem was VBoxService was not started automatically during the boot process of Slitaz.
So etc/rcS.conf file was edited to add extra program in LOAD_MODULES
.............. /usr/sbin/VBoxService (use which VBoxService to get the path for service)
Now when Slitaz was restarted, this process was running and
vboxmanage guestproperty enumerate '<vmname>' listed all the configuration
and one intereseted was,
Name: /VirtualBox/GuestInfo/Net/0/V4/IP, value: 192.168.56.101, timestamp: 1427467107101664501, flags:
Hope it helps somebody !!!

Related

Jmeter and MemCached Sets and Gets

So apologies if what I ask is trivial but I am experimenting with Memcached and Jmeter. I have a Memcached server setup (as far as I can tell) and am able to make telnet requests to it via telnet IP PORT and additionally set and get using commands set and get appropriately.
Now point me to a different application if perhaps this is the wrong choice; but my understanding was that Jmeter should allow me to pound the server with equivalent Set and Get requests.
Unfortunately the experimental platform is a remote linux PC running Rockylinux which is similar to CentOS / RedHat to my understanding (I didn't set this part up); and as a result I do not have a GUI to launch while on the Linux PC. I have however opened Jmeter up on my local PC on windows and understand I should be able to send the test file over and run it.
I followed these instructions to try to setup a TCP sampler and set the "text to send" field as below; after doing the additional step in the link regarding the precompiler.
set tutorialspoint 0 900 9${CR}${LF}
memcached${CR}${LF}
quit${CR}${LF}
Running the above as a headless jmeter session doesn't generate any errors called [./jmeter -n -t "Sample.jmx" -l testresults.jtl"] but when I connect via telnet I'm also not seeing the value for the key "tutorialspoint" get updated. When manually doing the get and set I am seeing updates. Any ideas what I could be doing wrong? Checking the log indicates ResponseCode 200 OK as expected. Is there a good method to debug something in a Headless setup?
Thanks for your time.
I believe the easiest way is using Memcached Java Client library
Download spymemcached-2.12.3.jar and drop it to "lib" folder of your JMeter installation (or any other location in JMeter Classpath)
Restart JMeter to pick the .jar up
Add JSR223 Sampler to your test plan and use the following code snippets:
def client = new net.spy.memcached.MemcachedClient(new InetSocketAddress('your-memcached-host', your-memcached-port)) - for connecting to the server
client.set('tutorialspoint', 900, 'memcached').done to write memcached to the tutorialspoint key for 15 minutes
client.get('tutorialspoint') - to read the value of tutorialspoint key
client.shutdown() - to disconnect
More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It
Demo:

Drill not finding drillbit from zookeeper?

I am trying out the drill sample in my project using this example.
https://github.com/vicenteg/DrillJDBCExample/blob/master/src/main/java/com/mapr/drill/DrillJDBCExample.java
I have started drillbits on all my datanodes with the same "cluster-id" and I specify "zk.connect" to point to "zookeeper1,zookeeper2,zookeeper3" in my drill-override.conf (picked up by default i believe).
I am getting the following error:
java.lang.IllegalStateException: No DrillbitEndpoint can be found
Am I supposed to start drillbits on my zookeeper nodes too in addition to my datanodes? Or what is wrong?
My drill-override is as follows:
drill.exec: {
cluster-id: "testcluster",
zk.connect: "zookeeper1:2181,zookeeper2:2181,zookeeper3:2181"
}
if you are trying to connect to a different machine where drill is installed. Then while connecting from windows, give ip address of the machine where drill is running as .
Important
If in drill-override.conf(Linux machine where Drill is running) you have written "zookeeper1" as node name, then you should modify your "c:\Windows\System32\Drivers\etc\hosts" file in your client machine, and gave a DNS name of that ip.
Example :
192.168.32.84 zookeeper1 .

Could not find COM port and port list is empty

Hey i would like to connect my eclipse programs written in Java with an Arduino. Previously i used Processing but now i am working on something more difficult: I will connect a Leap to an Arduino, but i get the following message when i try to connect to my port.
I am using a Mac and the port i used in processing was tty.usbserial-AM01VBFC
However this does not work with the given example from: http://playground.arduino.cc/interfacing/java
I changed this to match my port:
private static final String PORT_NAMES[] = {
"/dev/tty.usbserial-AM01VBFC", // Mac OS X
"/dev/ttyACM0", // Raspberry Pi
"/dev/ttyUSB0", // Linux
"COM3", // Windows
};
and the result is:
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
Could not find COM port.
Started
The port list is empty in my opinion because:
portEnum.hasMoreElements()
is false.
The full code can be found in the link above the only thing i changed is the port name for Mac OS X.
I have found only one guy with the same problem and he found a solution for ubuntu i do not understand: http://forum.arduino.cc/index.php?topic=73350.0;wap2
Hoping for some help,
Georgi
I found a solution for the problem:
System.setProperty("gnu.io.rxtx.SerialPorts", "/dev/tty.usbArduino");
the line above has to be commented out and you have to delete your lock files for a "fresh" USB connection!
Thanks to all the answers that lead me to the right way!
edit: it was "/dev/tty.usbArduino" because i made a symlink of my ports! I deleted the symlink afterwards
Follow Tim's advice and print the ports, running:
ls /dev/tty.*
in Terminal. This should allow you to double check if "/dev/tty.usbserial-AM01VBFC" is actually the correct name.
If nothing prefixed by tty.usbserial while your device is connected try this:
Install the FTDI VCP driver
Only if 1 doesn't work and you're using Mavericks try to unload Apple's FTDI driver: sudo kextunload -b com.apple.driver.AppleUSBFTDI (note that this need to be done once per OSX boot)
There are two types of cable:
Charging Cable
Data Transfer Cable
So, try changing cable if you have tried every usb driver and port.
Else, install driver using this link, http://www.wch.cn/download/CH341SER_MAC_ZIP.html
After installing if it doesn't work then change cable.
It worked for me after changing the cable.

address family not supported by protocol _only_ in Eclipse after disable/enable IPv6 on Network Adapters

Hi and thanks for any help in advance:
I'm seeing this well known and discussed issue. However, this is only when running/debugging in Eclipse, Juno on Win 7. VM version matters not.
Therefore, this is an Eclipse-only issue. This does not happen when I run the same app standalone - only within Eclipse (did I say that already ;-) )
This occurred after (for testing purposes) I disabled IPv6 on my network adapters and then enabled IPv6 on those same adapters.
The application is simple: creates a multicast server on the WS-Discovery port to listen and report on any UDP multicasts to that group. This program works fine in all cases and platforms except on the machine and in Eclipse where I disabled/enabled IPv6 as described above.
Also:
1) Yes, PreferIPv6Addresses = true and PreferIPv4Stack = false
- Args set in the code
2) No, the Win 7 host file is not messed up
3) No, this is not an Android app
Here is the error followed by the code.
Thanks again, in advance,
Tom
Protocol family not supported
java.net.SocketException: Protocol family not supported
at java.net.PlainDatagramSocketImpl.bind(Native Method)
at java.net.DatagramSocket.bind(DatagramSocket.java:368)
at java.net.MulticastSocket.<init>(MulticastSocket.java:147)
System.setProperty("java.net.preferIPv4Stack", "false");
System.setProperty("java.net.preferIPv6Addresses", "true");
// bind to all IPv6 ports (in contrast to "0.0.0.0" for IPv4 binding)
InetAddress ia6BindTo = InetAddress.getByName("::");
SocketAddress sa = new InetSocketAddress(ia6BindTo, 3702);
// bam
MulticastSocket ms = new MulticastSocket(sa);
// no longer gets this far since disable/enable IPv6 on net adapters
InetAddress m_GroupAddress = InetAddress.getByName("[FF02::C]");
ms.joinGroup(m_GroupAddress);
This is not the answer "Why?".
This is the answer to a workaround.
I deleted the Installed JVM from Eclipse and reinstalled it. Behavior cleared.
This isn't fully acceptable to me for two reasons:
1) The problem repeats when I disable/enable IPv6 again. Therefore, the workaround must be repeated.
2) I must configure projects and run configurations further to make the desired JVM the default again.
If I find out why this is occuring in Eclipse, I will post my findings.

Liferay blog URL's and virtual host

Our company running Liferay without virtual host. We using VM IP with port 80 open for our portal. No any problems with this setup.
When I'm added virtual host to Liferay and changed DNS on my machine -- I can't opened any assets (articles) with long russian names.
Tomcat console:
WARN [404_jsp:109] /home/-/asset_publisher/JbL5ejmhvwSa/content/%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D0%BF%D1%80%D0%BE%D0%BA%D0%BE%D0%BC-%D0%BF%D0%BE-%D0%BE%D0%BF%D1%82%D0%B8%D0%BC%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D0%B8-%D1%80%D0%B0%D0%B1%D0%BE%D1%87%D0%B5%D0%B3%D0%BE-%D0%B2%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%B8-%D1%81%D0%BE%D1%82%D1%80%D1%83%D0%B4%D0%BD%D0%B8%D0%BA%D0%BE%D0%B2-%D0%BD%D0%B0-%D0%B1%D0%B0%D0%B7%D0%B5-%D0%BF%D1%80%D0%BE%D0%B4%D1%83%D0%BA%D1%82%D0%BE%D0%B2-ibm
Virtual host enabled URL (not working)
http://companyname.com/home/-/asset_publisher/JbL5ejmhvwSa/content/%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D0%BF%D1%80%D0%BE%D0%BA%D0%BE%D0%BC-%D0%BF%D0%BE-%D0%BE%D0%BF%D1%82%D0%B8%D0%BC%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D0%B8-%D1%80%D0%B0%D0%B1%D0%BE%D1%87%D0%B5%D0%B3%D0%BE-%D0%B2%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%B8-%D1%81%D0%BE%D1%82%D1%80%D1%83%D0%B4%D0%BD%D0%B8%D0%BA%D0%BE%D0%B2-%D0%BD%D0%B0-%D0%B1%D0%B0%D0%B7%D0%B5-%D0%BF%D1%80%D0%BE%D0%B4%D1%83%D0%BA%D1%82%D0%BE%D0%B2-ibm?redirect=http%3A%2F%2Finterprocom.ru%2Fhome%3Fp_p_id%3D101_INSTANCE_JbL5ejmhvwSa%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-2%26p_p_col_pos%3D1%26p_p_col_count%3D2
Virtual host disabled URL (working)
http://192.168.10.35/web/guest/home/-/asset_publisher/JbL5ejmhvwSa/content/%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D0%BF%D1%80%D0%BE%D0%BA%D0%BE%D0%BC-%D0%BF%D0%BE-%D0%BE%D0%BF%D1%82%D0%B8%D0%BC%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D0%B8-%D1%80%D0%B0%D0%B1%D0%BE%D1%87%D0%B5%D0%B3%D0%BE-%D0%B2%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%B8-%D1%81%D0%BE%D1%82%D1%80%D1%83%D0%B4%D0%BD%D0%B8%D0%BA%D0%BE%D0%B2-%D0%BD%D0%B0-%D0%B1%D0%B0%D0%B7%D0%B5-%D0%BF%D1%80%D0%BE%D0%B4%D1%83%D0%BA%D1%82%D0%BE%D0%B2-ibm?redirect=http%3A%2F%2F192.168.10.45%2Fweb%2Fguest%2Fhome%3Fp_p_id%3D101_INSTANCE_JbL5ejmhvwSa%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-2%26p_p_col_pos%3D1%26p_p_col_count%3D2
It's few days until we go public. We'll use our domain companyname.com
I'm worried that we will got same issue.
Without being able to immediately solve the underlying problem: You can also use the last option with the host name: No virtual host names, just have the name resolve to 192.168.10.35 (change to an actual IP when going live).
Also, what version of Liferay are you on?
see this Question, my be it help you: Liferay: After changing Public Virtual Host settings, can't log in
Also you can see in generated jsp code tomcat/work/... why this do not work.
And at last, you can debug Liferay and find the solution :) The simple way to debug Liferay is to get Liferay IDE and add Liferay Source as eclipse project. Good luck.
Even I face this issue and observed that with liferay's virtual host mapping, url's with special characters are not showing up when they are related to entries in Guest site.
By mapping virtual host, web/guest part is removed from the URL.
Now if you try manually adding web/guest before the URL, In your case
try accessing with following URL
http://companyname.com/web/guest/home/-/asset_publisher/JbL5ejmhvwSa/content/%D1%80%D0%B5%D1%88%D0%B5%D0%BD%D0%B8%D1%8F-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D0%BF%D1%80%D0%BE%D0%BA%D0%BE%D0%BC-%D0%BF%D0%BE-%D0%BE%D0%BF%D1%82%D0%B8%D0%BC%D0%B8%D0%B7%D0%B0%D1%86%D0%B8%D0%B8-%D1%80%D0%B0%D0%B1%D0%BE%D1%87%D0%B5%D0%B3%D0%BE-%D0%B2%D1%80%D0%B5%D0%BC%D0%B5%D0%BD%D0%B8-%D1%81%D0%BE%D1%82%D1%80%D1%83%D0%B4%D0%BD%D0%B8%D0%BA%D0%BE%D0%B2-%D0%BD%D0%B0-%D0%B1%D0%B0%D0%B7%D0%B5-%D0%BF%D1%80%D0%BE%D0%B4%D1%83%D0%BA%D1%82%D0%BE%D0%B2-ibm?redirect=http%3A%2F%2Finterprocom.ru%2Fhome%3Fp_p_id%3D101_INSTANCE_JbL5ejmhvwSa%26p_p_lifecycle%3D0%26p_p_state%3Dnormal%26p_p_mode%3Dview%26p_p_col_id%3Dcolumn-2%26p_p_col_pos%3D1%26p_p_col_count%3D2
and it should work.
So one possible way to resolve this issue is to keep virtual host
mapping in your windows/your os hosts file and rename virtual host to
localhost in Liferay in portal settings under Portal tab in control
panel.
STEPS:
1) In hosts file keep the mapping as you have done i.e
192.168.10.35 companyname.com
2) In liferay, remove the virtual host mapping i.e rename virtual host to localhost in "portal settings" under "Portal" tab in control panel.
and try to access your entry and it will work.
This is very interesting behavior/ may be a bug in liferay.
Hope this helps.
So you testing Liferay on your local host, then trying to move on real domain and facing some weird behaviour.
First thing you want to do is to check Control Panel and type in your new virtual host there.
I'm not sure about this because we are using 6.0 now and I did not remember how exactly we fixed it. If my advice did not helped please check other comments to this question.

Categories

Resources