AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-8061983

kcantrel's questions

Martin Hope
kcantrel
Asked: 2024-10-23 05:34:23 +0800 CST

如何在循环中选择某些字段而不跳过大量行

  • 6

我正在尝试在 Ansible 中创建一个数组,其中包含我的帐户中启用的所有支持 FSx for NetApp ONTAP(FSxN)的 AWS 区域。

我知道我可以使用以下命令获取我的帐户上启用的区域列表:

    - name: Get all the opted in regions.
      amazon.aws.aws_region_info:
      register: region_info

    - name: Just get region names
      set_fact:
        opted_in_regions: "{{ [item.region_name] + opted_in_regions }}"
      loop: "{{ region_info.regions }}"

但有时,通常是当一个新地区上线时,有些地区不支持 FSxN。

我发现了解哪些地区支持特定服务的唯一方法是从下载价格指南https://api.regional-table.region-services.aws.a2z.com/index.json并查找将“Amazon FSx for NetApp ONTAP”作为“aws:serviceName”的地区。该文件的格式为:

{
  "prices": [
    {
      "attributes": {
        "aws:region": "ap-east-1",
        "aws:serviceName": "Amazon Translate",
        "aws:serviceUrl": "https://aws.amazon.com/translate/"
      },
      "id": "translate:ap-east-1"
    },
    {
      "attributes": {
        "aws:region": "ap-northeast-1",
        "aws:serviceName": "Amazon Translate",
        "aws:serviceUrl": "https://aws.amazon.com/translate/"
      },
      "id": "translate:ap-northeast-1"
    },

因此,我所做的是使用文件内容创建变量:

    - name: Get the capabilities of all regions.
      set_fact:
        regions_capabilities: "{{lookup('ansible.builtin.url', 'https://api.regional-table.region-services.aws.a2z.com/index.json', split_lines=false)}}"

然后下一个“任务”是循环遍历所有值并将字段中具有特定字符串的值添加到另一个数组中aws:serviceName。

    - name: Get the intersection of opted in regions and regions that support FSxN.
      when: item['attributes']['aws:serviceName'] == "Amazon FSx for NetApp ONTAP" and item['attributes']['aws:region'] in opted_in_regions
      set_fact:
        fsxnRegions: "{{ [item['attributes']['aws:region']] + fsxnRegions }}"
      loop: "{{ regions_capabilities.prices }}"

虽然有效,但该语句会在输出中when:生成很多(数千)行。而且速度非常慢。skipping...

因此,问题是,是否有更好的方法来创建支持 FSxN 的区域数组?如果没有,我该如何隐藏该skipping消息,但仅限于此任务?

以下是完整的 Ansible 剧本:

# Title: generate report
---
- hosts: localhost
  collections:
    - amazon.aws
  gather_facts: false
  name: Playbook to generate a report on all the FSxNs
  vars:
    fsxnRegions: []
    opted_in_regions: []

  tasks:
    - name: Get all the opted in regions.
      amazon.aws.aws_region_info:
      register: region_info

    - name: Just get region names
      set_fact:
        opted_in_regions: "{{ [item.region_name] + opted_in_regions }}"
      loop: "{{ region_info.regions }}"

    - name: Get the capabilities of all regions.
      set_fact:
        regions_capabilities: "{{lookup('ansible.builtin.url', 'https://api.regional-table.region-services.aws.a2z.com/index.json', split_lines=false)}}"

    - name: Get the intersection of opted in regions and regions that support FSxN.
      when: item['attributes']['aws:serviceName'] == "Amazon FSx for NetApp ONTAP" and item['attributes']['aws:region'] in opted_in_regions
      set_fact:
        fsxnRegions: "{{ [item['attributes']['aws:region']] + fsxnRegions }}"
      loop: "{{ regions_capabilities.prices }}"

    - name: Output
      debug:
        msg: "fsxnRegions={{ fsxnRegions }}"
ansible
  • 1 个回答
  • 49 Views
Martin Hope
kcantrel
Asked: 2024-04-05 01:32:22 +0800 CST

如何限制进程可以看到的 FSxN 文件系统?

  • 5

我试图限制一个进程只能列出某些 FSx 系统。我的 EC2 实例附加了一个角色,其中包含如下声明。

"Statement": [
        {
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
                "fsx:Describe*",
                "fsx:List*",
                "fsx:UpdateFileSystem"
            ],
            "Resource": [
                "arn:aws:fsx:us-west-2:75xxxxxxx648:file-system/fs-0e8d9xxxxxxxef3b",
                "arn:aws:fsx:us-west-2:75xxxxxxx648:file-system/fs-07bcxxxxxxxx5e43"
            ]
        }

但是当我尝试列出文件系统时,在使用描述操作时出现错误。

ubuntu@ip-10-129-10-194:~$ aws fsx describe-file-systems --region=us-west-2
 
An error occurred (AccessDeniedException) when calling the DescribeFileSystems operation: User: arn:aws:sts::75xxxxxxx648:assumed-role/Cloud-Manager-Operator-399y9hM/i-00d9xxxxxxf16 is not authorized to perform: fsx:DescribeFileSystems on resource: arn:aws:fsx:us-west-2:75xxxxxxx648:file-system/* because no identity-based policy allows the fsx:DescribeFileSystems action

即使指定我在角色中列出的 FSxN 文件系统之一,我也会收到错误:

ubuntu@ip-10-129-10-194:~$ aws fsx describe-file-systems --region=us-west-2 --file-system-ids fs-07bxxxxxx5e43
 
An error occurred (AccessDeniedException) when calling the DescribeFileSystems operation: User: arn:aws:sts::75xxxxxxx648:assumed-role/Cloud-Manager-Operator-399y9hM/i-00d9bxxxxxff16 is not authorized to perform: fsx:DescribeFileSystems on resource: arn:aws:fsx:us-west-2:75xxxxxxx648:file-system/* because no identity-based policy allows the fsx:DescribeFileSystems action

有谁知道如何让 AWS 默默地忽略我无权访问的文件系统?

  • 1 个回答
  • 9 Views
Martin Hope
kcantrel
Asked: 2024-03-16 01:03:54 +0800 CST

尝试在 BlueXP 中管理 FSxN 文件系统时收到“没有连接”

  • 5

几周前,我向 BlueXP 画布添加了一个 FSxN 文件系统,直到昨天它都运行良好。现在,当我尝试“输入它”时,我会看到“没有连接”错误页面。

在此输入图像描述

我已确认我可以通过端口 22 和 443 从连接器访问 FSxN,因此我认为这实际上不是连接问题。不管。我检查了安全组和 ACL 规则,没有看到任何会阻碍两个系统之间流量流动的内容。

如果有人对可能导致问题的其他原因和/或在哪里诊断问题有任何想法,我将不胜感激。

  • 1 个回答
  • 15 Views
Martin Hope
kcantrel
Asked: 2024-02-14 08:43:49 +0800 CST

当对象不包含 select() 调用中的字段时如何包含该对象

  • 6

我想列出 JSON 结构中的几个字段,包括一个可选字段,该字段可能与我不想显示的其他字段一起位于数组中。我一直在使用 select() 从我想要的数组中获取一个值,但是如果我有一个没有该可选键的对象,那么它会被一起跳过。让我举个例子。这是数据:

[
{"field1":"1", "field2":"x", "Tags":[{"Key": "Name", "Value": "Name1"}, {"Key": "tag1", "Value": "tag1valuea"}]},
{"field1":"2", "field2":"y", "Tags":[{"Key": "Name", "Value": "Name2"}]},
{"field1":"3", "field2":"z", "Tags":[{"Key": "tag2", "Value": "tag2valueb"}]}
]

我想要的输出是:

1 x name1
2 y name2
3 z

我努力了:

jq -r '.[] | .field1 + " " + .field2 + " " + (.Tags[] | select(.Key == "Name") .Value)'
1 x Name1
2 y Name2

但是,正如您所看到的,它删除了第三个条目,因为它没有设置为“Name”的“Key”。

然后我尝试:

jq -r '.[] | .field1 + " " + .field2 + " " + (.Tags[] | if(.Key == "Name") then .Value else null end)'
1 x Name1
1 x
2 y Name2
3 z

您可以看到我最终得到了第一个对象的两个条目,因为它在数组中有一个我不关心的额外元素。

我已经尝试了上述两个选项的多种排列,但均无济于事。我希望有人有一种聪明的方法让 jq 不“清空”该项目(如果它没有我正在选择的键)和/或当数组中有我不想选择的项目时重复。

jq
  • 2 个回答
  • 35 Views
Martin Hope
kcantrel
Asked: 2024-01-30 03:29:02 +0800 CST

从 FSxN 卷删除数据不释放空间

  • 5

我在 FSx Netapp 文件系统下有一个卷,当我删除文件时,可用空间不会恢复到该卷中。例如。在这里,我正在删除 10GB 卷上的 8GB 文件,但没有空间返回到文件系统:

$ df -h .
Filesystem               Size  Used Avail Use% Mounted on
fsxdata:/keith_test_vol  9.5G  8.6G  981M  90% /mnt
$ ls -lh
total 8.1G
-rw-r--r-- 1 root   root   8.0G Jan 26 09:07 bigfile
-rw-rw-r-- 1 ubuntu ubuntu    6 Dec  6 11:30 test
-rw-r--r-- 1 root   root      0 Oct  9 16:54 test2
-rw-r--r-- 1 ubuntu ubuntu    0 Nov  9 11:35 test3
drwxrwxrwx 2 root   root   8.0K Dec 15 09:25 test_qtree
-rw-r--r-- 1 root   root      0 Oct  9 11:53 testfilefromroot
-rw-rw-r-- 1 ubuntu ubuntu    0 Nov  9 11:34 testfromunbuntu
$ rm bigfile
rm: remove write-protected regular file 'bigfile'? y
$ ls -lh
total 8.0K
-rw-rw-r-- 1 ubuntu ubuntu    6 Dec  6 11:30 test
-rw-r--r-- 1 root   root      0 Oct  9 16:54 test2
-rw-r--r-- 1 ubuntu ubuntu    0 Nov  9 11:35 test3
drwxrwxrwx 2 root   root   8.0K Dec 15 09:25 test_qtree
-rw-r--r-- 1 root   root      0 Oct  9 11:53 testfilefromroot
-rw-rw-r-- 1 ubuntu ubuntu    0 Nov  9 11:34 testfromunbuntu
$ df -h .
Filesystem               Size  Used Avail Use% Mounted on
fsxdata:/keith_test_vol  9.5G  8.6G  978M  90% /mnt

有人知道这是怎么回事吗?

  • 1 个回答
  • 9 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve