Skip to content

Commit

Permalink
py33: unknown encoding: base64 Edit
Browse files Browse the repository at this point in the history
Python 3 doesn't support str.encode('base64'), we should use the
module "base64" instead.

Close-Bug #1229161

Change-Id: I1432952558f8c5c3cff39761306e91916d80207f
  • Loading branch information
skuicloud committed Sep 24, 2013
1 parent 2ab3344 commit 8b264fc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion novaclient/base.py
Expand Up @@ -360,7 +360,7 @@ def _boot(self, resource_url, response_key, name, image, flavor,
data = file_or_string
personality.append({
'path': filepath,
'contents': data.encode('base64'),
'contents': base64.b64encode(data.encode('utf-8')),
})

if availability_zone:
Expand Down
7 changes: 5 additions & 2 deletions novaclient/tests/v1_1/test_shell.py
Expand Up @@ -16,6 +16,7 @@
# License for the specific language governing permissions and limitations
# under the License.

import base64
import datetime
import os
import mock
Expand Down Expand Up @@ -174,7 +175,8 @@ def test_boot_key(self):

def test_boot_user_data(self):
testfile = os.path.join(os.path.dirname(__file__), 'testfile.txt')
expected_file_data = open(testfile).read().encode('base64').strip()
data = open(testfile).read()
expected_file_data = base64.b64encode(data.encode('utf-8'))
self.run_command(
'boot --flavor 1 --image 1 --user_data %s some-server' % testfile)
self.assert_called_anytime(
Expand Down Expand Up @@ -514,7 +516,8 @@ def test_boot_nics_no_netid_or_portid(self):

def test_boot_files(self):
testfile = os.path.join(os.path.dirname(__file__), 'testfile.txt')
expected_file_data = open(testfile).read().encode('base64')
data = open(testfile).read()
expected_file_data = base64.b64encode(data.encode('utf-8'))

cmd = ('boot some-server --flavor 1 --image 1'
' --file /tmp/foo=%s --file /tmp/bar=%s')
Expand Down

0 comments on commit 8b264fc

Please sign in to comment.