Add 'packer-image-create' job

- add packer-image-create.groovy to create images with packer
- add 'tcp_tests/templates/_packer/' with configs for 'foundation'
  node

Change-Id: I23379bef389adad791df9343930095a57af3fb55
diff --git a/tcp_tests/templates/_packer/foundation/config-drive/meta-data b/tcp_tests/templates/_packer/foundation/config-drive/meta-data
new file mode 100644
index 0000000..b0c74c9
--- /dev/null
+++ b/tcp_tests/templates/_packer/foundation/config-drive/meta-data
@@ -0,0 +1 @@
+hostname: foundation
diff --git a/tcp_tests/templates/_packer/foundation/config-drive/user-data b/tcp_tests/templates/_packer/foundation/config-drive/user-data
new file mode 100644
index 0000000..1d68c57
--- /dev/null
+++ b/tcp_tests/templates/_packer/foundation/config-drive/user-data
@@ -0,0 +1,72 @@
+#cloud-config, see http://cloudinit.readthedocs.io/en/latest/topics/examples.html
+
+ssh_pwauth: True
+users:
+  - name: root
+    sudo: ALL=(ALL) NOPASSWD:ALL
+    shell: /bin/bash
+  - name: jenkins
+    sudo: ALL=(ALL) NOPASSWD:ALL
+    shell: /bin/bash
+    ssh_authorized_keys:
+      - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDFSxeuXh2sO4VYL8N2dlNFVyNcr2RvoH4MeDD/cV2HThfU4/BcH6IOOWXSDibIU279bWVKCL7QUp3mf0Vf7HPuyFuC12QM+l7MwT0jCYh5um3hmAvM6Ga0nkhJygHexe9/rLEYzZJkIjP9/IS/YXSv8rhHg484wQ6qkEuq15nyMqil8tbDQCq0XQ+AWEpNpIa4pUoKmFMsOP8lq10KZXIXsJyZxizadr6Bh4Lm9LWrk8YCw7qP3rmgWxK/s8qXQh1ISZe6ONfcmk6p03qbh4H3CwKyWzxmnIHQvE6PgN/O+PuAZj3PbR2mkkJjYX4jNPlxvj8uTStaVPhAwfR9Spdx jenkins@cz8133
+
+disable_root: false
+chpasswd:
+  list: |
+    root:r00tme
+    jenkins:qalab
+  expire: False
+
+output:
+  all: '| tee -a /var/log/cloud-init-output.log /dev/tty0'
+
+runcmd:
+  # Create swap
+  - fallocate -l 16G /swapfile
+  - chmod 600 /swapfile
+  - mkswap /swapfile
+  - swapon /swapfile
+  - echo "/swapfile   none    swap    defaults   0   0" >> /etc/fstab
+
+  # Enable root access
+  - sed -i -e '/^PermitRootLogin/s/^.*$/PermitRootLogin yes/' /etc/ssh/sshd_config
+  - service sshd restart
+
+write_files:
+  - path: /etc/default/grub.d/97-enable-grub-menu.cfg
+    content: |
+      GRUB_RECORDFAIL_TIMEOUT=30
+      GRUB_TIMEOUT=3
+      GRUB_TIMEOUT_STYLE=menu
+
+  - path: /etc/network/interfaces
+    content: |
+      auto ens3
+      iface ens3 inet dhcp
+
+  - path: /etc/bash_completion.d/fuel_devops30_activate
+    content: |
+      source /home/jenkins/fuel-devops30/bin/activate
+
+  - path: /etc/sysctl.d/99-fuel-devops.conf
+    content: |
+      net.bridge.bridge-nf-call-arptables = 0
+      net.bridge.bridge-nf-call-ip6tables = 0
+      net.bridge.bridge-nf-call-iptables = 0
+
+  - path: /etc/ssh/ssh_config
+    content: |
+      Host *
+          SendEnv LANG LC_*
+          HashKnownHosts yes
+          GSSAPIAuthentication yes
+          GSSAPIDelegateCredentials no
+          ServerAliveInterval 300
+          ServerAliveCountMax 10
+          StrictHostKeyChecking no
+          UserKnownHostsFile /dev/null
+
+  - path: /etc/sudoers.d/99-mirantis
+    content: |
+      %mirantis ALL=(ALL) NOPASSWD:ALL
diff --git a/tcp_tests/templates/_packer/foundation/packer.json b/tcp_tests/templates/_packer/foundation/packer.json
new file mode 100644
index 0000000..452fdef
--- /dev/null
+++ b/tcp_tests/templates/_packer/foundation/packer.json
@@ -0,0 +1,64 @@
+{
+  "variables": {
+    "vm_name": "{{ env `IMAGE_NAME` }}.qcow2",
+    "image_path": "tmp/{{ env `IMAGE_NAME` }}",
+    "base_image_url": "{{ env `BASE_IMAGE_URL` }}",
+    "base_image_md5": "{{ env `BASE_IMAGE_MD5` }}",
+    "base_image_path": "base_image.qcow2",
+    "ssh_username": "root",
+    "ssh_password": "r00tme",
+    "ssh_wait_timeout": "30m",
+    "disk_size": "51200",
+    "boot_wait": "120s"
+  },
+
+  "builders":
+  [
+    {
+      "type": "qemu",
+      "qemuargs": [
+        [ "-m", "1024M" ],
+        [ "-cdrom", "tmp/config-drive.iso" ],
+        ["-device", "virtio-net,netdev=user.0"],
+        ["-object","rng-random,id=objrng0,filename=/dev/urandom"],
+        ["-device", "virtio-rng-pci,rng=objrng0,id=rng0,bus=pci.0,addr=0x10" ]
+      ],
+      "vm_name": "{{ user `vm_name` }}",
+      "output_directory": "{{ user `image_path` }}",
+      "format": "qcow2",
+      "iso_url": "{{ user `base_image_url` }}",
+      "iso_checksum": "{{ user `base_image_md5` }}",
+      "iso_checksum_type": "md5",
+      "iso_target_path": "{{ user `base_image_path`}}",
+      "disk_image": true,
+      "disk_compression": true,
+      "accelerator": "kvm",
+      "disk_size": "{{ user `disk_size`}}",
+      "headless": true,
+      "ssh_username": "{{ user `ssh_username` }}",
+      "ssh_password": "{{ user `ssh_password` }}",
+      "ssh_wait_timeout": "{{ user `ssh_wait_timeout` }}",
+      "ssh_host_port_min": 7000,
+      "ssh_host_port_max": 7050,
+      "shutdown_command": "shutdown -P now",
+      "boot_wait": "{{ user `boot_wait` }}"
+    }
+  ],
+
+  "provisioners": [
+    {
+      "type": "shell",
+      "environment_vars": [
+        "DEBIAN_FRONTEND=noninteractive"
+      ],
+      "execute_command": "echo '{{ user `ssh_password` }}' | {{.Vars}} sudo -S -E bash -x '{{.Path}}'",
+      "scripts": [
+        "tcp_tests/templates/_packer/scripts/ubuntu_packets.sh",
+        "tcp_tests/templates/_packer/scripts/ubuntu_ldap.sh",
+        "tcp_tests/templates/_packer/scripts/jenkins_virtualenvs.sh",
+        "tcp_tests/templates/_packer/scripts/ubuntu_cleanup.sh",
+        "tcp_tests/templates/_packer/scripts/zerodisk.sh"
+      ]
+    }
+  ]
+}