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

Migrate nixops-aws to python3 #37

Merged
merged 1 commit into from
Mar 22, 2020
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
1 change: 0 additions & 1 deletion nixopsaws/resources/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import absolute_import
from . import aws_vpn_connection
from . import aws_vpn_connection_route
from . import aws_vpn_gateway
Expand Down
2 changes: 1 addition & 1 deletion nixopsaws/resources/ebs_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Automatic provisioning of AWS EBS volumes.

from __future__ import absolute_import

import boto.ec2
import nixops.util
import nixopsaws.ec2_utils
Expand Down
6 changes: 3 additions & 3 deletions nixopsaws/resources/ec2_placement_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def create(self, defn, check, allow_reboot, allow_recreate):
self.state = self.UP
self.placement_group_strategy = grp.strategy
except boto.exception.EC2ResponseError as e:
if e.error_code == u"InvalidGroup.NotFound":
if e.error_code == "InvalidGroup.NotFound":
self.state = self.Missing
else:
raise
Expand All @@ -129,7 +129,7 @@ def create(self, defn, check, allow_reboot, allow_recreate):
except boto.exception.EC2ResponseError as e:
if (
self.state != self.UNKNOWN
or e.error_code != u"InvalidGroup.Duplicate"
or e.error_code != "InvalidGroup.Duplicate"
):
raise

Expand All @@ -146,7 +146,7 @@ def after_activation(self, defn):
try:
conn.delete_placement_group(group["name"])
except boto.exception.EC2ResponseError as e:
if e.error_code != u"InvalidGroup.NotFound":
if e.error_code != "InvalidGroup.NotFound":
raise
self.old_placement_groups = []

Expand Down
4 changes: 2 additions & 2 deletions nixopsaws/resources/ec2_rds_dbinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def _try_fetch_dbinstance(self, instance_id):
try:
dbinstance = self._conn.get_all_dbinstances(instance_id=instance_id)[0]
except boto.exception.BotoServerError as bse:
if bse.error_code == u"DBInstanceNotFound":
if bse.error_code == "DBInstanceNotFound":
dbinstance = None
else:
raise
Expand Down Expand Up @@ -275,7 +275,7 @@ def _to_boto_kwargs(self, attrs):

def _compare_instance_id(self, instance_id):
# take care when comparing instance ids, as aws lowercases and converts to unicode
return unicode(self.rds_dbinstance_id).lower() == unicode(instance_id).lower()
return str(self.rds_dbinstance_id).lower() == str(instance_id).lower()

def fetch_security_group_resources(self, config):
security_groups = []
Expand Down
10 changes: 5 additions & 5 deletions nixopsaws/resources/ec2_security_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def retry_notfound(f):
rules.append(new_rule)
self.security_group_rules = rules
except boto.exception.EC2ResponseError as e:
if e.error_code == u"InvalidGroup.NotFound":
if e.error_code == "InvalidGroup.NotFound":
self.state = self.MISSING
else:
raise
Expand Down Expand Up @@ -228,7 +228,7 @@ def retry_notfound(f):
except boto.exception.EC2ResponseError as e:
if (
self.state != self.UNKNOWN
or e.error_code != u"InvalidGroup.Duplicate"
or e.error_code != "InvalidGroup.Duplicate"
):
raise
self.state = self.STARTING # ugh
Expand Down Expand Up @@ -284,7 +284,7 @@ def retry_notfound(f):
)
)
except boto.exception.EC2ResponseError as e:
if e.error_code != u"InvalidPermission.Duplicate":
if e.error_code != "InvalidPermission.Duplicate":
raise

if old_rules:
Expand Down Expand Up @@ -345,7 +345,7 @@ def after_activation(self, defn):
try:
conn.delete_security_group(group["name"])
except boto.exception.EC2ResponseError as e:
if e.error_code != u"InvalidGroup.NotFound":
if e.error_code != "InvalidGroup.NotFound":
raise
self.old_security_groups = []

Expand All @@ -365,7 +365,7 @@ def destroy(self, wipe=False):
error_codes=["DependencyViolation"],
)
except boto.exception.EC2ResponseError as e:
if e.error_code != u"InvalidGroup.NotFound":
if e.error_code != "InvalidGroup.NotFound":
raise

self.state = self.MISSING
Expand Down
2 changes: 1 addition & 1 deletion nixopsaws/resources/elastic_file_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# AWS Elastic File Systems.

from __future__ import absolute_import

import uuid
import boto3
import botocore
Expand Down
2 changes: 1 addition & 1 deletion nixopsaws/resources/elastic_file_system_mount_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# AWS Elastic File System mount targets.

from __future__ import absolute_import

import boto3
import botocore
import nixops.util
Expand Down
6 changes: 3 additions & 3 deletions release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ rec {
build = pkgs.lib.genAttrs [ "x86_64-linux" "i686-linux" "x86_64-darwin" ] (system:
with import nixpkgs { inherit system; };

python2Packages.buildPythonApplication rec {
python3Packages.buildPythonApplication rec {
pname = "nixops-aws";
inherit version;
namePrefix = "";
Expand All @@ -26,8 +26,8 @@ rec {
substituteAllInPlace setup.py
'';

buildInputs = with python2Packages; [ nose coverage ];
propagatedBuildInputs = with python2Packages; [ boto boto3 ];
buildInputs = with python3Packages; [ nose coverage ];
propagatedBuildInputs = with python3Packages; [ boto boto3 ];

# For "nix-build --run-env".
shellHook = ''
Expand Down