{"action":"created","issue":{"url":"https://api.github.com/repos/saltstack/salt/issues/31579","repository_url":"https://api.github.com/repos/saltstack/salt","labels_url":"https://api.github.com/repos/saltstack/salt/issues/31579/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/31579/comments","events_url":"https://api.github.com/repos/saltstack/salt/issues/31579/events","html_url":"https://github.com/saltstack/salt/issues/31579","id":137585926,"number":31579,"title":"salt-cloud delete with a map file fails when multiple providers defined","user":{"login":"bradthurber","id":3045456,"avatar_url":"https://avatars.githubusercontent.com/u/3045456?v=3","gravatar_id":"","url":"https://api.github.com/users/bradthurber","html_url":"https://github.com/bradthurber","followers_url":"https://api.github.com/users/bradthurber/followers","following_url":"https://api.github.com/users/bradthurber/following{/other_user}","gists_url":"https://api.github.com/users/bradthurber/gists{/gist_id}","starred_url":"https://api.github.com/users/bradthurber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bradthurber/subscriptions","organizations_url":"https://api.github.com/users/bradthurber/orgs","repos_url":"https://api.github.com/users/bradthurber/repos","events_url":"https://api.github.com/users/bradthurber/events{/privacy}","received_events_url":"https://api.github.com/users/bradthurber/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/saltstack/salt/labels/Bug","name":"Bug","color":"e11d21"},{"url":"https://api.github.com/repos/saltstack/salt/labels/High%20Severity","name":"High Severity","color":"ff9143"},{"url":"https://api.github.com/repos/saltstack/salt/labels/P3","name":"P3","color":"0a3d77"},{"url":"https://api.github.com/repos/saltstack/salt/labels/RIoT","name":"RIoT","color":"fef2c0"},{"url":"https://api.github.com/repos/saltstack/salt/labels/Salt-Cloud","name":"Salt-Cloud","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/saltstack/salt/milestones/13","html_url":"https://github.com/saltstack/salt/milestones/Approved","labels_url":"https://api.github.com/repos/saltstack/salt/milestones/13/labels","id":9265,"number":13,"title":"Approved","description":"All issues that are ready to be worked on, both bugs and features.","creator":{"login":"thatch45","id":507599,"avatar_url":"https://avatars.githubusercontent.com/u/507599?v=3","gravatar_id":"","url":"https://api.github.com/users/thatch45","html_url":"https://github.com/thatch45","followers_url":"https://api.github.com/users/thatch45/followers","following_url":"https://api.github.com/users/thatch45/following{/other_user}","gists_url":"https://api.github.com/users/thatch45/gists{/gist_id}","starred_url":"https://api.github.com/users/thatch45/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thatch45/subscriptions","organizations_url":"https://api.github.com/users/thatch45/orgs","repos_url":"https://api.github.com/users/thatch45/repos","events_url":"https://api.github.com/users/thatch45/events{/privacy}","received_events_url":"https://api.github.com/users/thatch45/received_events","type":"User","site_admin":false},"open_issues":2920,"closed_issues":3396,"state":"open","created_at":"2011-05-14T04:00:56Z","updated_at":"2016-03-02T22:09:42Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-03-01T14:22:22Z","updated_at":"2016-03-02T23:47:15Z","closed_at":null,"body":"### Description of Issue/Question\r\nsalt-cloud delete of a mapped environment fails when more than one provider is defined. \r\n\r\nExample failing run: \r\n```\r\n[root@s-cdc-jbsalt-01 cloud.maps.d]# salt-cloud -m /etc/salt/cloud.maps.d/map-uat2-jb -d\r\n[INFO    ] salt-cloud starting\r\n[INFO    ] Applying map from '/etc/salt/cloud.maps.d/map-uat2-jb'.\r\n[ERROR   ] An un-handled exception was caught by salt's global exception handler:\r\nKeyError: 'u-jbdom-201.adesa.com'\r\nTraceback (most recent call last):\r\n  File \"/usr/bin/salt-cloud\", line 10, in <module>\r\n    salt_cloud()\r\n  File \"/usr/lib/python2.6/site-packages/salt/scripts.py\", line 425, in salt_cloud\r\n    client.run()\r\n  File \"/usr/lib/python2.6/site-packages/salt/cloud/cli.py\", line 186, in run\r\n    matching = mapper.delete_map(query='list_nodes')\r\n  File \"/usr/lib/python2.6/site-packages/salt/cloud/__init__.py\", line 1673, in delete_map\r\n    query_map = self.interpolated_map(query=query)\r\n  File \"/usr/lib/python2.6/site-packages/salt/cloud/__init__.py\", line 1656, in interpolated_map\r\n    names.remove(vm_name)\r\nKeyError: 'u-jbdom-201.adesa.com'\r\nTraceback (most recent call last):\r\n  File \"/usr/bin/salt-cloud\", line 10, in <module>\r\n    salt_cloud()\r\n  File \"/usr/lib/python2.6/site-packages/salt/scripts.py\", line 425, in salt_cloud\r\n    client.run()\r\n  File \"/usr/lib/python2.6/site-packages/salt/cloud/cli.py\", line 186, in run\r\n    matching = mapper.delete_map(query='list_nodes')\r\n  File \"/usr/lib/python2.6/site-packages/salt/cloud/__init__.py\", line 1673, in delete_map\r\n    query_map = self.interpolated_map(query=query)\r\n  File \"/usr/lib/python2.6/site-packages/salt/cloud/__init__.py\", line 1656, in interpolated_map\r\n    names.remove(vm_name)\r\nKeyError: 'u-jbdom-201.adesa.com'\r\n```\r\n\r\nThe workaround I have come up with is to hide all of the providers except for the one used by the map. The delete then works.\r\n\r\nI'm wondering if there is perhaps some nuance with the cloud.providers.d file format that I am not seeing? All of my sanitized cloud files are below.\r\n\r\n### Setup\r\nAdd the following cloud configuration files\r\n\r\n/etc/salt/cloud.maps.d/map-uat2-jb\r\n```\r\nprof-vmware-nonprod-jbdom:\r\n  - u-jbdom-201.adesa.com:\r\n      grains:\r\n        environment: uat2\r\n```\r\n\r\n/etc/salt/cloud.profiles.d/prof-vmware-nonprod-jb.conf\r\n```\r\nprof-vmware-nonprod-jb-instances:\r\n  provider: prov-vmware-nonprod-jb\r\n\r\n  clonefrom: rhel6xnonprodtemplate.company.com\r\n\r\n  datacenter: CAR\r\n  datastore: Pure-CDC\r\n  cluster: CVEP-LX\r\n  folder: JBOSS\r\n\r\n  ssh_username: Brad.Thurber\r\n  password: SANITIZED\r\n  deploy: True\r\n  domain: company.com\r\n\r\nprof-vmware-nonprod-jbdom:\r\n  cores_per_socket: 2\r\n  devices:\r\n    network:\r\n      Network adapter 1:\r\n        name: VLAN641\r\n        switch_type: standard\r\n  extends: prof-vmware-nonprod-jb-instances\r\n  grains:\r\n    jboss_domain_controller: True\r\n    platform:\r\n      name: jboss\r\n      ou: adesac\r\n      realm: nonprod \r\n    roles:\r\n      - jboss\r\n  memory: 8GB\r\n  num_cpus: 2\r\n\r\nprof-vmware-nonprod-jbapp:\r\n  cores_per_socket: 2\r\n  devices:\r\n    network:\r\n      Network adapter 1:\r\n        name: VLAN641\r\n        switch_type: standard\r\n  extends: prof-vmware-nonprod-jb-instances\r\n  grains:\r\n    platform:\r\n      name: jboss\r\n      ou: adesac\r\n      realm: nonprod\r\n    roles:\r\n      - jboss\r\n      - mod-cluster-node\r\n  memory: 64GB\r\n  num_cpus: 8\r\n\r\nprof-vmware-nonprod-jbweb:\r\n  devices:\r\n    network:\r\n      Network adapter 1:\r\n        name: VLAN230\r\n        switch_type: standard\r\n  extends: prof-vmware-nonprod-jb-instances\r\n  grains:\r\n    platform:\r\n      name: jboss\r\n      ou: adesac\r\n      realm: nonprod\r\n    roles:\r\n      - webserver\r\n      - mod-cluster-server\r\n  memory: 4GB\r\n  num_cpus: 1\r\n\r\n```\r\n/etc/salt/cloud.profiles.d/prof-vmware-prod-jb.conf\r\n```\r\nprof-vmware-prod-jb-instances:\r\n  provider: prov-vmware-prod-jb\r\n\r\n  clonefrom: rhel6xnonprodtemplate.company.com\r\n\r\n  datacenter: LIFELINE\r\n  datastore: Pure-CDC\r\n  cluster: PVEP-LX\r\n  folder: JBOSS\r\n\r\n  ssh_username: Brad.Thurber\r\n  password: SANITIZED\r\n  deploy: True\r\n  domain: company.com\r\n\r\nprof-vmware-prod-jbdom:\r\n  extends: prof-vmware-prod-jb-instances\r\n  cores_per_socket: 2\r\n  devices:\r\n    network:\r\n      Network adapter 1:\r\n        name: VLAN170\r\n        switch_type: standard\r\n  grains:\r\n    jboss_domain_controller: True\r\n    roles:\r\n      - jboss\r\n  memory: 8GB\r\n  num_cpus: 2\r\n\r\nprof-vmware-prod-jbapp:\r\n  extends: prof-vmware-prod-jb-instances\r\n  cores_per_socket: 2\r\n  devices:\r\n    network:\r\n      Network adapter 1:\r\n        name: VLAN170\r\n        switch_type: standard\r\n  grains:\r\n    roles:\r\n      - jboss\r\n      - mod-cluster-node\r\n  memory: 64GB\r\n  num_cpus: 8\r\n\r\nprof-vmware-prod-jbweb:\r\n  extends: prof-vmware-prod-jb-instances\r\n  devices:\r\n    network:\r\n      Network adapter 1:\r\n        name: VLAN765\r\n        switch_type: standard\r\n  grains:\r\n    roles:\r\n      - webserver\r\n      - mod-cluster-server\r\n  memory: 4GB\r\n  num_cpus: 1\r\n```\r\n\r\n/etc/salt/cloud.providers.d/prov_vmware_nonprod.conf\r\n```\r\nprov-vmware-nonprod-jb:\r\n  driver: vmware\r\n  user: 'DOMAIN\\username'\r\n  password: 'SANITIZED'\r\n  url: 'p-corp-vcntr.company.com'\r\n  protocol: 'https'\r\n  port: 443\r\n  minion:\r\n    master: saltmaster.company.com\r\n```\r\n\r\n/etc/salt/cloud.providers.d/prov_vmware_prod.conf\r\n```\r\nprov-vmware-prod-jb:\r\n  driver: vmware\r\n  user: 'DOMAIN\\username'\r\n  password: 'SANITIZED'\r\n  url: 'p-corp-vcntr.company.com'\r\n  protocol: 'https'\r\n  port: 443\r\n  minion:\r\n    master: saltmaster.company.com\r\n```\r\n\r\n### Steps to Reproduce Issue\r\nRun salt-cloud map delete as shown in the description above. You should get the failure as in the description above. \r\n\r\nNow hide the prov_vmware_prod.conf file (this is the one that is NOT used by the map) by renaming it to prov_vmware_prod.confHIDDEN. The salt cloud map delete operation will now work.\r\n\r\n\r\n### Versions Report\r\n*Provided by running* ``salt --versions-report``\r\n```\r\n[root@s-cdc-jbsalt-01 salt]# salt --versions-report                                                                                                     [2/9611]Salt Version:\r\n           Salt: 2015.8.7\r\n\r\nDependency Versions:\r\n         Jinja2: 2.8\r\n       M2Crypto: 0.20.2\r\n           Mako: 0.3.4\r\n         PyYAML: 3.11\r\n          PyZMQ: 14.5.0\r\n         Python: 2.6.6 (r266:84292, Nov 21 2013, 10:50:32)\r\n           RAET: Not Installed\r\n        Tornado: 4.2.1\r\n            ZMQ: 4.0.5\r\n           cffi: Not Installed\r\n       cherrypy: 3.2.2\r\n       dateutil: 1.4.1\r\n          gitdb: 0.5.4\r\n      gitpython: 0.3.2 RC1\r\n          ioflo: Not Installed\r\n        libgit2: 0.20.0\r\n        libnacl: Not Installed\r\n   msgpack-pure: Not Installed\r\n msgpack-python: 0.4.6\r\n   mysql-python: Not Installed\r\n      pycparser: Not Installed\r\n       pycrypto: 2.6.1\r\n         pygit2: 0.20.3\r\n   python-gnupg: Not Installed\r\n          smmap: 0.8.1\r\n        timelib: Not Installed\r\n\r\nSystem Versions:\r\n           dist: redhat 6.6 Santiago\r\n        machine: x86_64\r\n        release: 2.6.32-504.el6.x86_64\r\n         system: Red Hat Enterprise Linux Server 6.6 Santiago\r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/saltstack/salt/issues/comments/191497508","html_url":"https://github.com/saltstack/salt/issues/31579#issuecomment-191497508","issue_url":"https://api.github.com/repos/saltstack/salt/issues/31579","id":191497508,"user":{"login":"rickh563","id":9968958,"avatar_url":"https://avatars.githubusercontent.com/u/9968958?v=3","gravatar_id":"","url":"https://api.github.com/users/rickh563","html_url":"https://github.com/rickh563","followers_url":"https://api.github.com/users/rickh563/followers","following_url":"https://api.github.com/users/rickh563/following{/other_user}","gists_url":"https://api.github.com/users/rickh563/gists{/gist_id}","starred_url":"https://api.github.com/users/rickh563/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rickh563/subscriptions","organizations_url":"https://api.github.com/users/rickh563/orgs","repos_url":"https://api.github.com/users/rickh563/repos","events_url":"https://api.github.com/users/rickh563/events{/privacy}","received_events_url":"https://api.github.com/users/rickh563/received_events","type":"User","site_admin":false},"created_at":"2016-03-02T23:47:15Z","updated_at":"2016-03-02T23:47:15Z","body":"Salt-Support has validated that this is a bug, though with the following caveats:\r\n\r\nThis bug only shows up when using vmware with salt-cloud and using the extends profile functionality.\r\n\r\n1. The bug has been confirmed with the vmware driver.\r\n\r\n2. The bug was not confirmed with our test case using amazon or ec2 driver.\r\n\r\n3. Salt-Support confirmed that the workaround works  just as the customer stated.\r\n\r\n4. The bug does not show up when we remove the extends from the profile configurations.\r\n\r\nFor additional detail see:\r\n\r\n* https://gist.github.com/frogunder/71e934b0bd7c7f6e1e96"}}