NetScaler コンソールサービス

Amazon Web Services (AWS) にNetScalerエージェントをインストールする

NetScalerエージェントは、NetScaler Consoleと、データセンターまたはクラウドで検出されたインスタンスとの間の仲介役として機能します。

前提条件

Amazon GUIを使用してAmazon Web Services(AWS)仮想プライベートクラウド(VPC)内でNetScalerエージェントAMIを起動するには、以下が必要です。

  • AWSアカウント

  • AWS 仮想プライベートクラウド(VPC)

  • IAMアカウント

  • NetScalerエージェント仮想マシンをプロビジョニングする前に、シトリックスでは、セキュリティグループ、仮想プライベートネットワーク、キーペア、サブネット、およびその他のエンティティを作成することをお勧めします。したがって、ネットワーク情報は、プロビジョニング中に利用できます。

  • NetScalerエージェントがNetScalerコンソールおよびNetScalerインスタンスと通信するには、推奨ポートが開いていることを確認してください。 NetScalerエージェントのポート要件の詳細については、「ポート」を参照してください

NetScaler エージェントを AWS にインストールするには:

  1. AWS 認証情報を使用して AWS マーケットプレイスにログオンします

  2. 検索フィールドに「 NetScaler agent」と入力してNetScalerエージェントAMIを検索し 、「実行」をクリックます。

  3. 検索結果ページで、 使用可能なリストからNetScaler Console外部エージェントAMIをクリックします 。

  4. NetScalerコンソールの外部エージェントAMIページで 、「 購読を続ける」をクリックします。

    NetScaler コンソールの外部エージェント

  5. サブスクリプションが正常に完了したら、[ 構成に進む] をクリックします。

    設定を続ける

  6. [ このソフトウェアの構成 ] ページで、次の操作を行います。

    1. フルフィルメントオプションリストからAMIを選択します

    2. ソフトウェアバージョンリストから最新のNetScalerエージェントバージョンを選択します 。

    3. [地域] リストから地域を選択します

    4. [ 続行] をクリックして起動

      起動を続けてください

  7. [ このソフトウェアの起動 ]ページには、NetScalerエージェントを登録するための2つのオプションがあります。

    1. ウェブサイトからの起動

    2. EC2 で起動

      EC2 で起動

ウェブサイトからの起動

Web サイトから起動するには、次を選択します。

  1. EC2 インスタンスタイプリストの EC2 インスタンスタイプ

  2. [VPC 設定] リストから VPC 。[ EC2 で VPC を作成 ] をクリックして、ソフトウェアの VPC を作成します。

  3. [ サブネット設定] リストのサブネット。VPC を選択した後にサブネットを作成するには、[EC2 にサブネットを作成] をクリックします。

  4. [ セキュリティグループ設定] リストからファイアウォールのセキュリティグループ出品者設定に基づいて新規作成をクリックし 、セキュリティグループを作成します。

  5. [Key Pair Settings] リストからアクセスセキュリティを確保するためのキーペア 。[ EC2 でキーペアを作成する ] をクリックして、ソフトウェアのキーペアを作成します。

  6. [ 起動] をクリックします

    ウェブサイトを立ち上げる

  7. ウェブサイトからの起動は成功しました。

    ウェブサイトからの起動は成功しました

    展開プロセスには約 10 ~ 15 分かかる場合があります。デプロイが正常に完了すると、AWSアカウントでNetScalerエージェント仮想マシンを表示できます。

  8. エージェントが展開されたら、NetScalerエージェントに名前を割り当てます。

  9. エージェントが起動して実行されたら、NetScalerエージェントにエラスティックIPアドレスを割り当てます。

    エラスティックIPアドレスにより、NetScalerエージェントはNetScalerコンソールと通信できます。ただし、トラフィックをインターネットにルーティングするように NAT ゲートウェイを設定している場合は、Elastic IP アドレスは必要ありません。

  10. SSHクライアントを使用して、NetScalerエージェントにログオンします。

    :次のいずれかの方法でNetScalerエージェントにログオンできます。

    • nsrecoverをユーザー名として、AWS インスタンス ID をパスワードとして使用します。

    • nsrootをユーザー名として使用し、有効なキーペアをパスワードとして使用します。

  11. 次のコマンドを入力して、展開画面を起動します。 deployment_type.py

  12. 「はじめに」の指示に従って、NetScaler Consoleの[ エージェントの設定 ] ページからコピーして保存したサービスURLとアクティベーションコードを入力します 。エージェントは、サービス URL を使用してサービスを検索し、アクティベーションコードを使用してサービスに登録します。

    NetScaler コンソールの導入

エージェントの登録に成功すると、エージェントは再起動してインストールプロセスを完了します。

エージェントが再起動したら、NetScaler Consoleにアクセスし、[ エージェントの設定 ]ページの[ 検出されたエージェント]でエージェントの状態を確認します。

EC2 で起動

EC2で起動するには、[ アクションの選択] リストから [ EC2 経由で起動 ] を選択し、[Launch] をクリックします。

  1. [ インスタンスタイプの選択 ] ページで、インスタンスを選択し、[ 次へ:インスタンスの詳細の設定] をクリックします。

    インスタンスの詳細を設定する

  2. [ インスタンスの詳細の設定 ] ページで、必要なパラメータを指定します。

    [ 詳細情報 ] セクションで、[ User data ] フィールドに認証の詳細またはスクリプトを指定して、ゼロタッチエージェントを有効にできます。

    • 認証の詳細-「はじめに」の指示に従って、NetScaler Consoleの「 エージェントの設定 」 ページからコピーしたサービスURLアクティベーションコードを指定します 。次の形式で詳細を入力します。

       registeragent -serviceurl <apigatewayurl> -activationcode <activationcodevalue>
       <!--NeedCopy-->
      

      エージェントはこの情報を使用して、起動時にNetScaler Consoleに自動登録します。

    • スクリプト :ユーザーデータとしてエージェント自動登録スクリプトを指定します。スクリプトの例を次に示します。

       #!/var/python/bin/python2.7
       import os
       import requests
       import json
       import time
       import re
       import logging
       import logging.handlers
       import boto3
      
       '''
       Overview of the Script:
       The script helps to register a NetScaler agent with NetScaler Console. Pass it in userdata to make NetScaler agent in AWS to autoregister on bootup. The workflow is as follows
       1)  Fetch the NetScaler Console API credentials (ID and secret) from AWS secret store (NOTE: you have to assign IAM role to the NetScaler agent that will give permission to fetch secrets from AWS secret store)
       2)  Login to NetScaler Console with credentials fetched in step 1
       3)  Call NetScaler Console 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 NetScaler Console 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 = "<AWS_secret_id>"
       adm_ip_or_hostname = "<YOUR_ADM_POP>.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\*1024
       LOG_BACKUP_COUNT = 20
      
       logger = 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)
      
       class APIHandlerException(Exception):
           def \_\_init\_\_(self, error_code, message):
               self.error_code = error_code
               self.message = message
      
           def \_\_str\_\_(self):
               return self.message + ". Error code '" + str(self.error_code) + "'"
      
       def parse_response(response, url, print_response=True):
           if not response.ok:
               if "reboot" in url:
                   logger.debug('No response for url: reboot')
                   resp = {"errorcode": "500", "message": "Error while reading response."}
                   return resp
      
               if print_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']))
               raise APIHandlerException(response['errorcode'], str(response['message']))
           elif response.text:
               if print_response:
                   logger.debug('Response text for %s is %s' % (url, response.text))
      
               result = json.loads(response.text)
               if 'errorcode' in result and result['errorcode'] > 0:
                   raise APIHandlerException(result['errorcode'], str(result['message']))
               return result
      
       def _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)
               return result
           except [requests.exceptions.ConnectionError, requests.exceptions.ConnectTimeout]:
               if retry > 0:
                   return _request(method, url, data, headers, retry-1, print_response=print_response)
               else:
                   raise APIHandlerException(503, 'ConnectionError')
           except requests.exceptions.RequestException as e:
               logger.debug(str(e))
               raise APIHandlerException(500, str(e))
           except APIHandlerException as e:
               logger.debug("URL: %s, Error: %s, Message: %s" % (url, e.error_code, e.message))
               raise e
           except Exception as e:
               raise APIHandlerException(500, str(e))
      
       try:
           '''Get the AWS Region'''
           client = boto3.client('s3')
           my_region = client.meta.region_name
           logger.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: <aws_secret_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"]
      
       except Exception as e:
           logger.debug("Fetching of NetScaler Console credentials from AWS secret failed with error: %s" % (str(e)))
           raise e
      
       '''
       Initializing common NetScaler Console API handlers
       '''
       mas_common_headers = {
           'Content-Type': "application/json",
           'Accept-type': "application/json",
           'Connection': "keep-alive",
           'isCloud': "true"
       }
      
       '''
       API to login to the NetScaler Console 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"]
       except Exception as e:
           logger.debug("Login call to the NetScaler Console failed with error: %s" % (str(e)))
           raise e
      
       '''
       API to fetch the service URL and Token to be used for registering the agent with the NetScaler Console
       '''
       mas_common_headers['Cookie'] = 'SESSID=' + str(sessionid)
       url = "https://" + str(adm_ip_or_hostname) + "/nitro/v1/config/trust_preauthtoken/" + tenant_id +"?customer="+ tenant_id
       logger.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"]
       except Exception as e:
           logger.debug("Fetching of the Service URL Passed with error. %s" % (str(e)))
           raise e
      
       '''
       Running the register agent command using the values we retrieved earlier
       '''
       try:
           registeragent_command = "registeragent -serviceurl "+api_gateway_url+" -activationcode "+service_name+";"+token
           file_run_command = "/var/python/bin/python2.7 /mps/register_agent_cloud.py "+registeragent_command
           logger.debug("Executing registeragent command: %s" % (file_run_command))
           os.system(file_run_command)
       except Exception as e:
           logger.debug("Agent Registeration failed with error: %s" % (str(e)))
               raise e
       <!--NeedCopy-->
      

      このスクリプトは、AWSシークレットマネージャーから認証の詳細を取得し、 スクリプトを実行しdeployment.pyてエージェントをNetScaler Consoleに登録します。

    インスタンスの詳細を設定する

    パブリック IP アドレスを自動割り当てできますが、Elastic IP アドレスを割り当てることもできます。NAT Gatewayが設定されていない場合は、Elastic IP アドレスを割り当てる必要があります。

    このステップで Elastic IP アドレスが設定されていない場合でも、EC2 コンソールで行うことができます。インスタンスIDまたはENI-IDを使用して、新しいエラスティックIPアドレスを作成し、それをNetScalerエージェントに関連付けることができます。

    [ ストレージの追加] をクリックします。

  3. [ Add Storage ] ページで、インスタンスのストレージデバイス設定を構成し、[ 次へ:Add Tags] をクリックします。

    タグを追加する

  4. [ Add Tags ] ページで、インスタンスのタグを定義し、[ 次へ:セキュリティグループの設定] をクリックします。

    セキュリティグループの設定

  5. [ Configure Security Group ] ページで、インスタンスへの特定のトラフィックを許可するルールを追加し、[ Review and Launch] をクリックします。

    確認して起動

  6. [ Review Instance Launch ] ページで、インスタンスの設定を確認し、[ Launch] をクリックします。

  7. [ 既存のキーペアの選択または新しいキーペアの作成 ] ダイアログボックスで、キーペアを作成します。既存のキーペアから選択することもできます。

    確認を受け入れ、[ Launch Instances] をクリックします。

    インスタンスの起動

展開プロセスには約 10 ~ 15 分かかる場合があります。デプロイが正常に完了すると、AWSアカウントでNetScalerエージェント仮想マシンを表示できます。

Amazon Web Services (AWS) にNetScalerエージェントをインストールする