Module: Awspec::Helper::Finder::Efs
- Included in:
- Awspec::Helper::Finder
- Defined in:
- lib/awspec/helper/finder/efs.rb
Instance Method Summary collapse
- #find_efs(id) ⇒ Object
- #find_efs_tags(id, tag_key) ⇒ Object
- #get_id_by_name_tag(name) ⇒ Object
- #get_name_by_id(id) ⇒ Object
- #select_all_file_systems ⇒ Object
Instance Method Details
#find_efs(id) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/awspec/helper/finder/efs.rb', line 4 def find_efs(id) begin res = efs_client.describe_file_systems({ file_system_id: id, max_items: 1 }) rescue # Aws::EFS::Errors::BadRequest (invalid file system ID: my-efs) file_system_id = get_id_by_name_tag(id) res = efs_client.describe_file_systems({ file_system_id: file_system_id, max_items: 1 }) end res.file_systems.single_resource(id) end |
#find_efs_tags(id, tag_key) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/awspec/helper/finder/efs.rb', line 21 def (id, tag_key) begin tag_set = efs_client.({ file_system_id: id }) rescue # Aws::EFS::Errors::BadRequest (invalid file system ID: my-efs) file_system_id = get_id_by_name_tag(id) tag_set = efs_client.({ file_system_id: file_system_id }) end tag_query = tag_set..find { |tag| tag.key == tag_key } return tag_query if tag_query end |
#get_id_by_name_tag(name) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/awspec/helper/finder/efs.rb', line 35 def get_id_by_name_tag(name) # takes a name tag and iterates inventory and returns file_system obj inventory = efs_client.describe_file_systems file_systems = inventory.file_systems.select do |fs| tag_query = efs_client.({ file_system_id: fs.file_system_id }) name_tag = tag_query..find { |tag| tag.key == 'Name' } if tag_query. name_tag && name_tag.value == name end file_systems.single_resource(name).file_system_id end |
#get_name_by_id(id) ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/awspec/helper/finder/efs.rb', line 48 def get_name_by_id(id) tag_query = efs_client.({ file_system_id: id }) name_tag = tag_query..find { |tag| tag.key == 'Name' } return name_tag.value if name_tag end |
#select_all_file_systems ⇒ Object
56 57 58 59 60 |
# File 'lib/awspec/helper/finder/efs.rb', line 56 def select_all_file_systems file_systems_query = efs_client.describe_file_systems file_systems = file_systems_query.file_systems file_systems end |