Skip to content

Commit

Permalink
Merge pull request #136 from b-abadie/bugfix/diff_ratio
Browse files Browse the repository at this point in the history
cv_configlet : fix bugs where some configlet with small changes were not updated
  • Loading branch information
titom73 authored Feb 11, 2020
2 parents b87dab2 + 7806dc9 commit 0c63d3e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ $ cd ansible-cvp
__Build and install collection__

```shell
$ ansible-galaxy collection build --force ansible_collection/arista/cvp
$ ansible-galaxy collection build --force ansible_collections/arista/cvp
$ ansible-galaxy collection install arista-cvp-<VERSION>.tar.gz
```

Expand Down Expand Up @@ -119,7 +119,7 @@ $ make build-docker
$ make run-docker
```

Image will be created using current branc as tag. If it is run in master branch, then latest git tag will be used as docker tag.
Image will be created using current branch as tag. If it is run in master branch, then latest git tag will be used as docker tag.


> Docker images can be reduced by using `--squash` option available with experimental features enabled on your docker host.
Expand All @@ -133,7 +133,7 @@ This example outlines how to use `arista.cvp` to create a containers topology on

A [complete end to end demo](https://github.com/titom73/ansible-avd-cloudvision-demo) using [Arista Validated Design collection](https://github.com/aristanetworks/ansible-avd) and CloudVision modules is available as an example. You can also find some playbook examples under [__`examples`__](examples/) folder with information about how to built a test environment.

Below is a very basic example to build a container tology on a CloudVision platform assuming you have 3 veos named `veos0{1,3}` and a configlet named `alias`
Below is a very basic example to build a container topology on a CloudVision platform assuming you have 3 veos named `veos0{1,3}` and a configlet named `alias`

```yaml
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def compare(fromText, toText, fromName='', toName='', lines=10):
tolines = toText.splitlines(1)
diff = list(difflib.unified_diff(fromlines, tolines, fromName, toName, n=lines))
textComp = difflib.SequenceMatcher(None, fromText, toText)
diffRatio = round(textComp.quick_ratio() * 100, 2)
diffRatio = textComp.ratio()
return [diffRatio, diff]


Expand Down Expand Up @@ -203,7 +203,7 @@ def configlet_action(module):
ansible_configlet = module.params['configlets'][configlet['name']]
configlet_compare = compare(configlet['config'], ansible_configlet, 'CVP', 'Ansible')
# compare function returns a floating point number
if configlet_compare[0] == 100.0:
if configlet_compare[0] == 1.0:
keep_configlet.append(configlet)
else:
update_configlet.append({'data': configlet, 'config': ansible_configlet, 'diff': ''.join(configlet_compare[1])})
Expand Down

0 comments on commit 0c63d3e

Please sign in to comment.