Closed jpotter closed 7 years ago
PS: The version installed by pip on August 23rd was 0.5.0; now it's 0.7.0, in case that's useful to know.
We are also facing such issue, aws-ec2-assign-elastic-ip (0.5.0) seems to work fine.
Same issue as jpotter mentioned::
Collecting aws-ec2-assign-elastic-ip
Downloading aws-ec2-assign-elastic-ip-0.7.0.tar.gz
Collecting boto>=2.36.0 (from aws-ec2-assign-elastic-ip)
Downloading boto-2.48.0-py2.py3-none-any.whl (1.4MB)
Collecting netaddr>=0.7.12 (from aws-ec2-assign-elastic-ip)
Downloading netaddr-0.7.19-py2.py3-none-any.whl (1.6MB)
Building wheels for collected packages: aws-ec2-assign-elastic-ip
Running setup.py bdist_wheel for aws-ec2-assign-elastic-ip: started
Running setup.py bdist_wheel for aws-ec2-assign-elastic-ip: finished with status 'done'
Stored in directory: /root/.cache/pip/wheels/78/3d/54/c3832078fb8b5f51cc9cd50eae5a5d2222d59530094a67bab2
Successfully built aws-ec2-assign-elastic-ip
Installing collected packages: boto, netaddr, aws-ec2-assign-elastic-ip
Successfully installed aws-ec2-assign-elastic-ip-0.7.0 boto-2.48.0 netaddr-0.7.19
2017-08-28 10:45:28,772 - aws-ec2-assign-eip - INFO - Connected to AWS EC2 in eu-central-1
Traceback (most recent call last):
File "/usr/local/bin/aws-ec2-assign-elastic-ip", line 31, in
This has been patched in version 0.7.1 which was just submitted to PyPI. Please reopen if the issue persists.
Thanks for a handy script -- we've been using it and find it useful.
Alas, the latest version that gets installed via pip is fatally broken -- this was working a few days ago, so I dug in to see what I could find.
Starting at https://github.com/skymill/aws-ec2-assign-elastic-ip/blob/fd2208b7dcfc3f7dc1b7563c1c4f7219bf553ae1/aws_ec2_assign_elastic_ip/__init__.py#L171
This line returns an undefined variable, causing the script to fail. expected_state isn't defined anywhere other than line 171 and 181; in the older versions, line 171 would have returned True and line 181 would have returned False.
Also, once this is fixed, there is another bug: args.invalid_ips will be Null unless the script is called with a value passed in via --invalid-ips. This causes args.invalid_ips to be Null, which causes _is_ip_in_range to return False, which causes _is_valid to return False, which means the entire script fails to assign an elastic IP unless --invalid-ips is specified on the command line.
Traceback (most recent call last): File "/bin/aws-ec2-assign-elastic-ip", line 31, in
aws_ec2_assign_elastic_ip.main()
File "/usr/lib/python2.7/site-packages/aws_ec2_assign_elastic_ip/init.py", line 60, in main
address = _get_unassociated_address()
File "/usr/lib/python2.7/site-packages/aws_ec2_assign_elastic_ip/init.py", line 127, in _get_unassociated_address
if _is_valid(address.public_ip):
File "/usr/lib/python2.7/site-packages/aws_ec2_assign_elastic_ip/init.py", line 191, in _is_valid
if _is_ip_in_range(address, args.valid_ips):
File "/usr/lib/python2.7/site-packages/aws_ec2_assign_elastic_ip/init.py", line 171, in _is_ip_in_range
return expected_state
NameError: global name 'expected_state' is not defined