Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve(slb): Fix the error of passing parameters and add testcase #199

Merged
merged 1 commit into from
Nov 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ansible/modules/cloud/alicloud/ali_slb_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def add_set_backend_servers(module, slb, load_balancer_id, backend_servers):

try:

load_balancer_info = slb.describe_load_balancer_attribute(load_balancer_id)
load_balancer_info = slb.describe_load_balancer_attribute(load_balancer_id=load_balancer_id)

# Verifying if server load balancer Object is present
if load_balancer_info:
Expand Down
75 changes: 75 additions & 0 deletions tests/ali_slb_server_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
- name: Validate module ali_slb_server
hosts: localhost
remote_user: root

vars:
name: ansible-testacc-ali_slb_lb

roles:
- vpc
- vswitch
- slb
- security_group
- instance

tasks:
- name: Add backend servers
ali_slb_server:
lb_id: '{{ slbpri.load_balancer.id }}'
backend_servers:
- server_id: '{{instances.ids.0}}'
weight: 100
- server_id: '{{instances.ids.1}}'
weight: 90

- name: Filter slb using name_regex
ali_slb_lb_info:
name_prefix: '{{name}}'
register: slbs

- name: Remove backend servers
ali_slb_server:
lb_id: '{{ slbpri.load_balancer.id }}'
state: absent
backend_servers:
- server_id: '{{instances.ids.0}}'
weight: 100

- name: Filter slb using name_regex
ali_slb_lb_info:
name_prefix: '{{name}}'
register: slbs

- name: Changed. Delete ecs instances
ali_instance:
instance_ids: '{{ instances.ids }}'
force: True
state: absent

- name: Changed. Delete slb instance when C(absent)
ali_slb_lb:
name: '{{ item.name }}'
state: absent
with_items: '{{slbs.load_balancers}}'

- name: Changed. Deleting security groups
ali_security_group:
name: '{{ item.group_name }}'
vpc_id: '{{item.vpc_id}}'
state: absent
with_items: '{{sgs.groups}}'

- name: Changed. Deleting vswitches
ali_vswitch:
vpc_id: '{{ item.vpc_id}}'
cidr_block: '{{ item.cidr_block}}'
state: absent
with_items: '{{vswitches.vswitches}}'

- name: Changed. Deleting vpcs
ali_vpc:
name: '{{item.vpc_name}}'
cidr_block: '{{item.cidr_block}}'
state: absent
with_items: '{{vpcs.vpcs}}'