From 78f3c55b0a0e70c78e48b8094135995de8842bd8 Mon Sep 17 00:00:00 2001 From: zhihui wu Date: Sat, 24 Feb 2018 14:25:54 +0800 Subject: create VM via heat JIRA: QTIP-290 Change-Id: I3b87b06e7f2b134c28d9cb046150fb000070a760 Signed-off-by: zhihui wu --- .../openstack/tasks/create_flavor.yml | 19 ------ .../ansible_roles/openstack/tasks/create_image.yml | 32 --------- .../ansible_roles/openstack/tasks/create_stack.yml | 24 ------- .../openstack/tasks/delete_flavor.yaml | 16 ----- .../ansible_roles/openstack/tasks/delete_image.yml | 17 ----- .../ansible_roles/openstack/tasks/delete_stack.yml | 16 ----- resources/ansible_roles/openstack/tasks/main.yml | 76 +++++++++++++++++++++- 7 files changed, 75 insertions(+), 125 deletions(-) delete mode 100644 resources/ansible_roles/openstack/tasks/create_flavor.yml delete mode 100644 resources/ansible_roles/openstack/tasks/create_image.yml delete mode 100644 resources/ansible_roles/openstack/tasks/create_stack.yml delete mode 100644 resources/ansible_roles/openstack/tasks/delete_flavor.yaml delete mode 100644 resources/ansible_roles/openstack/tasks/delete_image.yml delete mode 100644 resources/ansible_roles/openstack/tasks/delete_stack.yml (limited to 'resources/ansible_roles/openstack/tasks') diff --git a/resources/ansible_roles/openstack/tasks/create_flavor.yml b/resources/ansible_roles/openstack/tasks/create_flavor.yml deleted file mode 100644 index c5795e46..00000000 --- a/resources/ansible_roles/openstack/tasks/create_flavor.yml +++ /dev/null @@ -1,19 +0,0 @@ -############################################################################## -# Copyright (c) 2018 ZTE Corporation and others. -# taseer94@gmail.com -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - ---- - -- name: create QTIP flavor - os_nova_flavor: - name: "{{ flavor_name }}" - endpoint_type: admin - ram: 2048 - vcpus: 3 - disk: 4 - state: present \ No newline at end of file diff --git a/resources/ansible_roles/openstack/tasks/create_image.yml b/resources/ansible_roles/openstack/tasks/create_image.yml deleted file mode 100644 index b67595ce..00000000 --- a/resources/ansible_roles/openstack/tasks/create_image.yml +++ /dev/null @@ -1,32 +0,0 @@ -############################################################################## -# Copyright (c) 2018 ZTE Corporation and others. -# taseer94@gmail.com -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - ---- - -- name: create directories for image - file: - path: "{{ download_dest }}" - state: directory - -- name: download image as qtip image - get_url: - url: "{{ image_url }}" - dest: "{{ download_dest }}/{{ image_name }}.img" - checksum: "md5:{{ checksum }}" - when: image_url | search("https://") - -- name: upload qtip image - os_image: - name: "{{ image_name }}" - container_format: bare - disk_format: qcow2 - state: present - endpoint_type: admin - filename: "{{ download_dest }}/{{ image_name }}.img" - diff --git a/resources/ansible_roles/openstack/tasks/create_stack.yml b/resources/ansible_roles/openstack/tasks/create_stack.yml deleted file mode 100644 index 33e8f148..00000000 --- a/resources/ansible_roles/openstack/tasks/create_stack.yml +++ /dev/null @@ -1,24 +0,0 @@ -############################################################################## -# Copyright (c) 2017 ZTE Corporation and others. -# taseer94@gmail.com -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - ---- - -- name: create qtip stack - os_stack: - name: "{{ stack_name }}" - state: present - template: ../template/heat_template.yml - endpoint_type: admin - parameters: - image_name: "{{ image_name }}" - flavor_name: "{{ flavor_name }}" - net_name: "{{ net_name }}" - subnet_name: "{{ subnet_name }}" - instance_name: "{{ inst_name }}" - timeout: 600 diff --git a/resources/ansible_roles/openstack/tasks/delete_flavor.yaml b/resources/ansible_roles/openstack/tasks/delete_flavor.yaml deleted file mode 100644 index a2816b83..00000000 --- a/resources/ansible_roles/openstack/tasks/delete_flavor.yaml +++ /dev/null @@ -1,16 +0,0 @@ -############################################################################## -# Copyright (c) 2018 ZTE Corporation and others. -# taseer94@gmail.com -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - ---- - -- name: delete QTIP flavor - os_nova_flavor: - name: "{{ flavor_name }}" - endpoint_type: admin - state: absent diff --git a/resources/ansible_roles/openstack/tasks/delete_image.yml b/resources/ansible_roles/openstack/tasks/delete_image.yml deleted file mode 100644 index 46653080..00000000 --- a/resources/ansible_roles/openstack/tasks/delete_image.yml +++ /dev/null @@ -1,17 +0,0 @@ -############################################################################## -# Copyright (c) 2018 ZTE Corporation and others. -# -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - ---- - -- name: delete qtip image - os_image: - name: "{{ image_name }}" - state: absent - endpoint_type: admin - diff --git a/resources/ansible_roles/openstack/tasks/delete_stack.yml b/resources/ansible_roles/openstack/tasks/delete_stack.yml deleted file mode 100644 index 63739345..00000000 --- a/resources/ansible_roles/openstack/tasks/delete_stack.yml +++ /dev/null @@ -1,16 +0,0 @@ -############################################################################## -# Copyright (c) 2018 ZTE Corporation and others. -# wu.zhihui1@zte.com.cn -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Apache License, Version 2.0 -# which accompanies this distribution, and is available at -# http://www.apache.org/licenses/LICENSE-2.0 -############################################################################## - ---- - -- name: cleanup qtip stack - os_stack: - name: "{{ stack_name }}" - state: absent - endpoint_type: admin diff --git a/resources/ansible_roles/openstack/tasks/main.yml b/resources/ansible_roles/openstack/tasks/main.yml index 0b84923e..ed043831 100644 --- a/resources/ansible_roles/openstack/tasks/main.yml +++ b/resources/ansible_roles/openstack/tasks/main.yml @@ -9,4 +9,78 @@ --- -- include_tasks: "{{ tasks }}.yml" +- name: Delete QTIP stack + os_stack: + name: "{{ stack_name }}" + state: absent + +- name: Delete QTIP keypair + os_keypair: + name: QtipKey + state: absent + +- name: Delete QTIP flavor + os_nova_flavor: + name: "{{ flavor_name }}" + state: absent + +- name: Delete qtip image + os_image: + name: "{{ image_name }}" + state: absent + +- name: Create temp directory for QTIP + file: + path: "{{ temp_dir }}" + state: directory + +- name: Clean the existing SSH keypair + file: + state: absent + path: "{{ temp_dir }}/{{ item }}" + with_items: + - QtipKey.pub + - QtipKey + +- name: Generate a SSH key for QTIP VM + shell: ssh-keygen -t rsa -N "" -f "{{ temp_dir }}/QtipKey" -q + +- name: Create QTIP keypair + os_keypair: + name: QtipKey + public_key_file: "{{ temp_dir }}/QtipKey.pub" + state: present + +- name: Create QTIP flavor + os_nova_flavor: + name: "{{ flavor_name }}" + ram: 2048 + vcpus: 3 + disk: 4 + state: present + +- name: Download image as qtip image + get_url: + url: "{{ image_url }}" + dest: "{{ temp_dir }}/{{ image_name }}.img" + checksum: "md5:{{ checksum }}" + when: image_url | search("https://") + +- name: Upload qtip image + os_image: + name: "{{ image_name }}" + container_format: bare + disk_format: qcow2 + state: present + filename: "{{ temp_dir }}/{{ image_name }}.img" + +- name: create qtip stack + os_stack: + name: "{{ stack_name }}" + state: present + template: "{{ heat_template }}" + parameters: + image: "{{ image_name }}" + flavor: "{{ flavor_name }}" + keypair: QtipKey + external_network: "{{ external_network }}" -- cgit 1.2.3-korg