跳转到主要内容

未提供项目描述

项目描述

CSP云提供商,用于Idem

开发

克隆idem-csp存储库,并用pip安装。

git clone git@gitlab.com:vmware/idem/idem-csp.git
pip install -e idem_csp

ACCT

安装后,CSP Idem提供程序执行和状态模块将可供pop hub访问。为了使用它们,我们需要设置我们的凭据。按照 说明 生成api令牌。

创建一个名为credentials.yaml的新文件,并用凭据填充它。除非您在cli上指定了–acct-profile=profile_name,否则default配置文件将自动由idem使用。

aws提供商/配置文件可以以多种方式存储。有关更多信息,请参阅acct后端

配置文件需要指定它使用的API密钥,并可选择指定API URL。

credentials.yaml

csp.token:
  default:
    refresh_token: dmd23q3au8ljyajcvhz207of4ivsn9vjiaxzez223qeagdpe0voqiasknykv58jt
    default_org_id: defaults_to_the_logged_in_user_org_id
    # Optional configuration, defaults will be used for these values if not supplied
    csp_url: https://console.cloud.vmware.com

还可以创建一个使用直接访问令牌的配置文件。但是,必须显式定义csp_url和default_org_id。

credentials.yaml

csp:
    my_profile:
        csp_url: https://console.cloud.vmware.com
        default_org_id: my_org_id
        headers:
            csp-auth-token: kl2k3jjoij0un093wjn092w34jta0-3

现在加密凭据文件,并将加密密钥和加密文件路径添加到ENVIRONMENT。

由于它是idemidem-csp的必需项,所以应该可以使用acct命令。加密凭据文件。

acct encrypt credentials.yaml

输出

-A9ZkiCSOjWYG_lbGmmkVh4jKLFDyOFH4e4S1HNtNwI=

将这些添加到您的环境中

export ACCT_KEY="-A9ZkiCSOjWYG_lbGmmkVh4jKLFDyOFH4e4S1HNtNwI="
export ACCT_FILE=$PWD/credentials.yaml.fernet

用法

此插件允许您的应用程序集成csp身份验证。

如果您的项目实现了exec模块,则将csp添加到项目的身份验证插件,如下所示

# my_project_root/my_project/exec/my_project/init.py
def __init__(hub):
    hub.exec.my_project.ACCT = ["csp"]

如果您的项目实现了状态模块,则将csp添加到项目的身份验证插件,如下所示

# my_project_root/my_project/states/my_project/init.py
def __init__(hub):
    hub.states.my_project.ACCT = ["csp"]
async def my_func(hub, ctx):
    # Call any exec modules from idem-aiohttp, the ctx contains the right headers for csp apps
    ret = await hub.exec.json.get(ctx, url=f"my_app_url")
    # ret.result will be "True" if the command was a success
    assert ret.result, ret.comment
    # ret.ret has the return data
    return ret.ret

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

idem-csp-2.0.0.tar.gz (8.6 kB 查看哈希值)

上传时间:

构建分布

idem_csp-2.0.0-py3-none-any.whl (8.3 kB 查看哈希值)

上传时间: Python 3

由以下支持

AWSAWS云计算和安全赞助商DatadogDatadog监控FastlyFastlyCDNGoogleGoogle下载分析MicrosoftMicrosoftPSF赞助商PingdomPingdom监控SentrySentry错误日志StatusPageStatusPage状态页面