Просмотр исходного кода

Use a dict getter when grabbing EC2 instance name

Enis Afgan 10 лет назад
Родитель
Сommit
53045601c9
1 измененных файлов с 4 добавлено и 2 удалено
  1. 4 2
      cloudbridge/providers/ec2/types.py

+ 4 - 2
cloudbridge/providers/ec2/types.py

@@ -23,8 +23,10 @@ class EC2Instance(Instance):
     def name(self):
         """
         Get the instance name.
+
+        .. note:: an instance must have a (case sensitive) tag ``Name``
         """
-        return self._ec2_instance.tags['Name']
+        return self._ec2_instance.tags.get('Name')
 
     @name.setter
     def name(self, value):
@@ -92,4 +94,4 @@ class EC2Instance(Instance):
         """
         Get the name of the key pair associated with this instance.
         """
-        return BaseKeyPair(self._ec2_instance.key_name)
+        return BaseKeyPair(self._ec2_instance.key_name)