Citrix Application Delivery Management 服务

在 Amazon Web Services (AWS) 上安装 Citrix ADM 代理

Citrix Application Delivery Management (Citrix ADM) 代理可充当 Citrix ADM 与数据中心或云中发现的实例之间的中介。

必备条件

要使用 Amazon GUI 在 Amazon Web Services (AWS) 虚拟私有云 (VPC) 中启动 Citrix ADM 代理 AMI,您需要:

  • AWS 帐户

  • AWS 虚拟专用云 (VPC)

  • IAM 帐户

注意

  • 在置备 ADM 代理虚拟机之前,Citrix 建议创建安全组、虚拟专用网络、密钥对、子网和其他实体。因此,在预配过程中可以使用网络信息。

  • 要使 Citrix ADM 代理与 Citrix ADM 和 Citrix ADC 实例进行通信,请确保建议的端口处于打开状态。有关 Citrix ADM 代理端口要求的完整详细信息,请参阅端口

要在 AWS 上安装 Citrix ADM 代理,请执行以下操作:

  1. 使用 AWS 凭证登录到AWS Marketplace

  2. 在搜索字段中,键入Citrix ADM 代理以搜索 Citrix ADM 代理 AMI,然后单击转到

  3. 在搜索结果页面上,单击可用列表中的ADM 外部代理 AMI

  4. ADM 外部代理 AMI页面上,单击继续订阅

    ADM 外部代理

  5. 订阅成功后,单击继续配置

    继续配置

  6. 配置此软件页面上:

    1. 从 “配送” 选项列表中选择 AMI。

    2. 从 “软件版本” 列表中选择最新的 Citrix ADM 代理版本

    3. 从区域列表中选择您的区域

    4. 点击继续启动

      继续启动

  7. 启动此软件页面上,您有两个选项可以注册 Citrix ADM 代理:

    1. 从网站启动

    2. 使用 EC2 启动

      使用 EC2 启动

从网站启动

要从网站启动,请选择:

  1. EC2 实例类型列表中的EC2 实例类型

  2. VPC 设置列表中的 VPC。单击在 EC2 中创建 VPC,为您的软件创建 VPC。

  3. 子网设置列表中的子网。在您选择 VPC 后,单击在 EC2中创建子网以创建子网。

  4. 安全组设置列表中的防火墙安全组。单击基于卖家设置创建新建以创建安全组。

  5. 用于确保 “密钥对设置” 列表中的访问安全性的密钥对。单击EC2 中的创建密钥对,为您的软件创建密钥对。

  6. 点击启动

    启动网站

  7. 从网站启动成功。

    从网站启动成功

    注意

    部署过程可能需要大约 10-15 分钟。部署成功完成后,您可以在 AWS 账户上查看 Citrix ADM 代理虚拟机。

  8. 部署代理后,为 Citrix ADM 代理分配名称。

  9. 代理启动并运行后,请为 Citrix ADM 代理分配弹性 IP 地址。

    注意

    弹性 IP 地址使 Citrix ADM 代理能够与 Citrix ADM 通信。但是,如果已将 NAT Gateway 配置为将流量路由到 Internet,则可能不需要弹性 IP 地址。

  10. 使用 SSH 客户端,使用公有 IP 地址登录到 Citrix ADM 代理。

    注意

    您可以使用以下方法之一登录到 Citrix ADM 代理:

    • nsrecover作用户名和 AWS 实例 ID 作为密码。

    • nsroot作用户名和有效的密钥对作为密码。

  11. 输入以下命令以调用部署屏幕:部署类型. py

  12. 按照中的说明在 Citrix ADM 中的置代页面中输入复制和保存的服务 URL和激活代码入门。代理使用服务 URL 查找服务,并使用激活代码向服务注册。

    ADM 服务部署

代理注册成功后,代理重新启动以完成安装过程。

代理重新启动后,访问 Citrix ADM,然后在设置代理页面的 “已发现代理” 下,验证代理的状态。

使用 EC2 启动

要使用 EC2 启动,请从选择操作列表中选择通过 EC2启动,然后单击动。

  1. 选择实例类型页面上,选择实例,然后单击下一步:配置实例详细信息

    配置实例详细信息

  2. 配置实例详细信息页面上,指定所需的参数。

    在 “高级详细信息” 部分下,您可以通过在用户数据字段中指定身份验证详细信息或脚本来启用零接触代理。

    • 身份验证详细信息- 按照入门中的说明,指定从 Citrix ADM 的设置代理页面复制的服务 URL激活码。请按以下格式输入详细信息。

      registeragent -serviceurl  -activationcode  

      Agent 在启动期间使用此信息向 ADM 服务自动注册。

    • 脚本-将代理自动注册脚本指定为用户数据。以下是示例脚本:

      #!/var/python/bin/python2.7importosimportrequestsimportjsonimporttimeimportreimportloggingimportlogging.handlersimportboto3''' Overview of the Script: The script helps to register an ADM agent with ADM. Pass it in userdata to make ADM agent in AWS to autoregister on bootup. The workflow is as follows 1) Fetch the ADM service API credentials (ID and secret) from AWS secret store (NOTE: you have to assign IAM role to the ADM Agent that will give permission to fetch secrets from AWS secret store) 2) Login to ADM service with credentials fetched in step 1 3) Call ADM service to fetch credentials (serviceURL and token) for agent registration 4) Calls registration by using the credentials fetched in step 3 '''''' These are the placeholders which you need to replace according to your setup configurations aws_secret_id: Id of the AWS secret where you have stored ADM Credentials The secrets value should be in the following json format { "adm_user_id_key": "YOUR_ID", " adm_user_secret_key": "YOUR_SECRET"} '''aws_secret_id=""adm_ip_or_hostname=".adm.cloud.com"''' Set up a specific logger with your desired output level and log file name '''log_file_name_local=os.path.basename(\_\_file\_\_)LOG_FILENAME='/var/log/'+'bootstrap'+'.log'LOG_MAX_BYTE=50\*1024\*1024LOG_BACKUP_COUNT=20logger=logging.getLogger(\_\_name\_\_)logger.setLevel(logging.DEBUG)logger_handler=logging.handlers.RotatingFileHandler(LOG_FILENAME,maxBytes=LOG_MAX_BYTE,backupCount=LOG_BACKUP_COUNT)logger_fortmater=logging.Formatter(fmt='%(asctime)-2s:%(funcName)30s:%(lineno)4d: [%(levelname)s] %(message)s',datefmt="%Y-%m-%d %H:%M:%S")logger_handler.setFormatter(logger_fortmater)logger.addHandler(logger_handler)classAPIHandlerException(Exception):def\_\_init\_\_(self,error_code,message):self.error_code=error_codeself.message=messagedef\_\_str\_\_(self):returnself.message+". Error code '"+str(self.error_code)+"'"defparse_response(response,url,print_response=True):ifnotresponse.ok:if"reboot"inurl:logger.debug('No response for url: reboot')resp={"errorcode":"500","message":"Error while reading response."}returnrespifprint_response:logger.debug('Response text for %s is %s'%(url,response.text))response=json.loads(response.text)logger.debug("ErrorCode - "+str(response['errorcode'])+". Message -"+str(response['message']))raiseAPIHandlerException(response['errorcode'],str(response['message']))elifresponse.text:ifprint_response:logger.debug('Response text for %s is %s'%(url,response.text))result=json.loads(response.text)if'errorcode'inresultandresult['errorcode']>0:raiseAPIHandlerException(result['errorcode'],str(result['message']))returnresultdef_request(method,url,data=None,headers=None,retry=3,print_response=True):try:response=requests.request(method,url,data=data,headers=headers)result=parse_response(response,url,print_response=print_response)returnresultexcept[requests.exceptions.ConnectionError,requests.exceptions.ConnectTimeout]:ifretry>0:return_request(method,url,data,headers,retry-1,print_response=print_response)else:raiseAPIHandlerException(503,'ConnectionError')exceptrequests.exceptions.RequestExceptionase:logger.debug(str(e))raiseAPIHandlerException(500,str(e))exceptAPIHandlerExceptionase:logger.debug("URL: %s, Error: %s, Message: %s"%(url,e.error_code,e.message))raiseeexceptExceptionase:raiseAPIHandlerException(500,str(e))try:'''Get the AWS Region'''client=boto3.client('s3')my_region=client.meta.region_namelogger.debug("The rgion is %s"%(my_region))'''Creating a Boto cleint session'''session=boto3.session.Session()client=session.client(service_name=“secretsmanager”,region_name=my_region)'''Getting the values stored in the secret with id: '''get_id_value_response=client.get_secret_value(SecretId=aws_secret_id)adm_user_id=json.loads(get_id_value_response["SecretString"])["adm_user_id_key"]adm_user_secret=json.loads(get_id_value_response["SecretString"])["adm_user_secret_key"]exceptExceptionase:logger.debug("Fetching of ADM credentials from AWS secret failed with error: %s"%(str(e)))raisee''' Initializing common ADM API handlers '''mas_common_headers={'Content-Type':"application/json",'Accept-type':"application/json",'Connection':"keep-alive",'isCloud':"true"}''' API to login to the ADM and fetch the Session ID and Tenant ID '''url="https://"+str(adm_ip_or_hostname)+"/nitro/v1/config/login"payload='object={"login":{"ID":"'+adm_user_id+'","Secret":"'+adm_user_secret+'"}}'try:response=_request("POST",url,data=payload,headers=mas_common_headers)sessionid=response["login"][0]["sessionid"]tenant_id=response["login"][0]["tenant_name"]exceptExceptionase:logger.debug("Login call to the ADM failed with error: %s"%(str(e)))raisee''' API to fetch the service URL and Token to be used for registering the agent with the ADM '''mas_common_headers['Cookie']='SESSID='+str(sessionid)url="https://"+str(adm_ip_or_hostname)+"/nitro/v1/config/trust_preauthtoken/"+tenant_id+"?customer="+tenant_idlogger.debug("Fetching Service URL and Token.")try:response=_request("GET",url,data=None,headers=mas_common_headers)service_name=response["trust_preauthtoken"][0]["service_name"]token=response["trust_preauthtoken"][0]["token"]api_gateway_url=response["trust_preauthtoken"][0]["api_gateway_url"]exceptExceptionase:logger.debug("Fetching of the Service URL Passed with error. %s"%(str(e)))raisee''' Running the register agent command using the values we retrieved earlier '''try:registeragent_command="registeragent -serviceurl "+api_gateway_url+" -activationcode "+service_name+";"+tokenfile_run_command="/var/python/bin/python2.7 /mps/register_agent_cloud.py "+registeragent_commandlogger.debug("Executing registeragent command: %s"%(file_run_command))os.system(file_run_command)exceptExceptionase:logger.debug("Agent Registeration failed with error: %s"%(str(e)))raisee<!--NeedCopy-->

      此脚本从 AWS secret 管理器获取身份验证详细信息,然后运行deployment.py脚本以将代理注册到 ADM 服务。

    配置实例详细信息

    注意

    虽然您可以自动分配公有 IP 地址,但也可以分配弹性 IP 地址。如果未配置 NAT Gateway,则需要分配弹性 IP 地址。

    如果此步骤中未设置弹性 IP 地址,您仍然可以在 EC2 控制台上进行设置。您可以创建一个新的弹性 IP 地址,然后使用实例 ID 或 ENI-ID 将其与 ADM Agent 关联。

    单击添加存储空间

  3. 添加存储页面上,配置实例的存储设备设置,然后单击下一步:添加标签

    添加标签

  4. 添加标签页面上,定义实例的标签,然后单击下一步:配置安全组

    配置安全组

  5. 配置安全组页面上,添加允许特定流量进入实例的规则,然后单击查看并启动

    审查和启动

  6. 查看实例启动页面上,查看实例设置,然后单击启动

  7. 选择现有密钥对或创建新密钥对对话框中,创建密钥对。您还可以从现有密钥对中进行选择。

    接受确认,然后单击启动实例

    启动实例

部署过程可能需要大约 10-15 分钟。部署成功完成后,您可以在 AWS 账户上查看 Citrix ADM 代理虚拟机。

在 Amazon Web Services (AWS) 上安装 Citrix ADM 代理