-
Notifications
You must be signed in to change notification settings - Fork 181
Development Environment Alternative Instructions
tomcat: add to /etc/sysconfig/tomcat or /etc/tomcatX/tomcatX.conf (Depends on version)
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
taskomatic: edit /usr/share/rhn/config-defaults/rhn_taskomatic_daemon.conf
and add the following lines:
wrapper.java.additional.6=-Xdebug
wrapper.java.additional.7=-Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=n
Prerequisites:
- Install a software that can run virtual machines based on *.vmdk/qcow2 image files (VirtualBox or KVM).
- Make sure your virtual machine does not change the IP address and the host name after reboot. :-)
Jenkins jobs automatically build appliance images for the SUSE Manager Server, you will need one for development.
For booting up the appliance, download the respective image file to a local directory with enough free diskspace. The image files can be found here:
- 1.7 IBS download site;
- 2.1 IBS download site;
- HEAD IBS download site (will become the next major version);
Unless you know you want something specific, you need the SUSE_Manager_Server_for_Testsuite variant for PostgreSQL in QCOW2 format
In case you use VirtualBox, you have to convert the QCOW2 image to VDI with the following commands:
qemu-img convert -O raw <imagename>.qcow <imagename>.raw
VBoxManage convertdd <imagename>.raw <imagename>.vdi --format VDI --variant Standard
rm <imagename>.raw
Next, create a virtual machine setup to boot up the image using KVM or VirtualBox. This is done in the same way as when booting into any other appliance. Network adapter needs to be configured to Bridged Ethernet with a registered hostname so it won't change after reboot. Further, virtual memory needs to be >= 2 GB (4 GB is recommended).
The first start of the VM will execute the setup which can take up to 10 minutes or more. On 2.1 the setup will be done once you get to the login prompt. In 3.0 you will get to the login prompt much faster but the setup is still running in the background. The login for the images is user: root password: linux. You can monitor the progress of the setup in 3.0 with tail -f /var/log/susemanager_setup.log
.
When the setup is done you should be able to ssh into the VM and access the WebUI with your browser. Its important that you let the setup finish and don't shutdown the VM or start any service manually otherwise your VM could end up in a non functional state and you have to start over.
When the appliance is running you can add one of your public SSH keys so that you don't need to input passwords all the time. On a SUSE system you can use:
ssh-copy-id root@<deploy.host>
where <deploy.host>
is the hostname or IP address of your instance. On OS X or any other system that does not have ssh-copy-id
you can resort to plain scp (if you don't have other keys to manage):
scp ~/.ssh/id_rsa.pub root@<deploy.host>://root/.ssh/authorized_keys
Change the Ant build properties:
cd <path_to_spacewalk>/java
cp buildconf/manager-developer-build.properties.example buildconf/manager-developer-build.properties
vi buildconf/manager-developer-build.properties
Edit the deploy.host
property to point to your Virtual Machines. Note that:
- any property that you define here will override values in
manager-*.xml
files (in Ant properties are immutable, thus the first definition overrides all others); - any boolean property is considered "true" whatever value it has, it is "false" iff it has not been defined at all (again this is how Ant works).
If everything was correctly set up you should be able to deploy a new copy of the application with the command:
ant -f manager-build.xml
That will compile the sources, generate a build/webapp directory, copy it over to the virtual machine, make some additional configuration and restart relevant services. Note that the Ant script does not assume that you are using the DevEnv appliance - actually any SSH-accessible machine running Tomcat should work.
If you are working with static files such as js/css you need to run the following command to deploy them:
ant -f manager-build.xml deploy-static-resources
For less
files you additionally need to add development_environment = 1
to the /etc/rhn/rhn.conf
file and zypper install susemanager-frontend-libs-devel
on the DevEnv. Changes to the rhn.conf
are only picked up after restarting tomcat.
TL;DR
su
rctomcat6 stop
yast firewall services add tcpport=8000 zone=EXT
echo "JAVA_OPTS=\"\$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n\"">>/etc/tomcat6/tomcat6.conf
wget https://gist.githubusercontent.com/renner/3170220/raw/ae335d62abc928a730e963acb4588dc69ed141b5/tomcat6.patch
patch /etc/init.d/tomcat6 tomcat6.patch
rm tomcat6.patch
rctomcat6 start
-
To enable remote debugging, you need to open a port in the firewall. Using
yast
from root selectSecurity and Users
, thenFirewall
,Allowed Services
,Advanced
and add a port you like (eg. 8000) to theTCP Ports
field; -
Enable JVM remote debugging. A trick is needed because activating the debugging port in Tomcat prevents the rctomcat6 script to properly stop it, so basically the configuration should include debugging directives during startup but not during shutdown. In order to achieve that you need to:
- edit
/etc/tomcat6/tomcat6.conf
adding the following line to the end of the file:
JAVA_OPTS="$JAVA_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
- apply this patch to
/etc/init.d/tomcat6
. The patch will comment out the above line during shutdowns.
- edit
Now you can connect with your debugger of choice.
If you need to debug a piece of code running on Taskomatic, you should:
-
open a port in the firewall (see above). 8001 is preferred;
-
edit
/usr/share/rhn/config-defaults/rhn_taskomatic_daemon.conf
and add the following lines:wrapper.java.additional.6=-Xdebug wrapper.java.additional.7=-Xrunjdwp:transport=dt_socket,address=8001,server=y,suspend=n
Note that .6
and .7
above are chosen to keep the whole numbering consistent and might not be correct depending on your configuration.
- run
rctaskomatic restart
.
Now you can connect with your debugger of choice.
TL;DR
su
yast firewall services add service=service:postgresql zone=EXT
echo "listen_addresses = '*'" >> /var/lib/pgsql/data/postgresql.conf
echo "host all all 0.0.0.0/0 md5" >> /var/lib/pgsql/data/pg_hba.conf
rcpostgresql restart
In order to access a Postgres instance from another machine (eg. your development host with pgAdmin III), from a root account, you have to:
-
ensure that the firewall allows connections to the 5432 port. Using
yast
selectSecurity and Users
, thenFirewall
,Allowed Services
and addPostgreSQL Server
; -
add the following line to
/var/lib/pgsql/data/postgresql.conf
to let Postgres accept TCP connections from any address:listen_addresses = '*'
-
add the following line to
/var/lib/pgsql/data/pg_hba.conf
to let Postgres accept connection from clients on any subnet to the susemanager database for the spacewalk user with MD5 authentication (use spaces, not tabs!):host all all 0.0.0.0/0 md5
-
restart Postgres with
rcpostgresql restart
.
In order to access an Oracle instance from another machine:
-
ensure that the firewall allows connections to the 1521 port (see above);
-
run this easy command to let Oracle listen to connection from remote machines (thanks bo!):
smdba-netswitch worldwide
Note that this will restart the oracle database daemon.
- install an Oracle client on your machine. A good graphical client for Oracle is SqlDeveloper, which you can obtain after free registration from the Oracle website. Choose
File
->New
->Database Connection
and open aBasic connection
toService name
"susemanager" with credentials defined in/etc/rhn/rhn.conf
.
First, open up ports on your Virtual Machines:
- if you are connecting to Tomcat, add the following Java properties to
JAVA_OPTS
in/etc/sysconfig/tomcat6
:
-Dcom.sun.management.jmxremote.port=3333
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Djava.rmi.server.hostname=<SERVER_IP_ADDRESS>
- if you are connecting to Taskomatic, add the same Java properties to
/usr/share/rhn/config-defaults/rhn_taskomatic_daemon.conf
file keeping the numbers sequential:
wrapper.java.additional.<N>=-Dcom.sun.management.jmxremote.port=3333
wrapper.java.additional.<N>=-Dcom.sun.management.jmxremote.ssl=false
wrapper.java.additional.<N>=-Dcom.sun.management.jmxremote.authenticate=false
wrapper.java.additional.<N>=-Djava.rmi.server.hostname=<SERVER_IP_ADDRESS>
Then follow standard instructions.