How to launch my c program as a image with tacker

Asked by 525215713@qq.com

Hi, I have a question. I want to launch my c hello program as a image using the tacker. How can i do it? Could you tell me what i should do? Thank you very much.

Question information

Language:
English Edit question
Status:
Answered
For:
tacker Edit question
Assignee:
Bob Haddleton Edit question
Last query:
Last reply:
Revision history for this message
Bob Haddleton (bob-haddleton) said :
#1

Hello:

There are two basic methods to do what you are looking for:

1 - create a "golden image" of your OS + your binary and use that as the boot image in Tacker

2 - use a generic OS image to boot the VM and then user wget/curl in a user_data script to retrieve the binary from a web server/repository and install it

Each method has it's benefits and limitations, and one may work better for you than the other depending on your situation.

Revision history for this message
525215713@qq.com (525215713-i) said :
#2

Hi Bob,
    Thank you for your answer. As the second answer you said, could you show an example? I still have no idea how to do it.

Revision history for this message
Bob Haddleton (bob-haddleton) said :
#3

Assuming that you have a local web server that you can put your binary executable on, so the link to retrieve the binary is "http://myrepo.url/mybinary", you can add the user_data lines as show in this example:

template_name: OpenWRT
description: Virtual WRT opensource router

service_properties:
  Id: openwrt-vnfd
  vendor: tacker
  version: 1
  type:
    - router
    - firewall

vdus:
  vdu1:
    id: vdu1
    vm_image: OpenWRT
    instance_type: m1.tiny
    service_type: firewall
    mgmt_driver: openwrt
    user_data: |
      wget http://repo.url/mybinary
      chmod +x ./mybinary
      ./mybinary

    network_interfaces:
      management:
        network: net_mgmt
        management: True
      pkt_in:
        network: net0
      pkt_out:
        network: net1

    placement_policy:
      availability_zone: nova

    monitoring_policy: ping
    failure_policy: respawn

That will call wget to retrieve the file at the specified URL, make it executable, and then execute it.

This example assumes that your binary will run on OpenWRT, so use an image that you know it will run on.

Hope this helps

Revision history for this message
525215713@qq.com (525215713-i) said :
#4

Hi Bob,
    As you said before, 1 - create a "golden image" of your OS + your binary and use that as the boot image in Tacker. How can i create a gloden image? I have not done this before. Could you share your method to me? Thank you very much.

Revision history for this message
Bob Haddleton (bob-haddleton) said :
#5

A golden image is a just a snapshot of a base image that has your binaries already installed.

So spin up a VM with your base image, install you binaries, and then take a snapshot of the VM. Note that depending on the base OS you are using you might need to make other changes to the OS before taking the snapshot - for example you might need to remove the files in /etc/udev/rules.d that are related to networking so that MAC addresses are not saved in the image.

Can you help with this problem?

Provide an answer of your own, or ask 525215713@qq.com for more information if necessary.

To post a message you must log in.