mistral-extra/examples/vm_job/README.md

2.0 KiB

Run VM job example

Run VM job example is created to demonstrate Mistral project features: It is needed for spinning up a VM and use it to do some useful work given calculator as an example.

What this example does

  1. Creates a VM
  2. Waits till it is up and running
  3. Runs small web server on VM
  4. Sends request to the server
  5. If an error occurred, it sends a email to admin with error message

How to run

  1. Preparing

  2. Create an image of virtual machine

  3. Make sure that VM has SSH server in running state

  4. Make sure that VM has password access via SSH

  5. Install packages (example for Debian/Ubuntu based systems)

     sudo apt-get install python-dev
     sudo apt-get install python-pip
     sudo pip install flask
    
  6. Put web_app.py file into user's home directory. To check if it works, type

     python ~/web_app.py
    

    This should run a small server on 5000 port.

  7. Save image

  8. Make sure that python-mistralclient have been installed. If not, install it:

    git clone https://github.com/stackforge/python-mistralclient.git
    cd  python-mistralclient
    python setup.py install
    
  9. Make sure that Mistral API and at least one Mistral-executor are up and running

  10. Create workbook and upload the definition

    mistral workbook-create myWorkbook description tag1,tag2 <path to run_vm_job.yaml>
    
  11. Create context file (simple json, which contains needed by workflow properties)

    {
      "server_name": "mistral-vm",
      "nova_url": "http://172.16.80.100:8774/v2",
      "image_id": "[copy from horizon or nova cli client]",
      "flavor_id": "1",
      "ssh_username": "[VM username]",
      "ssh_password": "[VM password]",
      "smtp_server": "[address to smtp server]",
      "from_email": "[email address]",
      "smtp_password": "[email password]",
      "admin_email": "[address the message should be sent to]",
    }
    
  12. Start execution

    mistral execution-create myWorkbook createVM <path-to-the-context-file>