Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(875)

Side by Side Diff: boto/ec2/keypair.py

Issue 8386013: Merging in latest boto. (Closed) Base URL: svn://svn.chromium.org/boto
Patch Set: Redoing vendor drop by deleting and then merging. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « boto/ec2/instance.py ('k') | boto/ec2/securitygroup.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/ 1 # Copyright (c) 2006,2007 Mitch Garnaat http://garnaat.org/
2 # 2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a 3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the 4 # copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including 5 # "Software"), to deal in the Software without restriction, including
6 # without limitation the rights to use, copy, modify, merge, publish, dis- 6 # without limitation the rights to use, copy, modify, merge, publish, dis-
7 # tribute, sublicense, and/or sell copies of the Software, and to permit 7 # tribute, sublicense, and/or sell copies of the Software, and to permit
8 # persons to whom the Software is furnished to do so, subject to the fol- 8 # persons to whom the Software is furnished to do so, subject to the fol-
9 # lowing conditions: 9 # lowing conditions:
10 # 10 #
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 of the keypair as the base name and .pem 69 of the keypair as the base name and .pem
70 for the file extension. If a file of that 70 for the file extension. If a file of that
71 name already exists in the directory, an 71 name already exists in the directory, an
72 exception will be raised and the old file 72 exception will be raised and the old file
73 will not be overwritten. 73 will not be overwritten.
74 74
75 :rtype: bool 75 :rtype: bool
76 :return: True if successful. 76 :return: True if successful.
77 """ 77 """
78 if self.material: 78 if self.material:
79 directory_path = os.path.expanduser(directory_path)
79 file_path = os.path.join(directory_path, '%s.pem' % self.name) 80 file_path = os.path.join(directory_path, '%s.pem' % self.name)
80 if os.path.exists(file_path): 81 if os.path.exists(file_path):
81 raise BotoClientError('%s already exists, it will not be overwri tten' % file_path) 82 raise BotoClientError('%s already exists, it will not be overwri tten' % file_path)
82 fp = open(file_path, 'wb') 83 fp = open(file_path, 'wb')
83 fp.write(self.material) 84 fp.write(self.material)
84 fp.close() 85 fp.close()
86 os.chmod(file_path, 0600)
85 return True 87 return True
86 else: 88 else:
87 raise BotoClientError('KeyPair contains no material') 89 raise BotoClientError('KeyPair contains no material')
88 90
89 def copy_to_region(self, region): 91 def copy_to_region(self, region):
90 """ 92 """
91 Create a new key pair of the same new in another region. 93 Create a new key pair of the same new in another region.
92 Note that the new key pair will use a different ssh 94 Note that the new key pair will use a different ssh
93 cert than the this key pair. After doing the copy, 95 cert than the this key pair. After doing the copy,
94 you will need to save the material associated with the 96 you will need to save the material associated with the
95 new key pair (use the save method) to a local file. 97 new key pair (use the save method) to a local file.
96 98
97 :type region: :class:`boto.ec2.regioninfo.RegionInfo` 99 :type region: :class:`boto.ec2.regioninfo.RegionInfo`
98 :param region: The region to which this security group will be copied. 100 :param region: The region to which this security group will be copied.
99 101
100 :rtype: :class:`boto.ec2.keypair.KeyPair` 102 :rtype: :class:`boto.ec2.keypair.KeyPair`
101 :return: The new key pair 103 :return: The new key pair
102 """ 104 """
103 if region.name == self.region: 105 if region.name == self.region:
104 raise BotoClientError('Unable to copy to the same Region') 106 raise BotoClientError('Unable to copy to the same Region')
105 conn_params = self.connection.get_params() 107 conn_params = self.connection.get_params()
106 rconn = region.connect(**conn_params) 108 rconn = region.connect(**conn_params)
107 kp = rconn.create_key_pair(self.name) 109 kp = rconn.create_key_pair(self.name)
108 return kp 110 return kp
109 111
110 112
111 113
OLDNEW
« no previous file with comments | « boto/ec2/instance.py ('k') | boto/ec2/securitygroup.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698