summaryrefslogtreecommitdiffstats
path: root/resources
diff options
context:
space:
mode:
Diffstat (limited to 'resources')
-rw-r--r--resources/ansible_roles/openstack/defaults/main.yml12
-rw-r--r--resources/ansible_roles/openstack/tasks/create_flavor.yml19
-rw-r--r--resources/ansible_roles/openstack/tasks/create_image.yml32
-rw-r--r--resources/ansible_roles/openstack/tasks/create_stack.yml24
-rw-r--r--resources/ansible_roles/openstack/tasks/delete_flavor.yaml16
-rw-r--r--resources/ansible_roles/openstack/tasks/delete_image.yml17
-rw-r--r--resources/ansible_roles/openstack/tasks/delete_stack.yml16
-rw-r--r--resources/ansible_roles/openstack/tasks/main.yml76
-rw-r--r--resources/ansible_roles/qtip-generator/defaults/main.yml4
-rw-r--r--resources/ansible_roles/qtip-generator/files/compute/group_vars/all.yml4
-rw-r--r--resources/ansible_roles/qtip-generator/files/compute/heat_template.yml117
-rw-r--r--resources/ansible_roles/qtip-generator/files/compute/setup.yml2
-rw-r--r--resources/ansible_roles/qtip-generator/files/compute/teardown.yml6
13 files changed, 163 insertions, 182 deletions
diff --git a/resources/ansible_roles/openstack/defaults/main.yml b/resources/ansible_roles/openstack/defaults/main.yml
index 1e6d6e9e..830def62 100644
--- a/resources/ansible_roles/openstack/defaults/main.yml
+++ b/resources/ansible_roles/openstack/defaults/main.yml
@@ -9,12 +9,10 @@
---
-stack_name: qtip_stack
-image_name: qtip_image
-flavor_name: qtip_flavor
-net_name: qtip_net
-subnet_name: qtip_subnet
-inst_name: qtip
image_url: https://cloud-images.ubuntu.com/releases/16.04/release-20180222/ubuntu-16.04-server-cloudimg-amd64-disk1.img
checksum: 027b3e9d219f0f6c17b5448ed67dc41e
-download_dest: /tmp/qtip/images \ No newline at end of file
+temp_dir: /tmp/qtip
+
+flavor_name: qtip_flavor
+stack_name: qtip_stack
+image_name: qtip_image
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 }}"
diff --git a/resources/ansible_roles/qtip-generator/defaults/main.yml b/resources/ansible_roles/qtip-generator/defaults/main.yml
index b7616486..300dadf0 100644
--- a/resources/ansible_roles/qtip-generator/defaults/main.yml
+++ b/resources/ansible_roles/qtip-generator/defaults/main.yml
@@ -16,6 +16,10 @@ installer_group:
apex: apex-underclouds
mcp: salt-master
+network_group:
+ mcp: floating_net
+ apex: external
+
project_name: 'qtip-project'
project_template: 'compute'
diff --git a/resources/ansible_roles/qtip-generator/files/compute/group_vars/all.yml b/resources/ansible_roles/qtip-generator/files/compute/group_vars/all.yml
index efb2bdb7..1b34fd69 100644
--- a/resources/ansible_roles/qtip-generator/files/compute/group_vars/all.yml
+++ b/resources/ansible_roles/qtip-generator/files/compute/group_vars/all.yml
@@ -21,3 +21,7 @@ installer_group:
fuel: fuel-masters
apex: apex-underclouds
mcp: salt-master
+
+network_group:
+ mcp: floating_net
+ apex: external
diff --git a/resources/ansible_roles/qtip-generator/files/compute/heat_template.yml b/resources/ansible_roles/qtip-generator/files/compute/heat_template.yml
index d476c8f5..cb67e624 100644
--- a/resources/ansible_roles/qtip-generator/files/compute/heat_template.yml
+++ b/resources/ansible_roles/qtip-generator/files/compute/heat_template.yml
@@ -1,70 +1,101 @@
##############################################################################
-# Copyright (c) 2017 ZTE Corporation and others.
-# taseer94@gmail.com
+# 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
##############################################################################
-
----
-
heat_template_version: 2015-04-30
-description: Simple template to deploy a single compute instance
+description: >
+ Used to run VMs for QTIP
parameters:
- image_name:
+ image:
type: string
- label: Image ID
- description: Image to be used for compute instance
- default: Ubuntu 16.04 x86_64
- flavor_name:
- type: string
- label: Instance Type
- description: Type of instance (flavor) to be used
- default: m1.large
- net_name:
+ description: Name of the image
+ default: qtip_image
+
+ flavor:
type: string
- label: Test network name
- description: The name of the stack's network
- default: qtip_net
- subnet_name:
+ description: Name of flavor
+ default: qtip_flavor
+
+ keypair:
type: string
- label: Test subnet name
- description: The name of the stack's subnet
- default: qtip_subnet
- instance_name:
+ description: Name of keypair
+ default: QtipKey
+
+ external_network:
type: string
- label: Test VM name
- description: The name of the spawned vm
- default: qtip_vm
+ description: Name of the external network
resources:
- private_net:
+
+ network:
type: OS::Neutron::Net
properties:
- name: { get_param: net_name }
+ name: qtip_net
- private_subnet:
+ subnet:
type: OS::Neutron::Subnet
properties:
- name: { get_param: subnet_name }
- network_id: { get_resource: private_net }
- cidr: 10.0.0.0/24
+ name: qtip_subnet
+ ip_version: 4
+ cidr: 192.168.0.0/24
+ network: { get_resource: network }
+ dns_nameservers: [8.8.8.8]
+
+ management_router:
+ type: OS::Neutron::Router
+ properties:
+ name: qtip_router
+ external_gateway_info:
+ network: { get_param: external_network }
+
+ management_router_interface:
+ type: OS::Neutron::RouterInterface
+ properties:
+ router: { get_resource: management_router }
+ subnet: { get_resource: subnet }
+
+ floating_ip:
+ type: OS::Neutron::FloatingIP
+ properties:
+ floating_network: { get_param: external_network }
+
+ floating_ip_association:
+ type: OS::Nova::FloatingIPAssociation
+ properties:
+ floating_ip: { get_resource: floating_ip }
+ server_id: { get_resource: qtip_instance }
- server1_port:
- type: OS::Neutron::Port
+ security_group:
+ type: OS::Neutron::SecurityGroup
properties:
- network_id: { get_resource: private_net }
- fixed_ips:
- - subnet_id: { get_resource: private_subnet }
+ name: qtip_security_group
+ rules:
+ - port_range_min: 22
+ port_range_max: 5201
+ protocol: tcp
+ - port_range_min: 22
+ port_range_max: 5201
+ protocol: udp
+ - protocol: icmp
- my_instance:
+ qtip_instance:
type: OS::Nova::Server
+ depends_on: [subnet]
properties:
- name: { get_param: instance_name }
- image: { get_param: image_name }
- flavor: { get_param: flavor_name }
+ name: { get_param: "OS::stack_name" }
+ image: { get_param: image }
+ flavor: { get_param: flavor }
+ key_name: { get_param: keypair }
+ security_groups: [{ get_resource: security_group }]
networks:
- - port: { get_resource: server1_port }
+ - network: { get_resource: network }
+outputs:
+ instance_ip:
+ description: The IP address of the instance
+ value: { get_attr: [floating_ip, floating_ip_address] }
diff --git a/resources/ansible_roles/qtip-generator/files/compute/setup.yml b/resources/ansible_roles/qtip-generator/files/compute/setup.yml
index d7f2b875..10537615 100644
--- a/resources/ansible_roles/qtip-generator/files/compute/setup.yml
+++ b/resources/ansible_roles/qtip-generator/files/compute/setup.yml
@@ -15,7 +15,7 @@
- hosts: localhost
gather_facts: no
roles:
- - { role: openstack, tasks: create_image }
+ - { role: openstack, external_network: {{ network_group[installer_type] }}, heat_template: heat_template.yml }
{% endif %}
{% if installer_type == 'manual' %}
diff --git a/resources/ansible_roles/qtip-generator/files/compute/teardown.yml b/resources/ansible_roles/qtip-generator/files/compute/teardown.yml
index 84d9c8c1..e483d7f6 100644
--- a/resources/ansible_roles/qtip-generator/files/compute/teardown.yml
+++ b/resources/ansible_roles/qtip-generator/files/compute/teardown.yml
@@ -7,12 +7,6 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-{% if sut_type == 'vnf' %}
-- hosts: localhost
- gather_facts: no
- roles:
- - { role: openstack, tasks: delete_image }
-{% endif %}
- hosts: SUT