def get_instance(self, instance_id): try: res = self.conn.get_all_instances( filters={'instance-id': instance_id}) i = res[0].instances[0] # set group info i.groups = res[0].groups return i except boto.exception.EC2ResponseError, e: self.__check_for_auth_failure(e) raise exception.InstanceDoesNotExist(instance_id)
def get_node(self, node_id, user='******'): """Factory for Node class""" instances = self.ec2.get_all_instances() node = None for instance in instances: if instance.dns_name == node_id: node = instance break elif instance.id == node_id: node = instance break if not node: raise exception.InstanceDoesNotExist(node_id) key = self.cfg.get_key(node.key_name) node = Node(node, key.key_location, user=user) return node
return base64.b64decode(user_data) def get_instance(self, instance_id): try: res = self.conn.get_all_instances( filters={'instance-id': instance_id}) i = res[0].instances[0] # set group info i.groups = res[0].groups return i except boto.exception.EC2ResponseError, e: self.__check_for_auth_failure(e) raise exception.InstanceDoesNotExist(instance_id) except IndexError: # for eucalyptus, invalid instance_id returns [] raise exception.InstanceDoesNotExist(instance_id) def is_valid_conn(self): try: self.get_all_instances() return True except boto.exception.EC2ResponseError: return False def get_all_spot_requests(self, spot_ids=[], filters=None): spots = self.conn.get_all_spot_instance_requests(spot_ids, filters=filters) return spots def get_all_instances(self, instance_ids=[], filters=None): reservations = self.conn.get_all_instances(instance_ids,