Tuesday, January 11, 2022

Openstack: Heat with error "create() got an unexpected keyword argument 'policies' "

 


  • In OSP16 the Nova API has changed the policies field to policy

  • You can work around this issue by specify the compute API --os-compute-api-version 2.63 in your command.


openstack server group create --os-compute-api-version 2.63 --policy affinity demo


Edit file: /etc/heat/heat.conf  add the lines below and restart heat service:

[DEFAULT]

...

max_nova_api_microversion = 2.63


Using GTK from MSYS2 packages

 

Ref:https://www.gtk.org/docs/installations/windows/#using-gtk-from-msys2-packages

Installation

The MSYS2 project provides a UNIX-like development environment for Windows. It provides packages for many software applications and libraries, including the GTK stack. If you prefer developing using Visual Studio, you should use gvsbuild instead.

In MSYS2 packages are installed using the pacman package manager.

Note: in the following steps, we will assume you’re using a 64-bit Windows. Therefore, the package names include the x86_64 architecture identifier. If you’re using a 32-bit Windows, please adapt the instructions below using the i686 architecture identifier.

Step 1.: Download the MSYS2 installer that matches your platform and follow the installation instructions.

Step 2.: Install GTK3 and its dependencies. Open a MSYS2 shell, and run:

pacman -S mingw-w64-x86_64-gtk3

Step 3. (recommended): Install the GTK core applications. Glade is a GUI designer for GTK. It lets you design your GUI and export it in XML format. You can then import your GUI from your code using the GtkBuilder API. Read the GtkBuilder section in the GTK manual for more information.

To install Glade:

pacman -S mingw-w64-x86_64-glade

Step 4. (optional): If you want to develop a GTK3 application in Python, you need to install the Python bindings.

If you develop in Python 3:

pacman -S mingw-w64-x86_64-python3-gobject

If you develop in Python 2:

pacman -S mingw-w64-x86_64-python2-gobject

Step 5. (optional): Install the build tools. If you want to develop a GTK3 application in other languages like C, C++, Fortran, etc, you’ll need a compiler like gcc and other development tools: pacman -S mingw-w64-x86_64-toolchain base-devel

How to distribute a GTK+ application on Windows?

Ref: https://newbedev.com/how-to-distribute-a-gtk-application-on-windows

You have some hints on the Windows page of the GTK website. This is the section named Building and distributing your application. It features a blog post about distributing a GTK application on Windows.

The solution proposed there is to create a MSYS2 package for your application, and then install it and all its dependencies (GTK among them) in a specific directory, so that you can redistribute the whole package.

2020-12-09 EDIT:

Reading the other answers, I want to add that this method not only gets the dependencies for shared objects and binaries right, but that should also work with other kinds of ressources (images, help files, etc.) that are in the required packages, as well as shared objects loaded at runtime with dlopen-based functions. This is something you can't get with just calling ldd to find the dependencies.


It turns out that running ldd mygtkapp.exe (with the ldd provided with MinGW) gave me a listing of all the dlls required to let it run. To get only the dlls which were gtk dependencies (and not e.g. Win32 dlls) I used the following command: ldd mygtkapp.exe | sed -n 's/\([^ ]*\) => \/mingw.*/\1/p' | sort. My program used the Haskell bindings, so the dependencies might be a bit different, but this is what I got:

libatk-1.0-0.dll
libbz2-1.dll
libcairo-2.dll
libcairo-gobject-2.dll
libepoxy-0.dll
libexpat-1.dll
libffi-6.dll
libfontconfig-1.dll
libfreetype-6.dll
libgcc_s_seh-1.dll
libgdk_pixbuf-2.0-0.dll
libgdk-3-0.dll
libgio-2.0-0.dll
libglib-2.0-0.dll
libgmodule-2.0-0.dll
libgobject-2.0-0.dll
libgraphite2.dll
libgthread-2.0-0.dll
libgtk-3-0.dll
libharfbuzz-0.dll
libiconv-2.dll
libintl-8.dll
libpango-1.0-0.dll
libpangocairo-1.0-0.dll
libpangoft2-1.0-0.dll
libpangowin32-1.0-0.dll
libpcre-1.dll
libpixman-1-0.dll
libpixman-1-0.dll
libpng16-16.dll
libstdc++-6.dll
libwinpthread-1.dll
zlib1.dll

Note also that there are a couple of other things you need to do to make a completely standalone application, particularly if you're using stock icons; for more details on this, see https://stackoverflow.com/a/34673860/7345298. Note however that I needed to copy the 16x16 directory instead of the scalable directory.

EDIT: I've actually found the following command to be very useful as well: ldd mygtkapp.exe | grep '\/mingw.*\.dll' -o | xargs -I{} cp "{}" .. This command actually copies the dlls to the current directory obviating the need to laboriously do it yourself.


The following procedure can be used to obtain the necessary DLLs:

  1. Download Listdlls
  2. Leave your application running
  3. Open the PowerShell window where Listdlls.exe is located
  4. Use the command ./Listdlls.exe application_name.exe
  5. Copy all listed paths to a text file
  6. Delete all lines that contain "C:\WINDOWS*" in your text file
  7. Leave only the lines that contain "C:\msys64*...*.dll" in your text file
  8. Open Msys2 Shell
  9. Use $ cp "paste_all_paths_from_dlls" "destination_path"

Cautions before using the $ cp command. In your text file, change "\" to "/" in the paths and remove line breaks.

 



Saturday, January 8, 2022

Camel XML to Java DSL convert utility


 https://github.com/jorgecastro05/camel-xml2dsl

Installing the script:

pip install camel_xml2dsl-0.0.x-py3-none-any.whl

Where x belongs to release version

Running the script

xml2dsl --xml xml_context_file.xml

Building the project (for developers)

Install dependencies

python3 -m pip install --upgrade build
python -m build

build and install

python -m build && pip install dist/camel_xml2dsl-0.0.1-py3-none-any.whl --force-reinstall



Thursday, December 30, 2021

Mingw-w64: How to fix “File too big/too many sections”


Ref: https://digitalkarabela.com/mingw-w64-how-to-fix-file-too-big-too-many-sections/

When you compile large source files that use templates intensively, you may receive the “File too big/too many sections” error. For the Visual Studio compiler you can simply use the /bigobj flag. The equivalent in mingw-w64 is the -mbig-obj flag. However, this is not a compiler flag but the GNU assembler and it should be passed to it.

You can set the assembler’s flags by using -Wa,<assembler_flags_comma_separated> in compiler for example:

g++ -g - Og -std=c++11 -m64 -Wa,-mbig-obj main.cpp

The syntax may seem strange but it is correct. Attempting to add the -mbig-obj flag directly to compiler will result in an error:

g++: error: unrecognized command line option ‘-mbig-obj’

Supported versions:

In my experience, you need version 2.30 of GNU binutils (in version 2.25 linking can hang).


Tuesday, December 21, 2021

How to do the port forwarding from one ip to another ip in same network?

 

Ref: https://serverfault.com/questions/586486/how-to-do-the-port-forwarding-from-one-ip-to-another-ip-in-same-network

These rules should work, assuming that iptables is running on server 192.168.12.87 :

#!/bin/sh

echo 1 > /proc/sys/net/ipv4/ip_forward

iptables -F
iptables -t nat -F
iptables -X

iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.12.77:80
iptables -t nat -A POSTROUTING -p tcp -d 192.168.12.77 --dport 80 -j SNAT --to-source 192.168.12.87

You have to DNAT incoming traffic on port 80, but you will also need to SNAT the traffic back.


Alternative (and best approach IMHO) :

Depending on what your Web Server is (Apache, NGinx) you should consider an HTTP Proxy on your front-end server (192.168.12.87) :

Thursday, December 9, 2021

How to Enable Logging in Iptables on Linux

Ref:  https://tecadmin.net/enable-logging-in-iptables-on-linux/

Enabling logging on iptables is helpful for monitoring traffic coming to our server. This we can also find the number of hits done from any IP. This article will help enable logging in iptables for all packets filtered by iptables.

Enable Iptables LOG

We can simply use following command to enable logging in iptables.

iptables -A INPUT -j LOG

We can also define the source ip or range for which log will be created.

iptables -A INPUT -s 192.168.10.0/24 -j LOG

To define level of LOG generated by iptables us –log-level followed by level number.

iptables -A INPUT -s 192.168.10.0/24 -j LOG --log-level 4

We can also add some prefix in generated Logs, So it will be easy to search for logs in a huge file.

iptables -A INPUT -s 192.168.10.0/24 -j LOG --log-prefix '** SUSPECT **'

View Iptables LOG

After enabling iptables logs. check following log files to view logs generated by iptables as per your operating system.

On Ubuntu and Debian

iptables logs are generated by the kernel. So check following kernel log file.

tail -f /var/log/kern.log

On CentOS/RHEL and Fedora

cat /var/log/messages

Install and use xorg-server on macOS via Homebrew

  The instructions to install and use xorg-server on macOS via Homebrew: Install Homebrew (if you haven't already): /bin/bash -c ...