Monday, January 17, 2022

OpenStack: Add Host entry in dnsmasq


 Ex: Setup for hostname "openstack" to ip "10.0.0.1".

  • Create file /etc/neutron/dnsmasq-neutron.conf with below content in it.

address=/openstack/10.0.0.1
  • Edit /etc/neutron/dhcp_agent.ini and add below.

dnsmasq_config_file=/etc/neutron/dnsmasq-neutron.conf
  • Then kill all existing dnsmasq processes and restart dhcp-agent. Or reboot the network node.

# service neutron-dhcp-agent restart


OpenStack: Setup MTU for VM instance's network

 

Within the VM instance, set the network interface MTU to 1400 bytes.

To set the MTU automatically to 1400 by neutron dhcp server, follow below steps. This is achieved by dhcp server sending out 1400 MTU to instances as a dhcp option.

  • Create file /etc/neutron/dnsmasq-neutron.conf with below content in it.

dhcp-option-force=26,1400
  • Edit /etc/neutron/dhcp_agent.ini and add below.

dnsmasq_config_file=/etc/neutron/dnsmasq-neutron.conf
  • Then kill all existing dnsmasq processes and restart dhcp-agent. Or reboot the network node.

# service neutron-dhcp-agent restart

Tuesday, January 11, 2022

Openstack: Launch an instance with heat

 

Ref: https://docs.openstack.org/heat/latest/install/launch-instance.html

Create a template

The Orchestration service uses templates to describe stacks. To learn about the template language, see the Template Guide.

  • Create the demo-template.yml file with the following content:

    heat_template_version: 2015-10-15
    description: Launch a basic instance with CirrOS image using the
                 ``m1.tiny`` flavor, ``mykey`` key,  and one network.
    
    parameters:
      NetID:
        type: string
        description: Network ID to use for the instance.
    
    resources:
      server:
        type: OS::Nova::Server
        properties:
          image: cirros
          flavor: m1.tiny
          key_name: mykey
          networks:
          - network: { get_param: NetID }
    
    outputs:
      instance_name:
        description: Name of the instance.
        value: { get_attr: [ server, name ] }
      instance_ip:
        description: IP address of the instance.
        value: { get_attr: [ server, first_address ] }
    

Create a stack

Create a stack using the demo-template.yml template.

  1. Source the demo credentials to perform the following steps as a non-administrative project:

    $ . demo-openrc
    
  2. Determine available networks.

    $ openstack network list
    +--------------------------------------+-------------+--------------------------------------+
    | ID                                   | Name        | Subnets                              |
    +--------------------------------------+-------------+--------------------------------------+
    | 4716ddfe-6e60-40e7-b2a8-42e57bf3c31c | selfservice | 2112d5eb-f9d6-45fd-906e-7cabd38b7c7c |
    | b5b6993c-ddf9-40e7-91d0-86806a42edb8 | provider    | 310911f6-acf0-4a47-824e-3032916582ff |
    +--------------------------------------+-------------+--------------------------------------+
    

    Note

    This output may differ from your environment.

  3. Set the NET_ID environment variable to reflect the ID of a network. For example, using the provider network:

    $ export NET_ID=$(openstack network list | awk '/ provider / { print $2 }')
    
  4. Create a stack of one CirrOS instance on the provider network:

    $ openstack stack create -t demo-template.yml --parameter "NetID=$NET_ID" stack
    +--------------------------------------+------------+--------------------+---------------------+--------------+
    | ID                                   | Stack Name | Stack Status       | Creation Time       | Updated Time |
    +--------------------------------------+------------+--------------------+---------------------+--------------+
    | dbf46d1b-0b97-4d45-a0b3-9662a1eb6cf3 | stack      | CREATE_IN_PROGRESS | 2015-10-13T15:27:20 | None         |
    +--------------------------------------+------------+--------------------+---------------------+--------------+
    
  5. After a short time, verify successful creation of the stack:

    $ openstack stack list
    +--------------------------------------+------------+-----------------+---------------------+--------------+
    | ID                                   | Stack Name | Stack Status    | Creation Time       | Updated Time |
    +--------------------------------------+------------+-----------------+---------------------+--------------+
    | dbf46d1b-0b97-4d45-a0b3-9662a1eb6cf3 | stack      | CREATE_COMPLETE | 2015-10-13T15:27:20 | None         |
    +--------------------------------------+------------+-----------------+---------------------+--------------+
    
  6. Show the name and IP address of the instance and compare with the output of the OpenStack client:

    $ openstack stack output show --all stack
    [
      {
        "output_value": "stack-server-3nzfyfofu6d4",
        "description": "Name of the instance.",
        "output_key": "instance_name"
      },
      {
        "output_value": "10.4.31.106",
        "description": "IP address of the instance.",
        "output_key": "instance_ip"
      }
    ]
    
    $ openstack server list
    +--------------------------------------+---------------------------+--------+---------------------------------+
    | ID                                   | Name                      | Status | Networks                        |
    +--------------------------------------+---------------------------+--------+---------------------------------+
    | 0fc2af0c-ae79-4d22-8f36-9e860c257da5 | stack-server-3nzfyfofu6d4 | ACTIVE | public=10.4.31.106              |
    +--------------------------------------+---------------------------+--------+---------------------------------+
    
  7. Delete the stack.

    $ openstack stack delete --yes stack


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



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 ...