diff options
43 files changed, 281 insertions, 2077 deletions
diff --git a/ansible/library/find_kernel.py b/ansible/library/find_kernel.py index 4623bce89..c237baaf2 100644 --- a/ansible/library/find_kernel.py +++ b/ansible/library/find_kernel.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -import os DOCUMENTATION = ''' --- diff --git a/ansible/library/my_make.py b/ansible/library/my_make.py deleted file mode 100644 index 35240851c..000000000 --- a/ansible/library/my_make.py +++ /dev/null @@ -1,137 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# (c) 2015, Linus Unnebäck <linus@folkdatorn.se> -# -# This file is part of Ansible -# -# This module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this software. If not, see <http://www.gnu.org/licenses/>. - -from __future__ import absolute_import -DOCUMENTATION = ''' ---- -module: my_make -short_description: Run targets in a Makefile -requirements: [ make ] -version_added: "2.1" -author: Linus Unnebäck (@LinusU) <linus@folkdatorn.se> -description: - - Run targets in a Makefile. -options: - target: - description: - - The target to run - required: false - default: none - params: - description: - - Any extra parameters to pass to make - required: false - default: none - extra_args: - description: - - Any extra options to pass to make - required: false - default: none - chdir: - description: - - cd into this directory before running make - required: true -''' - -EXAMPLES = ''' -# Build the default target -- make: chdir=/home/ubuntu/cool-project - -# Run `install` target as root -- make: chdir=/home/ubuntu/cool-project target=install - become: yes - -# Pass in extra arguments to build -- make: - chdir: /home/ubuntu/cool-project - target: all - params: - NUM_THREADS: 4 - BACKEND: lapack -''' - -# TODO: Disabled the RETURN as it was breaking docs building. Someone needs to -# fix this -RETURN = '''# ''' - - -def format_params(params): - return [k + '=' + str(v) for k, v in params.items()] - - -def push_arguments(cmd, args): - if args['extra_args'] is not None: - cmd.extend(shlex.split(args['extra_args'])) - if args['target'] is not None: - cmd.append(args['target']) - if args['params'] is not None: - cmd.extend(format_params(args['params'])) - return cmd - - -def check_changed(make_path, module, args): - cmd = push_arguments([make_path, '--question'], args) - rc, _, __ = module.run_command(cmd, check_rc=False, cwd=args['chdir']) - return rc != 0 - - -def run_make(make_path, module, args): - cmd = push_arguments([make_path], args) - module.run_command(cmd, check_rc=True, cwd=args['chdir']) - - -def main(): - module = AnsibleModule( - supports_check_mode=True, - argument_spec=dict( - target=dict(required=False, default=None, type='str'), - params=dict(required=False, default=None, type='dict'), - extra_args=dict(required=False, default=None, type='str'), - chdir=dict(required=True, default=None, type='str'), - ), - ) - args = dict( - changed=False, - failed=False, - target=module.params['target'], - params=module.params['params'], - extra_args=module.params['extra_args'], - chdir=module.params['chdir'], - ) - make_path = module.get_bin_path('make', True) - - # Check if target is up to date - args['changed'] = check_changed(make_path, module, args) - - # Check only; don't modify - if module.check_mode: - module.exit_json(changed=args['changed']) - - # Target is already up to date - if not args['changed']: - module.exit_json(**args) - - run_make(make_path, module, args) - module.exit_json(**args) - -from ansible.module_utils.basic import * - -if __name__ == '__main__': - main() diff --git a/ansible/library/my_os_networks_facts.py b/ansible/library/my_os_networks_facts.py deleted file mode 100644 index 1b6ad80f9..000000000 --- a/ansible/library/my_os_networks_facts.py +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2015 Hewlett-Packard Development Company, L.P. -# -# This module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this software. If not, see <http://www.gnu.org/licenses/>. - -try: - import shade - HAS_SHADE = True -except ImportError: - HAS_SHADE = False - -DOCUMENTATION = ''' ---- -module: my_os_network_facts -short_description: Retrieve facts about one or more OpenStack networks. -version_added: "2.0" -author: "Davide Agnello (@dagnello)" -description: - - Retrieve facts about one or more networks from OpenStack. -requirements: - - "python >= 2.6" - - "shade" -options: - network: - description: - - Name or ID of the Network - required: false - filters: - description: - - A dictionary of meta data to use for further filtering. Elements of - this dictionary may be additional dictionaries. - required: false -extends_documentation_fragment: openstack -''' - -EXAMPLES = ''' -# Gather facts about previously created networks -- my_os_network_facts: - auth: - auth_url: https://your_api_url.com:9000/v2.0 - username: user - password: password - project_name: someproject -- debug: var=openstack_networks - -# Gather facts about a previously created network by name -- my_os_network_facts: - auth: - auth_url: https://your_api_url.com:9000/v2.0 - username: user - password: password - project_name: someproject - name: network1 -- debug: var=openstack_networks - -# Gather facts about a previously created network with filter (note: name and - filters parameters are Not mutually exclusive) -- my_os_network_facts: - auth: - auth_url: https://your_api_url.com:9000/v2.0 - username: user - password: password - project_name: someproject - filters: - tenant_id: 55e2ce24b2a245b09f181bf025724cbe - subnets: - - 057d4bdf-6d4d-4728-bb0f-5ac45a6f7400 - - 443d4dc0-91d4-4998-b21c-357d10433483 -- debug: var=openstack_networks -''' - -RETURN = ''' -openstack_networks: - description: has all the openstack facts about the networks - returned: always, but can be null - type: complex - contains: - id: - description: Unique UUID. - returned: success - type: string - name: - description: Name given to the network. - returned: success - type: string - status: - description: Network status. - returned: success - type: string - subnets: - description: Subnet(s) included in this network. - returned: success - type: list of strings - tenant_id: - description: Tenant id associated with this network. - returned: success - type: string - shared: - description: Network shared flag. - returned: success - type: boolean -''' - -def main(): - - argument_spec = openstack_full_argument_spec( - network={'required': False, 'default': None}, - filters={'required': False, 'default': None} - ) - module_kwargs = openstack_module_kwargs() - module = AnsibleModule(argument_spec) - - if not HAS_SHADE: - module.fail_json(msg='shade is required for this module') - - network = module.params.pop('network') - filters = module.params.pop('filters') - - try: - cloud = shade.openstack_cloud(**module.params) - networks = cloud.search_networks(network, filters) - module.exit_json(changed=False, ansible_facts={ - 'openstack_networks': networks}) - - except shade.OpenStackCloudException as e: - module.fail_json(msg=str(e)) - -# this is magic, see lib/ansible/module_common.py -from ansible.module_utils.basic import * -from ansible.module_utils.openstack import * -if __name__ == '__main__': - main() diff --git a/ansible/library/my_os_router_facts.py b/ansible/library/my_os_router_facts.py deleted file mode 100644 index ce8d2af25..000000000 --- a/ansible/library/my_os_router_facts.py +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2016 IBM -# -# This module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this software. If not, see <http://www.gnu.org/licenses/>. - -try: - import shade - HAS_SHADE = True -except ImportError: - HAS_SHADE = False - -DOCUMENTATION = ''' -module: my_os_router_facts -short_description: Retrieve facts about routers within OpenStack. -version_added: "2.1" -author: "Originally: David Shrewsbury (@Shrews); modified" -description: - - Retrieve facts about routers from OpenStack. -notes: - - Facts are placed in the C(openstack_routers) variable. -requirements: - - "python >= 2.6" - - "shade" -options: - port: - description: - - Unique name or ID of a port. - required: false - default: null - filters: - description: - - A dictionary of meta data to use for further filtering. Elements - of this dictionary will be matched against the returned port - dictionaries. Matching is currently limited to strings within - the port dictionary, or strings within nested dictionaries. - required: false - default: null -extends_documentation_fragment: openstack -''' - -EXAMPLES = ''' -# Gather facts about all routers -- my_os_router_facts: - cloud: mycloud - -# Gather facts about a single port -- my_os_router_facts: - cloud: mycloud - port: 6140317d-e676-31e1-8a4a-b1913814a471 - -# Gather facts about all routers that have device_id set to a specific value -# and with a status of ACTIVE. -- my_os_router_facts: - cloud: mycloud - router: - description: - - Name or ID of the router - required: false - filters: - device_id: 1038a010-3a37-4a9d-82ea-652f1da36597 - status: ACTIVE -''' - -RETURN = ''' -openstack_routers: - description: List of port dictionaries. A subset of the dictionary keys - listed below may be returned, depending on your cloud provider. - returned: always, but can be null - type: complex - contains: -''' - - -def main(): - argument_spec = openstack_full_argument_spec( - router={'required': False, 'default': None}, - filters={'required': False, 'type': 'dict', 'default': None}, - ) - module_kwargs = openstack_module_kwargs() - module = AnsibleModule(argument_spec, **module_kwargs) - - if not HAS_SHADE: - module.fail_json(msg='shade is required for this module') - - name = module.params.pop('name') - filters = module.params.pop('filters') - - try: - cloud = shade.openstack_cloud(**module.params) - routers = cloud.search_routers(name, filters) - module.exit_json(changed=False, ansible_facts=dict( - openstack_routers=routers)) - - except shade.OpenStackCloudException as e: - module.fail_json(msg=str(e)) - -from ansible.module_utils.basic import * -from ansible.module_utils.openstack import * - -if __name__ == '__main__': - main() diff --git a/ansible/library/os_images_facts.py b/ansible/library/os_images_facts.py deleted file mode 100644 index 736403893..000000000 --- a/ansible/library/os_images_facts.py +++ /dev/null @@ -1,166 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2015 Hewlett-Packard Development Company, L.P. -# -# This module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this software. If not, see <http://www.gnu.org/licenses/>. - -try: - import shade - HAS_SHADE = True -except ImportError: - HAS_SHADE = False - -DOCUMENTATION = ''' -module: os_images_facts -short_description: Retrieve facts about an image within OpenStack. -version_added: "2.0" -author: "Originally: Davide Agnello (@dagnello); modified" -description: - - Retrieve facts about a image image from OpenStack. -notes: - - Facts are placed in the C(openstack) variable. -requirements: - - "python >= 2.6" - - "shade" -options: - image: - description: - - Name or ID of the image - required: false - filters: - description: - - A dictionary of meta data to use for further filtering. Elements of - this dictionary may be additional dictionaries. - required: false -extends_documentation_fragment: openstack -''' - -EXAMPLES = ''' -# Gather facts about a previously created image named image1 -- os_images_facts: - auth: - auth_url: https://your_api_url.com:9000/v2.0 - username: user - password: password - project_name: someproject - image: image1 -- debug: var=openstack -''' - -RETURN = ''' -openstack_image: - description: has all the openstack facts about the image - returned: always, but can be null - type: complex - contains: - id: - description: Unique UUID. - returned: success - type: string - name: - description: Name given to the image. - returned: success - type: string - status: - description: Image status. - returned: success - type: string - created_at: - description: Image created at timestamp. - returned: success - type: string - deleted: - description: Image deleted flag. - returned: success - type: boolean - container_format: - description: Container format of the image. - returned: success - type: string - min_ram: - description: Min amount of RAM required for this image. - returned: success - type: int - disk_format: - description: Disk format of the image. - returned: success - type: string - updated_at: - description: Image updated at timestamp. - returned: success - type: string - properties: - description: Additional properties associated with the image. - returned: success - type: dict - min_disk: - description: Min amount of disk space required for this image. - returned: success - type: int - protected: - description: Image protected flag. - returned: success - type: boolean - checksum: - description: Checksum for the image. - returned: success - type: string - owner: - description: Owner for the image. - returned: success - type: string - is_public: - description: Is public flag of the image. - returned: success - type: boolean - deleted_at: - description: Image deleted at timestamp. - returned: success - type: string - size: - description: Size of the image. - returned: success - type: int -''' - - -def main(): - - argument_spec = openstack_full_argument_spec( - image={'required': False, 'default': None}, - filters={'required': False, 'default': None}, - ) - module_kwargs = openstack_module_kwargs() - module = AnsibleModule(argument_spec, **module_kwargs) - - if not HAS_SHADE: - module.fail_json(msg='shade is required for this module') - - image = module.params.pop('image') - filters = module.params.pop('filters') - - try: - cloud = shade.openstack_cloud(**module.params) - images = cloud.search_images(image, filters) - module.exit_json(changed=False, ansible_facts={ - 'openstack_images': images}) - - except shade.OpenStackCloudException as e: - module.fail_json(msg=str(e)) - -# this is magic, see lib/ansible/module_common.py -from ansible.module_utils.basic import * -from ansible.module_utils.openstack import * -if __name__ == '__main__': - main() diff --git a/ansible/library/os_router_facts.py b/ansible/library/os_router_facts.py deleted file mode 100644 index b14a362ef..000000000 --- a/ansible/library/os_router_facts.py +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2016 IBM -# -# This module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this software. If not, see <http://www.gnu.org/licenses/>. - -try: - import shade - HAS_SHADE = True -except ImportError: - HAS_SHADE = False - -DOCUMENTATION = ''' -module: os_router_facts -short_description: Retrieve facts about routers within OpenStack. -version_added: "2.1" -author: "Originally: David Shrewsbury (@Shrews); modified" -description: - - Retrieve facts about routers from OpenStack. -notes: - - Facts are placed in the C(openstack_routers) variable. -requirements: - - "python >= 2.6" - - "shade" -options: - port: - description: - - Unique name or ID of a port. - required: false - default: null - filters: - description: - - A dictionary of meta data to use for further filtering. Elements - of this dictionary will be matched against the returned port - dictionaries. Matching is currently limited to strings within - the port dictionary, or strings within nested dictionaries. - required: false - default: null -extends_documentation_fragment: openstack -''' - -EXAMPLES = ''' -# Gather facts about all routers -- os_router_facts: - cloud: mycloud - -# Gather facts about a single port -- os_router_facts: - cloud: mycloud - port: 6140317d-e676-31e1-8a4a-b1913814a471 - -# Gather facts about all routers that have device_id set to a specific value -# and with a status of ACTIVE. -- os_router_facts: - cloud: mycloud - router: - description: - - Name or ID of the router - required: false - filters: - device_id: 1038a010-3a37-4a9d-82ea-652f1da36597 - status: ACTIVE -''' - -RETURN = ''' -openstack_routers: - description: List of port dictionaries. A subset of the dictionary keys - listed below may be returned, depending on your cloud provider. - returned: always, but can be null - type: complex - contains: -''' - - -def main(): - argument_spec = openstack_full_argument_spec( - router={'required': False, 'default': None}, - filters={'required': False, 'type': 'dict', 'default': None}, - ) - module_kwargs = openstack_module_kwargs() - module = AnsibleModule(argument_spec, **module_kwargs) - - if not HAS_SHADE: - module.fail_json(msg='shade is required for this module') - - router = module.params.pop('router') - filters = module.params.pop('filters') - - try: - cloud = shade.openstack_cloud(**module.params) - routers = cloud.search_routers(router, filters) - module.exit_json(changed=False, ansible_facts=dict( - openstack_routers=routers)) - - except shade.OpenStackCloudException as e: - module.fail_json(msg=str(e)) - -from ansible.module_utils.basic import * -from ansible.module_utils.openstack import * - -if __name__ == '__main__': - main() diff --git a/ansible/library/os_stack_facts.py b/ansible/library/os_stack_facts.py deleted file mode 100644 index c67947686..000000000 --- a/ansible/library/os_stack_facts.py +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/python - -# Copyright (c) 2015 Hewlett-Packard Development Company, L.P. -# -# This module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this software. If not, see <http://www.gnu.org/licenses/>. - -try: - import shade - HAS_SHADE = True -except ImportError: - HAS_SHADE = False - -DOCUMENTATION = ''' -module: os_stack_facts -short_description: Retrieve facts about an stack within OpenStack. -version_added: "2.0" -author: "Originally: Davide Agnello (@dagnello); modified" -description: - - Retrieve facts about a stack from OpenStack. -notes: - - Facts are placed in the C(openstack) variable. -requirements: - - "python >= 2.6" - - "shade" -options: -extends_documentation_fragment: openstack -''' - -EXAMPLES = ''' -# Gather facts about a previously created stack named stack1 -- os_stack_facts: - auth: - auth_url: https://your_api_url.com:9000/v2.0 - username: user - password: password - project_name: someproject -- debug: var=openstack_stacks -''' - -RETURN = ''' -openstack_stack: - description: has all the openstack facts about the stack - returned: always, but can be null - type: complex -''' - - -def main(): - - argument_spec = openstack_full_argument_spec( - ) - module_kwargs = openstack_module_kwargs() - module = AnsibleModule(argument_spec, **module_kwargs) - - if not HAS_SHADE: - module.fail_json(msg='shade is required for this module') - - - try: - cloud = shade.openstack_cloud(**module.params) - stacks = cloud.list_stacks() - module.exit_json(changed=False, ansible_facts={ - 'openstack_stacks': stacks}) - - except shade.OpenStackCloudException as e: - module.fail_json(msg=str(e)) - -# this is magic, see lib/ansible/module_common.py -from ansible.module_utils.basic import * -from ansible.module_utils.openstack import * -if __name__ == '__main__': - main() diff --git a/ansible/library/parted.py b/ansible/library/parted.py deleted file mode 100755 index af9c80f7e..000000000 --- a/ansible/library/parted.py +++ /dev/null @@ -1,705 +0,0 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- - -# (c) 2016, Fabrizio Colonna <colofabrix@tin.it> -# -# This file is part of Ansible -# -# Ansible is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# Ansible is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Ansible. If not, see <http://www.gnu.org/licenses/>. - -ANSIBLE_METADATA = {'metadata_version': '1.0', - 'status': ['preview'], - 'supported_by': 'curated'} - - -DOCUMENTATION = ''' ---- -author: - - "Fabrizio Colonna (@ColOfAbRiX)" -module: parted -short_description: Configure block device partitions -version_added: "2.3" -description: - - This module allows configuring block device partition using the C(parted) - command line tool. For a full description of the fields and the options - check the GNU parted manual. -notes: - - When fetching information about a new disk and when the version of parted - installed on the system is before version 3.1, the module queries the kernel - through C(/sys/) to obtain disk information. In this case the units CHS and - CYL are not supported. -requirements: - - This module requires parted version 1.8.3 and above. - - If the version of parted is below 3.1, it requires a Linux version running - the sysfs file system C(/sys/). -options: - device: - description: The block device (disk) where to operate. - required: True - align: - description: Set alignment for newly created partitions. - choices: ['none', 'cylinder', 'minimal', 'optimal'] - default: optimal - number: - description: - - The number of the partition to work with or the number of the partition - that will be created. Required when performing any action on the disk, - except fetching information. - unit: - description: - - Selects the current default unit that Parted will use to display - locations and capacities on the disk and to interpret those given by the - user if they are not suffixed by an unit. When fetching information about - a disk, it is always recommended to specify a unit. - choices: [ - 's', 'B', 'KB', 'KiB', 'MB', 'MiB', 'GB', 'GiB', 'TB', 'TiB', '%', 'cyl', - 'chs', 'compact' - ] - default: KiB - label: - description: Creates a new disk label. - choices: [ - 'aix', 'amiga', 'bsd', 'dvh', 'gpt', 'loop', 'mac', 'msdos', 'pc98', - 'sun', '' - ] - default: msdos - part_type: - description: - - Is one of 'primary', 'extended' or 'logical' and may be specified only - with 'msdos' or 'dvh' partition tables. A name must be specified for a - 'gpt' partition table. Neither part-type nor name may be used with a - 'sun' partition table. - choices: ['primary', 'extended', 'logical'] - part_start: - description: - - Where the partition will start as offset from the beginning of the disk, - that is, the "distance" from the start of the disk. The distance can be - specified with all the units supported by parted (except compat) and - it is case sensitive. E.g. C(10GiB), C(15%). - default: 0% - part_end : - description: - - Where the partition will end as offset from the beginning of the disk, - that is, the "distance" from the start of the disk. The distance can be - specified with all the units supported by parted (except compat) and - it is case sensitive. E.g. C(10GiB), C(15%). - default: 100% - name: - description: - - Sets the name for the partition number (GPT, Mac, MIPS and PC98 only). - flags: - description: A list of the flags that has to be set on the partition. - state: - description: - - If to create or delete a partition. If set to C(info) the module will - only return the device information. - choices: ['present', 'absent', 'info'] - default: info -''' - -RETURN = ''' -partition_info: - description: Current partition information - returned: success - type: dict - contains: - device: - description: Generic device information. - type: dict - partitions: - description: List of device partitions. - type: list - sample: > - { - "disk": { - "dev": "/dev/sdb", - "logical_block": 512, - "model": "VMware Virtual disk", - "physical_block": 512, - "size": 5.0, - "table": "msdos", - "unit": "gib" - }, - "partitions": [{ - "begin": 0.0, - "end": 1.0, - "flags": ["boot", "lvm"], - "fstype": null, - "num": 1, - "size": 1.0 - }, { - "begin": 1.0, - "end": 5.0, - "flags": [], - "fstype": null, - "num": 2, - "size": 4.0 - }] - } -''' - -EXAMPLES = """ -# Create a new primary partition -- parted: - device: /dev/sdb - number: 1 - state: present - -# Remove partition number 1 -- parted: - device: /dev/sdb - number: 1 - state: absent - -# Create a new primary partition with a size of 1GiB -- parted: - device: /dev/sdb - number: 1 - state: present - part_end: 1gib - -# Create a new primary partition for LVM -- parted: - device: /dev/sdb - number: 2 - flags: [ lvm ] - state: present - part_start: 1gib - -# Read device information (always use unit when probing) -- parted: device=/dev/sdb unit=MiB - register: sdb_info - -# Remove all partitions from disk -- parted: - device: /dev/sdb - number: "{{ item.num }}" - state: absent - with_items: - - "{{ sdb_info.partitions }}" -""" - - -from ansible.module_utils.basic import AnsibleModule -import locale -import math -import re -import os - - -# Reference prefixes (International System of Units and IEC) -units_si = ['B', 'KB', 'MB', 'GB', 'TB'] -units_iec = ['B', 'KiB', 'MiB', 'GiB', 'TiB'] -parted_units = units_si + units_iec + ['s', '%', 'cyl', 'chs', 'compact'] - - -def parse_unit(size_str, unit=''): - """ - Parses a string containing a size of information - """ - matches = re.search(r'^([\d.]+)([\w%]+)?$', size_str) - if matches is None: - # "<cylinder>,<head>,<sector>" format - matches = re.search(r'^(\d+),(\d+),(\d+)$', size_str) - if matches is None: - module.fail_json( - msg="Error interpreting parted size output: '%s'" % size_str - ) - - size = { - 'cylinder': int(matches.group(1)), - 'head': int(matches.group(2)), - 'sector': int(matches.group(3)) - } - unit = 'chs' - - else: - # Normal format: "<number>[<unit>]" - if matches.group(2) is not None: - unit = matches.group(2) - - size = float(matches.group(1)) - - return size, unit - - -def parse_partition_info(parted_output, unit): - """ - Parses the output of parted and transforms the data into - a dictionary. - - Parted Machine Parseable Output: - See: https://lists.alioth.debian.org/pipermail/parted-devel/2006-December/00 - 0573.html - - All lines end with a semicolon (;) - - The first line indicates the units in which the output is expressed. - CHS, CYL and BYT stands for CHS, Cylinder and Bytes respectively. - - The second line is made of disk information in the following format: - "path":"size":"transport-type":"logical-sector-size":"physical-sector-siz - e":"partition-table-type":"model-name"; - - If the first line was either CYL or CHS, the next line will contain - information on no. of cylinders, heads, sectors and cylinder size. - - Partition information begins from the next line. This is of the format: - (for BYT) - "number":"begin":"end":"size":"filesystem-type":"partition-name":"flags-s - et"; - (for CHS/CYL) - "number":"begin":"end":"filesystem-type":"partition-name":"flags-set"; - """ - lines = [x for x in parted_output.split('\n') if x.strip() != ''] - - # Generic device info - generic_params = lines[1].rstrip(';').split(':') - - # The unit is read once, because parted always returns the same unit - size, unit = parse_unit(generic_params[1], unit) - - generic = { - 'dev': generic_params[0], - 'size': size, - 'unit': unit.lower(), - 'table': generic_params[5], - 'model': generic_params[6], - 'logical_block': int(generic_params[3]), - 'physical_block': int(generic_params[4]) - } - - # CYL and CHS have an additional line in the output - if unit in ['cyl', 'chs']: - chs_info = lines[2].rstrip(';').split(':') - cyl_size, cyl_unit = parse_unit(chs_info[3]) - generic['chs_info'] = { - 'cylinders': int(chs_info[0]), - 'heads': int(chs_info[1]), - 'sectors': int(chs_info[2]), - 'cyl_size': cyl_size, - 'cyl_size_unit': cyl_unit.lower() - } - lines = lines[1:] - - parts = [] - for line in lines[2:]: - part_params = line.rstrip(';').split(':') - - # CHS use a different format than BYT, but contrary to what stated by - # the author, CYL is the same as BYT. I've tested this undocumented - # behaviour down to parted version 1.8.3, which is the first version - # that supports the machine parseable output. - if unit != 'chs': - size = parse_unit(part_params[3])[0] - fstype = part_params[4] - flags = part_params[5] - else: - size = "" - fstype = part_params[3] - flags = part_params[4] - - parts.append({ - 'num': int(part_params[0]), - 'begin': parse_unit(part_params[1])[0], - 'end': parse_unit(part_params[2])[0], - 'size': size, - 'fstype': fstype, - 'flags': [f.strip() for f in flags.split(', ') if f != ''], - 'unit': unit.lower(), - }) - - return {'generic': generic, 'partitions': parts} - - -def format_disk_size(size_bytes, unit): - """ - Formats a size in bytes into a different unit, like parted does. It doesn't - manage CYL and CHS formats, though. - This function has been adapted from https://github.com/Distrotech/parted/blo - b/279d9d869ff472c52b9ec2e180d568f0c99e30b0/libparted/unit.c - """ - global units_si, units_iec - - unit = unit.lower() - - # Shortcut - if size_bytes == 0: - return 0.0 - - # Cases where we default to 'compact' - if unit in ['', 'compact', 'cyl', 'chs']: - index = max(0, int( - (math.log10(size_bytes) - 1.0) / 3.0 - )) - unit = 'b' - if index < len(units_si): - unit = units_si[index] - - # Find the appropriate multiplier - multiplier = 1.0 - if unit in units_si: - multiplier = 1000.0 ** units_si.index(unit) - elif unit in units_iec: - multiplier = 1024.0 ** units_iec.index(unit) - - output = size_bytes / multiplier * (1 + 1E-16) - - # Corrections to round up as per IEEE754 standard - if output < 10: - w = output + 0.005 - elif output < 100: - w = output + 0.05 - else: - w = output + 0.5 - - if w < 10: - precision = 2 - elif w < 100: - precision = 1 - else: - precision = 0 - - # Round and return - return round(output, precision), unit - - -def get_unlabeled_device_info(device, unit): - """ - Fetches device information directly from the kernel and it is used when - parted cannot work because of a missing label. It always returns a 'unknown' - label. - """ - device_name = os.path.basename(device) - base = "/sys/block/%s" % device_name - - vendor = read_record(base + "/device/vendor", "Unknown") - model = read_record(base + "/device/model", "model") - logic_block = int(read_record(base + "/queue/logical_block_size", 0)) - phys_block = int(read_record(base + "/queue/physical_block_size", 0)) - size_bytes = int(read_record(base + "/size", 0)) * logic_block - - size, unit = format_disk_size(size_bytes, unit) - - return { - 'generic': { - 'dev': device, - 'table': "unknown", - 'size': size, - 'unit': unit, - 'logical_block': logic_block, - 'physical_block': phys_block, - 'model': "%s %s" % (vendor, model), - }, - 'partitions': [] - } - - -def get_device_info(device, unit): - """ - Fetches information about a disk and its partitions and it returns a - dictionary. - """ - global module - - # If parted complains about missing labels, it means there are no partitions. - # In this case only, use a custom function to fetch information and emulate - # parted formats for the unit. - label_needed = check_parted_label(device) - if label_needed: - return get_unlabeled_device_info(device, unit) - - command = "parted -s -m %s -- unit '%s' print" % (device, unit) - rc, out, err = module.run_command(command) - if rc != 0 and 'unrecognised disk label' not in err: - module.fail_json(msg=( - "Error while getting device information with parted " - "script: '%s'" % command), - rc=rc, out=out, err=err - ) - - return parse_partition_info(out, unit) - - -def check_parted_label(device): - """ - Determines if parted needs a label to complete its duties. Versions prior - to 3.1 don't return data when there is no label. For more information see: - http://upstream.rosalinux.ru/changelogs/libparted/3.1/changelog.html - """ - # Check the version - parted_major, parted_minor, _ = parted_version() - if (parted_major == 3 and parted_minor >= 1) or parted_major > 3: - return False - - # Older parted versions return a message in the stdout and RC > 0. - rc, out, err = module.run_command("parted -s -m %s print" % device) - if rc != 0 and 'unrecognised disk label' in out.lower(): - return True - - return False - - -def parted_version(): - """ - Returns the major and minor version of parted installed on the system. - """ - global module - - rc, out, err = module.run_command("parted --version") - if rc != 0: - module.fail_json( - msg="Failed to get parted version.", rc=rc, out=out, err=err - ) - - lines = [x for x in out.split('\n') if x.strip() != ''] - if len(lines) == 0: - module.fail_json(msg="Failed to get parted version.", rc=0, out=out) - - matches = re.search(r'^parted.+(\d+)\.(\d+)(?:\.(\d+))?$', lines[0]) - if matches is None: - module.fail_json(msg="Failed to get parted version.", rc=0, out=out) - - # Convert version to numbers - major = int(matches.group(1)) - minor = int(matches.group(2)) - rev = 0 - if matches.group(3) is not None: - rev = int(matches.group(3)) - - return major, minor, rev - - -def parted(script, device, align): - """ - Runs a parted script. - """ - global module - - if script and not module.check_mode: - command = "parted -s -m -a %s %s -- %s" % (align, device, script) - rc, out, err = module.run_command(command) - - if rc != 0: - module.fail_json( - msg="Error while running parted script: %s" % command.strip(), - rc=rc, out=out, err=err - ) - - -def read_record(file_path, default=None): - """ - Reads the first line of a file and returns it. - """ - try: - f = open(file_path, 'r') - try: - return f.readline().strip() - finally: - f.close() - except IOError: - return default - - -def part_exists(partitions, attribute, number): - """ - Looks if a partition that has a specific value for a specific attribute - actually exists. - """ - return any( - part[attribute] and - part[attribute] == number for part in partitions - ) - - -def check_size_format(size_str): - """ - Checks if the input string is an allowed size - """ - size, unit = parse_unit(size_str) - return unit in parted_units - - -def main(): - global module, units_si, units_iec - - changed = False - output_script = "" - script = "" - module = AnsibleModule( - argument_spec={ - 'device': {'required': True, 'type': 'str'}, - 'align': { - 'default': 'optimal', - 'choices': ['none', 'cylinder', 'minimal', 'optimal'], - 'type': 'str' - }, - 'number': {'default': None, 'type': 'int'}, - - # unit <unit> command - 'unit': { - 'default': 'KiB', - 'choices': parted_units, - 'type': 'str' - }, - - # mklabel <label-type> command - 'label': { - 'choices': [ - 'aix', 'amiga', 'bsd', 'dvh', 'gpt', 'loop', 'mac', 'msdos', - 'pc98', 'sun', '' - ], - 'type': 'str' - }, - - # mkpart <part-type> [<fs-type>] <start> <end> command - 'part_type': { - 'default': 'primary', - 'choices': ['primary', 'extended', 'logical'], - 'type': 'str' - }, - 'part_start': {'default': '0%', 'type': 'str'}, - 'part_end': {'default': '100%', 'type': 'str'}, - - # name <partition> <name> command - 'name': {'type': 'str'}, - - # set <partition> <flag> <state> command - 'flags': {'type': 'list'}, - - # rm/mkpart command - 'state': { - 'choices': ['present', 'absent', 'info'], - 'default': 'info', - 'type': 'str' - } - }, - supports_check_mode=True, - ) - - # Data extraction - device = module.params['device'] - align = module.params['align'] - number = module.params['number'] - unit = module.params['unit'] - label = module.params['label'] - part_type = module.params['part_type'] - part_start = module.params['part_start'] - part_end = module.params['part_end'] - name = module.params['name'] - state = module.params['state'] - flags = module.params['flags'] - - # Conditioning - if number and number < 0: - module.fail_json(msg="The partition number must be non negative.") - if not check_size_format(part_start): - module.fail_json( - msg="The argument 'part_start' doesn't respect required format." - "The size unit is case sensitive.", - err=parse_unit(part_start) - ) - if not check_size_format(part_end): - module.fail_json( - msg="The argument 'part_end' doesn't respect required format." - "The size unit is case sensitive.", - err=parse_unit(part_end) - ) - - # Read the current disk information - current_device = get_device_info(device, unit) - current_parts = current_device['partitions'] - - if state == 'present': - # Default value for the label - if not current_device['generic']['table'] or \ - current_device['generic']['table'] == 'unknown' and \ - not label: - label = 'msdos' - - # Assign label if required - if label: - script += "mklabel %s " % label - - # Create partition if required - if part_type and not part_exists(current_parts, 'num', number): - script += "mkpart %s %s %s " % ( - part_type, - part_start, - part_end - ) - - # Set the unit of the run - if unit and script: - script = "unit %s %s" % (unit, script) - - # Execute the script and update the data structure. - # This will create the partition for the next steps - if script: - output_script += script - parted(script, device, align) - changed = True - script = "" - - current_parts = get_device_info(device, unit)['partitions'] - - if part_exists(current_parts, 'num', number) or module.check_mode: - partition = {'flags': []} # Empty structure for the check-mode - if not module.check_mode: - partition = [p for p in current_parts if p['num'] == number][0] - - # Assign name to the the partition - if name: - script += "name %s %s " % (number, name) - - # Manage flags - if flags: - # Compute only the changes in flags status - flags_off = list(set(partition['flags']) - set(flags)) - flags_on = list(set(flags) - set(partition['flags'])) - - for f in flags_on: - script += "set %s %s on " % (number, f) - - for f in flags_off: - script += "set %s %s off " % (number, f) - - # Set the unit of the run - if unit and script: - script = "unit %s %s" % (unit, script) - - # Execute the script - if script: - output_script += script - changed = True - parted(script, device, align) - - elif state == 'absent': - # Remove the partition - if part_exists(current_parts, 'num', number) or module.check_mode: - script = "rm %s " % number - output_script += script - changed = True - parted(script, device, align) - - elif state == 'info': - output_script = "unit '%s' print " % unit - - # Final status of the device - final_device_status = get_device_info(device, unit) - module.exit_json( - changed=changed, - disk=final_device_status['generic'], - partitions=final_device_status['partitions'], - script=output_script.strip() - ) - - -if __name__ == '__main__': - main() diff --git a/ansible/library/shade_api.py b/ansible/library/shade_api.py new file mode 100644 index 000000000..ad1180832 --- /dev/null +++ b/ansible/library/shade_api.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python +# Copyright (c) 2017 Intel Corporation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +DOCUMENTATION = ''' +--- +module: shade_api +short_description: directly access shade +description: + - directly access shade API +options: + method: shade method + args: list of ags + kwargs: dict of kwargs + fact_name: name of ansible fact to store result +''' + +try: + import shade +except ImportError: + SHADE_PRESENT = False +else: + SHADE_PRESENT = True + + +def main(): + module = AnsibleModule( + argument_spec={ + 'method': {'required': True, 'type': 'str'}, + 'args': {'required': False, 'type': 'list', 'default': []}, + 'kwargs': {'required': False, 'type': 'dict', 'default': {}}, + 'os_auth': {'required': False, 'type': 'dict', 'default': {}}, + 'fact_name': {'required': True, 'type': 'str'}, + } + ) + + if not SHADE_PRESENT: + module.fail_json(msg="shade not found") + shade.simple_logging(debug=True) + params = module.params + method = params['method'] + args = params['args'] + kwargs = params['kwargs'] + os_auth = params['os_auth'] + fact_name = params['fact_name'] + if os_auth: + os.environ.update(os_auth) + + c = shade.openstack_cloud() + module.debug(args) + module.debug(kwargs) + ret = getattr(c, method)(*args, **kwargs) + if ret: + try: + # convert to regular dict, might not be necessary + ret = ret.toDict() + except AttributeError: + pass + else: + ret = {} + ansible_facts = { + fact_name: ret + } + module.exit_json(ansible_facts=ansible_facts) + + +# <<INCLUDE_ANSIBLE_MODULE_COMMON>> +from ansible.module_utils.basic import * # noqa + +if __name__ == '__main__': + main() diff --git a/ansible/roles/check_openstack_services/tasks/main.yml b/ansible/roles/check_openstack_services/tasks/main.yml index 02e730533..bfd9e1193 100644 --- a/ansible/roles/check_openstack_services/tasks/main.yml +++ b/ansible/roles/check_openstack_services/tasks/main.yml @@ -13,13 +13,19 @@ # limitations under the License. --- - name: Check images - os_images_facts: {} + shade_api: + method: search_images + fact_name: openstack_images + args: + - ~ environment: "{{ openrc }}" - name: Check servers os_server_facts: {} - environment: "{{ openrc }}" +# environment: "{{ openrc }}" - name: Check stacks - os_stack_facts: {} + shade_api: + method: list_stacks + fact_name: openstack_stacks environment: "{{ openrc }}" diff --git a/ansible/roles/clean_images/tasks/main.yml b/ansible/roles/clean_images/tasks/main.yml index 5cbae06d8..1bc3dc4ef 100644 --- a/ansible/roles/clean_images/tasks/main.yml +++ b/ansible/roles/clean_images/tasks/main.yml @@ -13,15 +13,21 @@ # limitations under the License. --- - name: Get all images - os_images_facts: {} + shade_api: + method: search_images + fact_name: openstack_images + args: + - ~ environment: "{{ openrc }}" -- debug: var=openstack_images +- debug: + var: openstack_images - set_fact: images_to_clean: "{{ openstack_images|map(attribute='name')|select('search', 'yardstick|cirros|Ubuntu-14\\.04')|list }}" -- debug: var=images_to_clean +- debug: + var: images_to_clean - name: Cleanup images os_image: diff --git a/ansible/roles/create_storperf_admin_rc/library/my_os_project_facts.py b/ansible/roles/create_storperf_admin_rc/library/my_os_project_facts.py deleted file mode 100644 index debb8dd5b..000000000 --- a/ansible/roles/create_storperf_admin_rc/library/my_os_project_facts.py +++ /dev/null @@ -1,167 +0,0 @@ -#!/usr/bin/python -# Copyright (c) 2016 Hewlett-Packard Enterprise Corporation -# -# This module is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This software is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this software. If not, see <http://www.gnu.org/licenses/>. - -import sys - -try: - import shade - HAS_SHADE = True -except ImportError: - HAS_SHADE = False - -DOCUMENTATION = ''' ---- -module: os_project_facts -short_description: Retrieve facts about one or more OpenStack projects -extends_documentation_fragment: openstack -version_added: "2.1" -author: "Ricardo Carrillo Cruz (@rcarrillocruz)" -description: - - Retrieve facts about a one or more OpenStack projects -requirements: - - "python >= 2.6" - - "shade" -options: - name: - description: - - Name or ID of the project - required: true - domain: - description: - - Name or ID of the domain containing the project if the cloud supports domains - required: false - default: None - filters: - description: - - A dictionary of meta data to use for further filtering. Elements of - this dictionary may be additional dictionaries. - required: false - default: None -''' - -EXAMPLES = ''' -# Gather facts about previously created projects -- my_os_project_facts: - cloud: awesomecloud -- debug: var=openstack_projects - -# Gather facts about a previously created project by name -- my_os_project_facts: - cloud: awesomecloud - name: demoproject -- debug: var=openstack_projects - -# Gather facts about a previously created project in a specific domain -- my_os_project_facts - cloud: awesomecloud - name: demoproject - domain: admindomain -- debug: var=openstack_projects - -# Gather facts about a previously created project in a specific domain - with filter -- my_os_project_facts - cloud: awesomecloud - name: demoproject - domain: admindomain - filters: - enabled: False -- debug: var=openstack_projects -''' - - -RETURN = ''' -openstack_projects: - description: has all the OpenStack facts about projects - returned: always, but can be null - type: complex - contains: - id: - description: Unique UUID. - returned: success - type: string - name: - description: Name given to the project. - returned: success - type: string - description: - description: Description of the project - returned: success - type: string - enabled: - description: Flag to indicate if the project is enabled - returned: success - type: bool - domain_id: - description: Domain ID containing the project (keystone v3 clouds only) - returned: success - type: bool -''' - -def main(): - - argument_spec = openstack_full_argument_spec( - name=dict(required=False, default=None), - domain=dict(required=False, default=None), - filters=dict(required=False, type='dict', default=None), - ) - - module = AnsibleModule(argument_spec) - - if not HAS_SHADE: - module.fail_json(msg='shade is required for this module') - - try: - name = module.params['name'] - domain = module.params['domain'] - filters = module.params['filters'] - - opcloud = shade.operator_cloud(**module.params) - # module.exit_json(changed=False, ansible_facts=dict( - # openstack_prjects=opcloud.cloud_config.get_auth_args())) - - if domain: - try: - # We assume admin is passing domain id - dom = opcloud.get_domain(domain)['id'] - domain = dom - except: - # If we fail, maybe admin is passing a domain name. - # Note that domains have unique names, just like id. - dom = opcloud.search_domains(filters={'name': domain}) - if dom: - domain = dom[0]['id'] - else: - module.fail_json(msg='Domain name or ID does not exist') - - if not filters: - filters = {} - - filters['domain_id'] = domain - - # projects = opcloud.search_projects(name, filters) - projects = opcloud.list_projects(name, filters) - module.exit_json(changed=False, ansible_facts=dict( - openstack_projects=projects)) - - except shade.OpenStackCloudException as e: - module.fail_json(msg=str(e)) - -from ansible.module_utils.basic import * -from ansible.module_utils.openstack import * - -if __name__ == '__main__': - main() diff --git a/ansible/roles/install_L4Replay/tasks/main.yml b/ansible/roles/install_L4Replay/tasks/main.yml deleted file mode 100644 index 1401d1b13..000000000 --- a/ansible/roles/install_L4Replay/tasks/main.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -# there is no clean for L4Replay -#- my_make: chdir="{{ vnf_build_dir }}/L4Replay" target=clean extra_args="-j {{ ansible_processor_vcpus }}" - -- name: Building L4Replay VNF - my_make: chdir="{{ NSB_INSTALL_DIR }}/L4Replay" params="RTE_SDK={{ dpdk_path }}" extra_args="-j {{ ansible_processor_vcpus }}" - -- command: cp "{{ NSB_INSTALL_DIR }}/L4Replay/build/L4replay" "{{ INSTALL_BIN_PATH }}/" - diff --git a/ansible/roles/install_collectd/tasks/main.yml b/ansible/roles/install_collectd/tasks/main.yml index c1ea4d994..8368df103 100644 --- a/ansible/roles/install_collectd/tasks/main.yml +++ b/ansible/roles/install_collectd/tasks/main.yml @@ -32,7 +32,7 @@ dest: /tmp - name: "make collectd install" - my_make: + make: chdir: "{{ collectd_path }}" target: install diff --git a/ansible/roles/install_dpdk/tasks/main.yml b/ansible/roles/install_dpdk/tasks/main.yml index e189eb629..01ad4baf1 100644 --- a/ansible/roles/install_dpdk/tasks/main.yml +++ b/ansible/roles/install_dpdk/tasks/main.yml @@ -36,13 +36,9 @@ set_fact: RTE_KERNELDIR: "/lib/modules/{{ dpdk_kernel }}/build" -- my_make: +- command: make -j {{ ansible_processor_vcpus }} config T={{ dpdk_make_arch }} O={{ dpdk_make_arch }} + args: chdir: "{{ dpdk_path }}" - target: config - params: - T: "{{ dpdk_make_arch }}" - O: "{{ dpdk_make_arch }}" - extra_args: "-j {{ ansible_processor_vcpus }}" environment: RTE_KERNELDIR: "{{ RTE_KERNELDIR }}" @@ -85,14 +81,15 @@ # TODO: disable ASLR -- my_make: +- name: make dpdk + command: make -j {{ ansible_processor_vcpus }} + args: chdir: "{{ dpdk_path }}/{{ dpdk_make_arch}}" - extra_args: "-j {{ ansible_processor_vcpus }}" environment: RTE_KERNELDIR: "{{ RTE_KERNELDIR }}" #- name: make install DPDK into /usr for collectd and other programs -# my_make: +# make: # chdir: "{{ dpdk_path }}/{{ dpdk_make_arch}}" # target: install # params: "T={{ RTE_TARGET }}" diff --git a/ansible/roles/install_dpdk_shared/tasks/main.yml b/ansible/roles/install_dpdk_shared/tasks/main.yml index 6ed9f3bfc..65954be04 100644 --- a/ansible/roles/install_dpdk_shared/tasks/main.yml +++ b/ansible/roles/install_dpdk_shared/tasks/main.yml @@ -42,13 +42,9 @@ set_fact: RTE_KERNELDIR: "/lib/modules/{{ dpdk_kernel }}/build" -- my_make: +- command: make -j {{ ansible_processor_vcpus }} config T={{ dpdk_make_arch }} O={{ dpdk_make_arch }} + args: chdir: "{{ dpdk_shared_path }}" - target: config - params: - T: "{{ dpdk_make_arch }}" - O: "{{ dpdk_make_arch }}" - extra_args: "-j {{ ansible_processor_vcpus }}" environment: RTE_KERNELDIR: "{{ RTE_KERNELDIR }}" @@ -89,26 +85,23 @@ regexp: '^CONFIG_RTE_EAL_PMD_PATH=""' line: 'CONFIG_RTE_EAL_PMD_PATH="{{ dpdk_pmd_path }}"' -- my_make: + # no T= target for clean +- command: make -j {{ ansible_processor_vcpus }} clean O={{ dpdk_make_arch }} + args: chdir: "{{ dpdk_shared_path }}" - target: clean - params: - # no T= target for clean - O: "{{ dpdk_make_arch }}" - extra_args: "-j {{ ansible_processor_vcpus }}" environment: RTE_KERNELDIR: "{{ RTE_KERNELDIR }}" # TODO: disable ASLR -- my_make: +- command: make -j {{ ansible_processor_vcpus }} + args: chdir: "{{ dpdk_shared_path }}/{{ dpdk_make_arch}}" - extra_args: "-j {{ ansible_processor_vcpus }}" environment: RTE_KERNELDIR: "{{ RTE_KERNELDIR }}" #- name: make install DPDK into /usr for collectd and other programs -# my_make: +# make: # chdir: "{{ dpdk_shared_path }}/{{ dpdk_make_arch}}" # target: install # params: "T={{ RTE_TARGET }}" diff --git a/ansible/roles/install_intel_cmt_cat/tasks/main.yml b/ansible/roles/install_intel_cmt_cat/tasks/main.yml index fe3bf1464..609e98024 100644 --- a/ansible/roles/install_intel_cmt_cat/tasks/main.yml +++ b/ansible/roles/install_intel_cmt_cat/tasks/main.yml @@ -18,8 +18,8 @@ with_items: "{{ intel_cmt_cat_build_dependencies[ansible_os_family] }}" - name: "make intel-cmt-cat" - my_make: + make: chdir: "{{ intel_cmt_cat_path }}" target: install - params: "PREFIX=/usr" - + params: + PREFIX: "/usr" diff --git a/ansible/roles/install_samplevnf/tasks/main.yml b/ansible/roles/install_samplevnf/tasks/main.yml index b0ea91961..55c4da5e1 100644 --- a/ansible/roles/install_samplevnf/tasks/main.yml +++ b/ansible/roles/install_samplevnf/tasks/main.yml @@ -36,16 +36,15 @@ when: vnf_name == "PROX" and image_type is defined and image_type == "vm" - name: "make {{ vnf_name }} clean" - my_make: + command: make -j {{ ansible_processor_vcpus }} clean + args: chdir: "{{ vnf_build_dir }}" - target: clean - extra_args: "-j {{ ansible_processor_vcpus }}" environment: "{{ build_env_vars }}" - name: "make {{ vnf_name }}" - my_make: + command: make -j {{ ansible_processor_vcpus }} + args: chdir: "{{ vnf_build_dir }}" - extra_args: "-j {{ ansible_processor_vcpus }}" environment: "{{ build_env_vars }}" #- command: cp "{{ vnf_build_dir }}/{{ vnf_name }}/build/ip_pipeline" "{{ INSTALL_BIN_PATH }}/vACL_vnf" diff --git a/ansible/roles/install_yajl/tasks/main.yml b/ansible/roles/install_yajl/tasks/main.yml index a7eb7961e..20fd958c8 100644 --- a/ansible/roles/install_yajl/tasks/main.yml +++ b/ansible/roles/install_yajl/tasks/main.yml @@ -23,11 +23,10 @@ chdir: "{{ yajl_path }}" - name: "make yajl" - my_make: + make: chdir: "{{ yajl_path }}" - name: "make install yajl" - my_make: + make: chdir: "{{ yajl_path }}" target: install - diff --git a/api/resources/v2/containers.py b/api/resources/v2/containers.py index ee1903901..f71e607e7 100644 --- a/api/resources/v2/containers.py +++ b/api/resources/v2/containers.py @@ -259,13 +259,13 @@ class V2Containers(ApiResource): def _create_dashboard(self, ip): url = 'http://admin:admin@{}:{}/api/dashboards/db'.format(ip, 3000) - path = os.path.join(consts.REPOS_DIR, 'dashboard', '*dashboard.json') + path = os.path.join(consts.REPOS_DIR, 'dashboard', 'opnfv_yardstick_tc*.json') for i in sorted(glob.iglob(path)): with open(i) as f: data = jsonutils.load(f) try: - HttpClient().post(url, data) + HttpClient().post(url, {'dashboard': data}) except Exception: LOG.exception('Create dashboard %s failed', i) raise diff --git a/etc/yardstick/nodes/compass_sclab_physical/pod.yaml b/etc/yardstick/nodes/compass_sclab_physical/pod.yaml index 88501820e..218e00271 100644 --- a/etc/yardstick/nodes/compass_sclab_physical/pod.yaml +++ b/etc/yardstick/nodes/compass_sclab_physical/pod.yaml @@ -24,27 +24,49 @@ nodes: ip: 192.168.10.10 user: root password: root + ipmi_ip: 172.16.130.26 + ipmi_user: root + ipmi_pwd: Opnfv@pod1 - name: node2 role: Controller ip: 192.168.10.11 user: root password: root + ipmi_ip: 172.16.130.27 + ipmi_user: root + ipmi_pwd: Opnfv@pod1 - name: node3 role: Controller ip: 192.168.10.12 user: root password: root + ipmi_ip: 172.16.130.29 + ipmi_user: root + ipmi_pwd: Opnfv@pod1 - name: node4 role: Compute ip: 192.168.10.13 user: root password: root + ipmi_ip: 172.16.130.30 + ipmi_user: root + ipmi_pwd: Opnfv@pod1 - name: node5 role: Compute ip: 192.168.10.14 user: root password: root + ipmi_ip: 172.16.130.31 + ipmi_user: root + ipmi_pwd: Opnfv@pod1 +- + name: node0 + ip: 192.168.10.6 + role: Baremetal + user: root + password: root + diff --git a/gui/app/images/checkno.png b/gui/app/images/checkno.png Binary files differdeleted file mode 100644 index 7c6841930..000000000 --- a/gui/app/images/checkno.png +++ /dev/null diff --git a/gui/app/images/checkyes.png b/gui/app/images/checkyes.png Binary files differdeleted file mode 100644 index ef6028310..000000000 --- a/gui/app/images/checkyes.png +++ /dev/null diff --git a/gui/app/views/modal/environmentDialog.html b/gui/app/views/modal/environmentDialog.html index 4c539fc33..4c4906972 100644 --- a/gui/app/views/modal/environmentDialog.html +++ b/gui/app/views/modal/environmentDialog.html @@ -139,8 +139,8 @@ <th>status</th> </tr> <tr ng-repeat="(name, value) in yardstickImage"> - <td ng-if="selectImageList.indexOf(name) > -1"><img src="images/checkyes.png" style="height:12px;cursor:pointer" ng-click="unselectImage(name)" /></td> - <td ng-if="selectImageList.indexOf(name) == -1"><img src="images/checkno.png" style="height:12px;cursor:pointer" ng-click="selectImage(name)" /></td> + <td ng-if="selectImageList.indexOf(name) > -1"><span class="glyphicon glyphicon-check" aria-hidden="true" ng-click="unselectImage(name)"></span></td> + <td ng-if="selectImageList.indexOf(name) == -1"><span class="glyphicon glyphicon-unchecked" aria-hidden="true" ng-click="selectImage(name)"></span></td> <td>{{name}}</td> <td>{{value.description}}</td> <td>{{value.status}}</td> diff --git a/gui/app/views/modal/taskCreate.html b/gui/app/views/modal/taskCreate.html index e7812cf2b..2d7f1dc3b 100644 --- a/gui/app/views/modal/taskCreate.html +++ b/gui/app/views/modal/taskCreate.html @@ -18,8 +18,8 @@ <div style="display:flex;flex-direction:row;justify-content:space-between;padding:8px;border-top: 1px solid #e9ecec;" ng-class="{deepColor: $index%2==0}"> <div> {{env.name}}</div> <!--<button class="btn btn-default btn-sm" ng-click="gotoDetail('false',env.uuid)">detail</button>--> - <img src="images/checkyes.png" style="height:18px;cursor:pointer" ng-click="constructTestSuit(env.uuid,env.name)" ng-show="selectEnv==env.uuid" /> - <img src="images/checkno.png" style="height:18px;cursor:pointer" ng-click="constructTestSuit(env.uuid,env.name)" ng-show="selectEnv!=env.uuid" /> + <span class="glyphicon glyphicon-check" aria-hidden="true" ng-click="constructTestSuit(env.uuid,env.name)" ng-show="selectEnv==env.uuid"></span> + <span class="glyphicon glyphicon-unchecked" aria-hidden="true" ng-click="constructTestSuit(env.uuid,env.name)" ng-show="selectEnv!=env.uuid"></span> </div> <!--<hr style="margin-top:5px;margin-bottom:5px;" />--> @@ -52,8 +52,8 @@ <div style="display:flex;flex-direction:row;justify-content:space-between;padding:8px;border-top: 1px solid #e9ecec;" ng-class="{deepColor: $index%2==0}"> <div> {{test.Name}}</div> <div style="font-size:10px;">{{test.Description}}</div> - <img src="images/checkyes.png" style="height:18px;cursor:pointer" ng-click="constructTestCase(test.Name)" ng-show="selectCase==test.Name" /> - <img src="images/checkno.png" style="height:18px;cursor:pointer" ng-click="constructTestCase(test.Name)" ng-show="selectCase!=test.Name" /> + <span class="glyphicon glyphicon-check" aria-hidden="true" ng-click="constructTestCase(test.Name)" ng-show="selectCase==test.Name"></span> + <span class="glyphicon glyphicon-unchecked" aria-hidden="true" ng-click="constructTestCase(test.Name)" ng-show="selectCase!=test.Name"></span> </div> <!--<hr style="margin-top:5px;margin-bottom:5px;" />--> @@ -68,8 +68,8 @@ <div style="display:flex;flex-direction:row;justify-content:space-between;padding:8px;border-top: 1px solid #e9ecec;" ng-class="{deepColor: $index%2==0}"> <div> {{suite}}</div> - <img src="images/checkyes.png" style="height:18px;cursor:pointer" ng-click="constructTestCase(suite)" ng-show="selectCase==suite" /> - <img src="images/checkno.png" style="height:18px;cursor:pointer" ng-click="constructTestCase(suite)" ng-show="selectCase!=suite" /> + <span class="glyphicon glyphicon-check" aria-hidden="true" ng-click="constructTestCase(suite)" ng-show="selectCase==suite"></span> + <span class="glyphicon glyphicon-unchecked" aria-hidden="true" ng-click="constructTestCase(suite)" ng-show="selectCase!=suite"></span> </div> <!--<hr style="margin-top:5px;margin-bottom:5px;" />--> diff --git a/gui/app/views/taskmodify.html b/gui/app/views/taskmodify.html index a4593f745..d12df4ba2 100644 --- a/gui/app/views/taskmodify.html +++ b/gui/app/views/taskmodify.html @@ -22,8 +22,8 @@ <div style="display:flex;flex-direction:row;justify-content:space-between;padding:8px;border-top: 1px solid #e9ecec;" ng-class="{deepColor: $index%2==0}"> <div> {{env.name}}</div> <!--<button class="btn btn-default btn-sm" ng-click="gotoDetail('false',env.uuid)">detail</button>--> - <img src="images/checkyes.png" style="height:18px;cursor:pointer" ng-click="constructTestSuit(env.uuid,env.name)" ng-show="selectEnv==env.uuid" /> - <img src="images/checkno.png" style="height:18px;cursor:pointer" ng-click="constructTestSuit(env.uuid,env.name)" ng-show="selectEnv!=env.uuid" /> + <span class="glyphicon glyphicon-check" aria-hidden="true" ng-click="constructTestSuit(env.uuid,env.name)" ng-show="selectEnv==env.uuid"></span> + <span class="glyphicon glyphicon-unchecked" aria-hidden="true" ng-click="constructTestSuit(env.uuid,env.name)" ng-show="selectEnv!=env.uuid"></span> </div> <!--<hr style="margin-top:5px;margin-bottom:5px;" />--> @@ -72,8 +72,8 @@ <div style="display:flex;flex-direction:row;justify-content:space-between;padding:8px;border-top: 1px solid #e9ecec;" ng-class="{deepColor: $index%2==0}"> <div> {{test.Name}}</div> <div style="font-size:10px;">{{test.Description}}</div> - <img src="images/checkyes.png" style="height:18px;cursor:pointer" ng-click="constructTestCase(test.Name)" ng-show="selectCase==test.Name" /> - <img src="images/checkno.png" style="height:18px;cursor:pointer" ng-click="constructTestCase(test.Name)" ng-show="selectCase!=test.Name" /> + <span class="glyphicon glyphicon-check" aria-hidden="true" ng-click="constructTestCase(test.Name)" ng-show="selectCase==test.Name"></span> + <span class="glyphicon glyphicon-unchecked" aria-hidden="true" ng-click="constructTestCase(test.Name)" ng-show="selectCase!=test.Name"></span> </div> <!--<hr style="margin-top:5px;margin-bottom:5px;" />--> @@ -88,8 +88,8 @@ <div style="display:flex;flex-direction:row;justify-content:space-between;padding:8px;border-top: 1px solid #e9ecec;" ng-class="{deepColor: $index%2==0}"> <div> {{suite}}</div> - <img src="images/checkyes.png" style="height:18px;cursor:pointer" ng-click="constructTestCase(suite)" ng-show="selectCase==suite" /> - <img src="images/checkno.png" style="height:18px;cursor:pointer" ng-click="constructTestCase(suite)" ng-show="selectCase!=suite" /> + <span class="glyphicon glyphicon-check" aria-hidden="true" ng-click="constructTestCase(suite)" ng-show="selectCase==suite"></span> + <span class="glyphicon glyphicon-unchecked" aria-hidden="true" ng-click="constructTestCase(suite)" ng-show="selectCase!=suite"></span> </div> <!--<hr style="margin-top:5px;margin-bottom:5px;" />--> diff --git a/gui/app/views/testcasechoose.html b/gui/app/views/testcasechoose.html index 12bdb834f..12fb28c90 100644 --- a/gui/app/views/testcasechoose.html +++ b/gui/app/views/testcasechoose.html @@ -17,8 +17,8 @@ </div>--> <div dir-paginate="test in testcaselist.testcases | itemsPerPage: 10"> <div style="display:flex;flex-direction:row;"> - <img src="images/checkyes.png" style="height:12px;cursor:pointer" ng-click="constructTestSuit(test.Name)" ng-show="testsuiteList.indexOf(test.Name)>-1" /> - <img src="images/checkno.png" style="height:12px;cursor:pointer" ng-click="constructTestSuit(test.Name)" ng-show="testsuiteList.indexOf(test.Name)==-1" /> + <span class="glyphicon glyphicon-check" aria-hidden="true" ng-click="constructTestSuit(test.Name)" ng-show="testsuiteList.indexOf(test.Name)>-1"></span> + <span class="glyphicon glyphicon-unchecked" aria-hidden="true" ng-click="constructTestSuit(test.Name)" ng-show="testsuiteList.indexOf(test.Name)==-1"></span> <div style="margin-left:50px;"> {{test.Name}}</div> <div style="font-size:10px;margin-left:100px">{{test.Description}}</div> diff --git a/samples/vnf_samples/nsut/acl/ixia_traffic.cfg b/samples/vnf_samples/nsut/acl/ixia_traffic.cfg deleted file mode 100644 index 3f7e33471..000000000 --- a/samples/vnf_samples/nsut/acl/ixia_traffic.cfg +++ /dev/null @@ -1,51 +0,0 @@ -{ - "uplink_0": { - "id": 1, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:03", - "framesPerSecond": true, - "framesize": 64, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "2001", - "srcport": "1234" - }, - "traffic_type": "continuous" - }, - "downlink_0": { - "id": 2, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:04", - "framesPerSecond": true, - "framesize": 64, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "1234", - "srcport": "2001" - }, - "traffic_type": "continuous" - } -} diff --git a/samples/vnf_samples/nsut/cgnapt/ixia_traffic.cfg b/samples/vnf_samples/nsut/cgnapt/ixia_traffic.cfg deleted file mode 100644 index 3f7e33471..000000000 --- a/samples/vnf_samples/nsut/cgnapt/ixia_traffic.cfg +++ /dev/null @@ -1,51 +0,0 @@ -{ - "uplink_0": { - "id": 1, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:03", - "framesPerSecond": true, - "framesize": 64, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "2001", - "srcport": "1234" - }, - "traffic_type": "continuous" - }, - "downlink_0": { - "id": 2, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:04", - "framesPerSecond": true, - "framesize": 64, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "1234", - "srcport": "2001" - }, - "traffic_type": "continuous" - } -} diff --git a/samples/vnf_samples/nsut/cgnapt/tc_baremetal_rfc2544_ipv4_1flow_64B_ixia.yaml b/samples/vnf_samples/nsut/cgnapt/tc_baremetal_rfc2544_ipv4_1flow_64B_ixia.yaml index 7d6203c0c..0f1ddd606 100644 --- a/samples/vnf_samples/nsut/cgnapt/tc_baremetal_rfc2544_ipv4_1flow_64B_ixia.yaml +++ b/samples/vnf_samples/nsut/cgnapt/tc_baremetal_rfc2544_ipv4_1flow_64B_ixia.yaml @@ -28,7 +28,7 @@ scenarios: flow: src_ip: [{'tg__0': 'xe0'}] dst_ip: [{'tg__0': 'xe1'}] - publicip: ["152.16.40.10"] + public_ip: ["152.16.40.10"] count: 1 traffic_type: 4 rfc2544: @@ -44,4 +44,4 @@ context: type: Node name: yardstick nfvi_type: baremetal - file: /etc/yardstick/nodes/pod.yaml + file: /etc/yardstick/nodes/pod_ixia.yaml diff --git a/samples/vnf_samples/nsut/prox/tc_prox_heat_context_l2fwd-2-l3fwd-2.yaml b/samples/vnf_samples/nsut/prox/tc_prox_heat_context_l2fwd-2-l3fwd-2.yaml index 5af410215..4964f6fe9 100644 --- a/samples/vnf_samples/nsut/prox/tc_prox_heat_context_l2fwd-2-l3fwd-2.yaml +++ b/samples/vnf_samples/nsut/prox/tc_prox_heat_context_l2fwd-2-l3fwd-2.yaml @@ -105,12 +105,12 @@ context: mgmt: cidr: '10.0.1.0/24' uplink_0: - cidr: '10.1.1.0/24' + cidr: '10.0.2.0/24' gateway_ip: 'null' port_security_enabled: False enable_dhcp: 'false' downlink_0: - cidr: '10.1.1.0/24' + cidr: '10.0.3.0/24' gateway_ip: 'null' port_security_enabled: False enable_dhcp: 'false' diff --git a/samples/vnf_samples/nsut/prox/tc_prox_heat_context_l2fwd-2.yaml b/samples/vnf_samples/nsut/prox/tc_prox_heat_context_l2fwd-2.yaml index 6bbec4842..5213277aa 100644 --- a/samples/vnf_samples/nsut/prox/tc_prox_heat_context_l2fwd-2.yaml +++ b/samples/vnf_samples/nsut/prox/tc_prox_heat_context_l2fwd-2.yaml @@ -72,12 +72,12 @@ context: mgmt: cidr: '10.0.1.0/24' uplink_0: - cidr: '10.1.1.0/24' + cidr: '10.0.2.0/24' gateway_ip: 'null' port_security_enabled: False enable_dhcp: 'false' downlink_0: - cidr: '10.1.1.0/24' + cidr: '10.0.3.0/24' gateway_ip: 'null' port_security_enabled: False enable_dhcp: 'false' diff --git a/samples/vnf_samples/nsut/vfw/ixia_traffic.cfg b/samples/vnf_samples/nsut/vfw/ixia_traffic.cfg deleted file mode 100644 index 3f7e33471..000000000 --- a/samples/vnf_samples/nsut/vfw/ixia_traffic.cfg +++ /dev/null @@ -1,51 +0,0 @@ -{ - "uplink_0": { - "id": 1, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:03", - "framesPerSecond": true, - "framesize": 64, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "2001", - "srcport": "1234" - }, - "traffic_type": "continuous" - }, - "downlink_0": { - "id": 2, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:04", - "framesPerSecond": true, - "framesize": 64, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "1234", - "srcport": "2001" - }, - "traffic_type": "continuous" - } -} diff --git a/samples/vnf_samples/nsut/vpe/ixia_traffic.cfg b/samples/vnf_samples/nsut/vpe/ixia_traffic.cfg deleted file mode 100644 index a0cf372cf..000000000 --- a/samples/vnf_samples/nsut/vpe/ixia_traffic.cfg +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright (c) 2016-2017 Intel Corporation -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -{ - "uplink_0": { - "id": 1, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:03", - "framesPerSecond": true, - "framesize": 64, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "dscp": 0, - "dstip4": "152.16.40.20", - "proto": "udp", - "srcip4": "152.16.100.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "2001", - "srcport": "1234" - }, - "traffic_type": "continuous" - }, - "downlink_0": { - "id": 2, - "bidir": "False", - "duration": 60, - "iload": "100", - "outer_l2": { - "dstmac": "00:00:00:00:00:04", - "framesPerSecond": true, - "framesize": 64, - "srcmac": "00:00:00:00:00:01" - }, - "outer_l3": { - "count": 1024, - "dscp": 0, - "dstip4": "152.16.100.20", - "proto": "udp", - "srcip4": "152.16.40.20", - "ttl": 32 - }, - "outer_l4": { - "dstport": "1234", - "srcport": "2001" - }, - "traffic_type": "continuous" - } -} diff --git a/samples/vnf_samples/traffic_profiles/ixia_ipv4_latency.yaml b/samples/vnf_samples/traffic_profiles/ixia_ipv4_latency.yaml index a475173f2..6ba1553ad 100644 --- a/samples/vnf_samples/traffic_profiles/ixia_ipv4_latency.yaml +++ b/samples/vnf_samples/traffic_profiles/ixia_ipv4_latency.yaml @@ -33,6 +33,7 @@ traffic_profile: uplink_0: ipv4: + id: 1 outer_l2: framesize: 64B: "{{get(imix, 'imix.uplink.64B', '0') }}" @@ -58,6 +59,7 @@ uplink_0: count: "{{get(flow, 'flow.count', '1') }}" downlink_0: ipv4: + id: 2 outer_l2: framesize: 64B: "{{get(imix, 'imix.downlink.64B', '0') }}" @@ -74,6 +76,9 @@ downlink_0: proto: "udp" srcip4: "{{get(flow, 'flow.dst_ip_0', '1.1.1.1-1.15.255.255') }}" dstip4: "{{get(flow, 'flow.src_ip_0', '90.90.1.1-90.105.255.255') }}" + {% if flow.flow.public_ip_0 is defined %} + dstip4: "{{get(flow, 'flow.public_ip_0', '90.90.1.1-90.105.255.255') }}" + {% endif %} count: "{{get(flow, 'flow.count', '1') }}" ttl: 32 dscp: 0 @@ -83,6 +88,7 @@ downlink_0: count: "{{get(flow, 'flow.count', '1') }}" uplink_1: ipv4: + id: 3 outer_l2: framesize: 64B: "{{get(imix, 'imix.uplink.64B', '0') }}" @@ -97,17 +103,18 @@ uplink_1: outer_l3v4: proto: "udp" - srcip4: "{{get(flow, 'flow.src_ip1', '1.1.1.1-1.15.255.255') }}" - dstip4: "{{get(flow, 'flow.dst_ip1', '90.90.1.1-90.105.255.255') }}" + srcip4: "{{get(flow, 'flow.src_ip_1', '1.1.1.1-1.15.255.255') }}" + dstip4: "{{get(flow, 'flow.dst_ip_1', '90.90.1.1-90.105.255.255') }}" count: "{{get(flow, 'flow.count', '1') }}" ttl: 32 dscp: 0 outer_l4: - srcport: "{{get(flow, 'flow.src_port1', '1234') }}" - dstport: "{{get(flow, 'flow.dst_port1', '2001') }}" + srcport: "{{get(flow, 'flow.src_port_1', '1234') }}" + dstport: "{{get(flow, 'flow.dst_port_1', '2001') }}" count: "{{get(flow, 'flow.count', '1') }}" downlink_1: ipv4: + id: 4 outer_l2: framesize: 64B: "{{get(imix, 'imix.downlink.64B', '0') }}" @@ -124,10 +131,13 @@ downlink_1: proto: "udp" srcip4: "{{get(flow, 'flow.dst_ip_1', '1.1.1.1-1.15.255.255') }}" dstip4: "{{get(flow, 'flow.src_ip_1', '90.90.1.1-90.105.255.255') }}" + {% if flow.public_ip_1 is defined %} + dstip4: "{{get(flow, 'flow.public_ip_1', '90.90.1.1-90.105.255.255') }}" + {% endif %} count: "{{get(flow, 'flow.count', '1') }}" ttl: 32 dscp: 0 outer_l4: - srcport: "{{get(flow, 'flow.dst_port1', '1234') }}" - dstport: "{{get(flow, 'flow.src_port1', '2001') }}" + srcport: "{{get(flow, 'flow.dst_port_1', '1234') }}" + dstport: "{{get(flow, 'flow.src_port_1', '2001') }}" count: "{{get(flow, 'flow.count', '1') }}" diff --git a/samples/vnf_samples/traffic_profiles/ixia_ipv4_latency_vpe.yaml b/samples/vnf_samples/traffic_profiles/ixia_ipv4_latency_vpe.yaml index 5cce5941e..4d73b8ffe 100644 --- a/samples/vnf_samples/traffic_profiles/ixia_ipv4_latency_vpe.yaml +++ b/samples/vnf_samples/traffic_profiles/ixia_ipv4_latency_vpe.yaml @@ -46,6 +46,7 @@ traffic_profile: uplink_0: ipv4: + id: 1 outer_l2: framesize: 64B: "{{ get(imix, 'imix.uplink.imix_small', '0') }}" @@ -79,6 +80,7 @@ uplink_0: dstport: "{{get(flow, 'flow.dst_port_0', '0') }}" count: "{{get(flow, 'flow.count', '1') }}" downlink_0: + id: 2 ipv4: outer_l2: framesize: @@ -103,6 +105,7 @@ downlink_0: dstport: "{{get(flow, 'flow.src_port_0', '0') }}" count: "{{get(flow, 'flow.count', '1') }}" uplink_1: + id: 3 ipv4: outer_l2: framesize: @@ -126,16 +129,17 @@ uplink_1: outer_l3v4: proto: "tcp" - srcip4: "{{get(flow, 'flow.srcip1', '192.168.0.0-192.168.255.255') }}" - dstip4: "{{get(flow, 'flow.dstip1', '192.16.0.0-192.16.0.31') }}" + srcip4: "{{get(flow, 'flow.srcip_1', '192.168.0.0-192.168.255.255') }}" + dstip4: "{{get(flow, 'flow.dstip_1', '192.16.0.0-192.16.0.31') }}" ttl: 32 dscp: 32 outer_l4: - srcport: "{{get(flow, 'flow.src_port1', '0') }}" - dstport: "{{get(flow, 'flow.dst_port1', '0') }}" + srcport: "{{get(flow, 'flow.src_port_1', '0') }}" + dstport: "{{get(flow, 'flow.dst_port_1', '0') }}" count: "{{get(flow, 'flow.count', '1') }}" downlink_1: + id: 4 ipv4: outer_l2: framesize: @@ -149,13 +153,13 @@ downlink_1: outer_l3v4: proto: "tcp" - srcip4: "{{get(flow, 'flow.dst_ip1', '192.16.0.0-192.16.0.31') }}" - dstip4: "{{get(flow, 'flow.src_ip1', '192.168.0.0-192.168.255.255') }}" + srcip4: "{{get(flow, 'flow.dst_ip_1', '192.16.0.0-192.16.0.31') }}" + dstip4: "{{get(flow, 'flow.src_ip_1', '192.168.0.0-192.168.255.255') }}" count: "{{get(flow, 'flow.count', '1') }}" ttl: 32 dscp: 32 outer_l4: - srcport: "{{get(flow, 'flow.dst_port1', '0') }}" - dstport: "{{get(flow, 'flow.src_port1', '0') }}" + srcport: "{{get(flow, 'flow.dst_port_1', '0') }}" + dstport: "{{get(flow, 'flow.src_port_1', '0') }}" count: "{{get(flow, 'flow.count', '1') }}" diff --git a/tests/ci/load_images.sh b/tests/ci/load_images.sh index c2ae4fe7b..89ebb2dde 100755 --- a/tests/ci/load_images.sh +++ b/tests/ci/load_images.sh @@ -13,17 +13,20 @@ set -e YARD_IMG_ARCH=amd64 -export YARD_IMG_ARCH if ! grep -q "Defaults env_keep += \"YARD_IMG_ARCH\"" "/etc/sudoers"; then echo "Defaults env_keep += \"YARD_IMG_ARCH YARDSTICK_REPO_DIR\"" | sudo tee -a /etc/sudoers fi # Look for a compute node, that is online, and check if it is aarch64 -ARCH_SCRIPT="ssh \$(fuel2 node list | awk -F'|' '\$6 ~ /compute/ && \$11 ~ /rue/ {print \$7; exit;}') uname -m 2>/dev/null | grep -q aarch64" -if [ "$INSTALLER_TYPE" == "fuel" ]; then - sshpass -p r00tme ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -l root "${INSTALLER_IP}" "${ARCH_SCRIPT}" && YARD_IMG_ARCH=arm64 +if [ "${INSTALLER_TYPE}" == 'fuel' ]; then + COMPUTE_ARCH=$(ssh -l ubuntu ${INSTALLER_IP} -i ${SSH_KEY} ${ssh_options} \ + "sudo salt 'cmp*' grains.get cpuarch --out yaml | awk '{print \$2; exit}'") + if [ "${COMPUTE_ARCH}" == 'aarch64' ]; then + YARD_IMG_ARCH=arm64 + fi fi +export YARD_IMG_ARCH HW_FW_TYPE="" if [ "${YARD_IMG_ARCH}" == "arm64" ]; then diff --git a/tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml b/tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml index 417327cb6..5eb34e56a 100644 --- a/tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml +++ b/tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml @@ -13,15 +13,12 @@ description: > Test case for TC054 :OpenStack VIP Master Node abnormally shutdown High Availability; This test case is written by new scenario-based HA testing framework. -{% set attack_host = attack_host or 'node1' %} -{% set check_host = check_host or 'node2' %} {% set jump_host = jump_host or 'node0' %} +{% set attack_host = attack_host or 'node1' %} +{% set check_host = check_host or 'node4' %} {% set file = file or '/etc/yardstick/pod.yaml' %} -{% set vip_management = vip_management or '192.168.0.2' %} -{% set vip_public = vip_public or '172.16.0.3' %} -{% set vip_router_management = vip_router_management or '192.168.0.1' %} -{% set vip_router_public = vip_router_public or '172.16.0.2' %} -{% set monitor_time = monitor_time or 180 %} +{% set vip_public = vip_public or '10.1.0.222' %} +{% set monitor_time = monitor_time or 30 %} scenarios: - @@ -47,42 +44,6 @@ scenarios: - monitor_type: "general-monitor" monitor_key: "ip-status" - key: "vip-mgmt-status" - host: {{check_host}} - monitor_time: {{monitor_time}} - monitor_number: 3 - sla: - max_outage_time: 5 - parameter: - ip_address: {{vip_management}} - - - - monitor_type: "general-monitor" - monitor_key: "ip-status" - key: "vip-routerp-status" - host: {{check_host}} - monitor_time: {{monitor_time}} - monitor_number: 3 - sla: - max_outage_time: 5 - parameter: - ip_address: {{vip_router_public}} - - - - monitor_type: "general-monitor" - monitor_key: "ip-status" - key: "vip-router-status" - host: {{check_host}} - monitor_time: {{monitor_time}} - monitor_number: 3 - sla: - max_outage_time: 5 - parameter: - ip_address: {{vip_router_management}} - - - - monitor_type: "general-monitor" - monitor_key: "ip-status" key: "vip-pub" host: {{check_host}} monitor_time: {{monitor_time}} @@ -102,26 +63,10 @@ scenarios: actionKey: "list-images" actionType: "monitor" index: 2 - - - - actionKey: "vip-mgmt-status" - actionType: "monitor" - index: 3 - - - - actionKey: "vip-routerp-status" - actionType: "monitor" - index: 4 - - - - actionKey: "vip-router-status" - actionType: "monitor" - index: 5 - - actionKey: "vip-pub" actionType: "monitor" - index: 6 + index: 3 nodes: {{jump_host}}: {{jump_host}}.LF diff --git a/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py b/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py index 6fffb9ede..616921e33 100644 --- a/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py +++ b/tests/unit/network_services/traffic_profile/test_ixia_rfc2544.py @@ -179,12 +179,12 @@ class TestIXIARFC2544Profile(unittest.TestCase): "dst_mac_0": "00:00:00:00:00:03", "dst_mac_1": "00:00:00:00:00:04", "dst_mac_2": "00:00:00:00:00:04"} - self.assertRaises(IOError, r_f_c2544_profile._get_ixia_traffic_profile, - self.PROFILE, mac, xfile="tmp", - static_traffic=STATIC_TRAFFIC) + result = r_f_c2544_profile._get_ixia_traffic_profile( + self.PROFILE, mac, xfile="tmp", + static_traffic=STATIC_TRAFFIC) + self.assertIsNotNone(result) - @mock.patch("yardstick.network_services.traffic_profile.ixia_rfc2544.open") - def test_get_ixia_traffic_profile(self, mock_open): + def test_get_ixia_traffic_profile(self): traffic_generator = mock.Mock(autospec=TrexProfile) traffic_generator.my_ports = [0, 1] traffic_generator.uplink_ports = [-1] diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py index 355b69862..3f61116bc 100644 --- a/yardstick/benchmark/scenarios/networking/vnf_generic.py +++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py @@ -546,7 +546,11 @@ printf "%s/driver:" $1 ; basename $(readlink -s $1/device/driver); } \ # we assume OrderedDict for consistenct in instantiation for node_name, node in context_cfg["nodes"].items(): LOG.debug(node) - file_name = node["VNF model"] + try: + file_name = node["VNF model"] + except KeyError: + LOG.debug("no model for %s, skipping", node_name) + continue file_path = scenario_cfg['task_path'] with open_relative_file(file_name, file_path) as stream: vnf_model = stream.read() diff --git a/yardstick/network_services/libs/ixia_libs/IxNet/IxNet.py b/yardstick/network_services/libs/ixia_libs/IxNet/IxNet.py index 358e6e761..70ce4ff03 100644 --- a/yardstick/network_services/libs/ixia_libs/IxNet/IxNet.py +++ b/yardstick/network_services/libs/ixia_libs/IxNet/IxNet.py @@ -254,8 +254,10 @@ class IxNextgen(object): helper = TrafficStreamHelper(traffic_item, stream, param_id) self.ixnet.setMultiAttribute(helper.transmissionControl, - '-type', '{0}'.format(param['traffic_type']), - '-duration', '{0}'.format(param['duration'])) + '-type', '{0}'.format(param.get('traffic_type', + 'continuous')), + '-duration', '{0}'.format(param.get('duration', + "30"))) stream_frame_rate_path = helper.frameRate self.ixnet.setMultiAttribute(stream_frame_rate_path, '-rate', param['iload']) diff --git a/yardstick/network_services/traffic_profile/ixia_rfc2544.py b/yardstick/network_services/traffic_profile/ixia_rfc2544.py index 28480b8e9..53a99bf0b 100644 --- a/yardstick/network_services/traffic_profile/ixia_rfc2544.py +++ b/yardstick/network_services/traffic_profile/ixia_rfc2544.py @@ -14,7 +14,6 @@ from __future__ import absolute_import import logging -import json from yardstick.network_services.traffic_profile.traffic_profile import \ TrexProfile @@ -24,60 +23,60 @@ LOG = logging.getLogger(__name__) class IXIARFC2544Profile(TrexProfile): + UPLINK = 'uplink' + DOWNLINK = 'downlink' + def _get_ixia_traffic_profile(self, profile_data, mac=None, xfile=None, static_traffic=None): if mac is None: mac = {} - if static_traffic is None: - static_traffic = {} - result = {} - if xfile: - with open(xfile) as stream: - try: - static_traffic = json.load(stream) - except Exception as exc: - LOG.debug(exc) - - for traffickey, trafficvalue in static_traffic.items(): - traffic = static_traffic[traffickey] - # outer_l2 - index = 0 + for traffickey, values in profile_data.items(): + if not traffickey.startswith((self.UPLINK, self.DOWNLINK)): + continue + try: - for key, value in profile_data[traffickey].items(): - framesize = value['outer_l2']['framesize'] - traffic['outer_l2']['framesize'] = framesize - traffic['framesPerSecond'] = True - traffic['bidir'] = False - traffic['outer_l2']['srcmac'] = \ - mac["src_mac_{}".format(traffic['id'])] - traffic['outer_l2']['dstmac'] = \ - mac["dst_mac_{}".format(traffic['id'])] - - # outer_l3 - if "outer_l3v6" in list(value.keys()): - traffic['outer_l3'] = value['outer_l3v6'] - srcip4 = value['outer_l3v6']['srcip6'] - traffic['outer_l3']['srcip4'] = srcip4.split("-")[0] - dstip4 = value['outer_l3v6']['dstip6'] - traffic['outer_l3']['dstip4'] = dstip4.split("-")[0] - else: - traffic['outer_l3'] = value['outer_l3v4'] - srcip4 = value['outer_l3v4']['srcip4'] - traffic['outer_l3']['srcip4'] = srcip4.split("-")[0] - dstip4 = value['outer_l3v4']['dstip4'] - traffic['outer_l3']['dstip4'] = dstip4.split("-")[0] - - traffic['outer_l3']['type'] = key - traffic['outer_l3']['count'] = value['outer_l3v4']['count'] - # outer_l4 - traffic['outer_l4'] = value['outer_l4'] - index = index + 1 + # values should be single-item dict, so just grab the first item + try: + key, value = next(iter(values.items())) + except StopIteration: + result[traffickey] = {} + continue + + port_id = value.get('id', 1) + port_index = port_id - 1 + try: + ip = value['outer_l3v6'] + except KeyError: + ip = value['outer_l3v4'] + src_key, dst_key = 'srcip4', 'dstip4' + else: + src_key, dst_key = 'srcip6', 'dstip6' + + result[traffickey] = { + 'bidir': False, + 'iload': '100', + 'id': port_id, + 'outer_l2': { + 'framesize': value['outer_l2']['framesize'], + 'framesPerSecond': True, + 'srcmac': mac['src_mac_{}'.format(port_index)], + 'dstmac': mac['dst_mac_{}'.format(port_index)], + }, + 'outer_l3': { + 'count': ip['count'], + 'dscp': ip['dscp'], + 'ttl': ip['ttl'], + src_key: ip[src_key], + dst_key: ip[dst_key], + 'type': key, + 'proto': ip['proto'], + }, + 'outer_l4': value['outer_l4'], + } except Exception: continue - result.update({traffickey: traffic}) - return result def _ixia_traffic_generate(self, traffic_generator, traffic, ixia_obj): diff --git a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py index 22aaf6dfb..47c5a35d9 100644 --- a/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py +++ b/yardstick/network_services/vnf_generic/vnf/tg_rfc2544_ixia.py @@ -14,7 +14,6 @@ from __future__ import absolute_import -import json import time import os import logging @@ -130,39 +129,28 @@ class IxiaResourceHelper(ClientResourceHelper): self.client.ix_assign_ports() - ixia_file = find_relative_file("ixia_traffic.cfg", - self.scenario_helper.scenario_cfg["task_path"]) - - static_traffic = {} - with open(ixia_file) as stream: - try: - static_traffic = json.load(stream) - except Exception: - LOG.exception("") mac = {} - for vld_id, traffic in static_traffic.items(): - intfs = self.vnfd_helper.port_pairs.networks.get(vld_id, []) - interface = next(iter(intfs), None) - if interface: - virt_intf = self.vnfd_helper.find_interface(name=interface)["virtual-interface"] - # we only know static traffic id by reading the json - # this is used by _get_ixia_traffic_profile - mac["src_mac_{}".format(traffic["id"])] = virt_intf.get("local_mac", default) - mac["dst_mac_{}".format(traffic["id"])] = virt_intf.get("dst_mac", default) + for port_name in self.vnfd_helper.port_pairs.all_ports: + intf = self.vnfd_helper.find_interface(name=port_name) + virt_intf = intf["virtual-interface"] + # we only know static traffic id by reading the json + # this is used by _get_ixia_trafficrofile + port_num = self.vnfd_helper.port_num(intf) + mac["src_mac_{}".format(port_num)] = virt_intf.get("local_mac", default) + mac["dst_mac_{}".format(port_num)] = virt_intf.get("dst_mac", default) samples = {} # Generate ixia traffic config... try: while not self._terminated.value: - traffic_profile.execute_traffic(self, self.client, mac, ixia_file) + traffic_profile.execute_traffic(self, self.client, mac) self.client_started.value = 1 time.sleep(WAIT_FOR_TRAFFIC) self.client.ix_stop_traffic() samples = self.generate_samples(traffic_profile.ports) self._queue.put(samples) status, samples = traffic_profile.get_drop_percentage(self, samples, min_tol, - max_tol, self.client, mac, - ixia_file) + max_tol, self.client, mac) current = samples['CurrentDropPercentage'] if min_tol <= current <= max_tol or status == 'Completed': @@ -175,13 +163,13 @@ class IxiaResourceHelper(ClientResourceHelper): self._terminated.value = 1 return - traffic_profile.execute_traffic(self, self.client, mac, ixia_file) + traffic_profile.execute_traffic(self, self.client, mac) for _ in range(5): time.sleep(self.LATENCY_TIME_SLEEP) self.client.ix_stop_traffic() samples = self.generate_samples(traffic_profile.ports, 'latency', {}) self._queue.put(samples) - traffic_profile.start_ixia_latency(self, self.client, mac, ixia_file) + traffic_profile.start_ixia_latency(self, self.client, mac) if self._terminated.value: break |