def __create_advanced_gateway(self):
        """Creates a gateway."""

        ext_config = TestIpSecVpn._config['external_network']
        vdc_reource = TestIpSecVpn._vdc_resource
        api_version = TestIpSecVpn._config['vcd']['api_version']
        vdc = VDC(TestIpSecVpn._client, resource=vdc_reource)
        gateway = vdc.get_gateway(TestIpSecVpn._gateway_name)
        if self.__does_exist_gateway(TestIpSecVpn._gateway_name):
            return

        if float(api_version) <= float(
                ApiVersion.VERSION_30.value):
            gateway = vdc.create_gateway_api_version_30(
                TestIpSecVpn._gateway_name, [ext_config['name']])
        elif float(api_version) == float(ApiVersion.VERSION_31.value):
            gateway = vdc.create_gateway_api_version_31(
                TestIpSecVpn._gateway_name,
                [ext_config['name']],
                should_create_as_advanced=True)
        elif float(api_version) >= float(ApiVersion.VERSION_32.value):
            gateway = vdc.create_gateway_api_version_32(
                TestIpSecVpn._gateway_name, [ext_config['name']],
                should_create_as_advanced=True)

        TestIpSecVpn._client.get_task_monitor(). \
            wait_for_success(task=gateway.Tasks.Task[0])
        TestIpSecVpn._gateway_href = gateway.get('href')
        TestIpSecVpn._gateway_obj = Gateway(TestIpSecVpn._client,
                                            href=TestIpSecVpn._gateway_href)
        TestIpSecVpn._gateway_resource = TestIpSecVpn. \
            _gateway_obj.get_resource()
Beispiel #2
0
    def __create_advanced_gateway(self):
        """Creates a gateway."""

        ext_config = TestIpSecVpn._config['external_network']
        vdc_reource = TestIpSecVpn._vdc_resource
        api_version = TestIpSecVpn._config['vcd']['api_version']
        vdc = VDC(TestIpSecVpn._client, resource=vdc_reource)
        gateway = vdc.get_gateway(TestIpSecVpn._gateway_name)
        if self.__does_exist_gateway(TestIpSecVpn._gateway_name):
            return

        if float(api_version) <= float(
                ApiVersion.VERSION_30.value):
            gateway = vdc.create_gateway_api_version_30(
                TestIpSecVpn._gateway_name, [ext_config['name']])
        elif float(api_version) == float(ApiVersion.VERSION_31.value):
            gateway = vdc.create_gateway_api_version_31(
                TestIpSecVpn._gateway_name,
                [ext_config['name']],
                should_create_as_advanced=True)
        elif float(api_version) >= float(ApiVersion.VERSION_32.value):
            gateway = vdc.create_gateway_api_version_32(
                TestIpSecVpn._gateway_name, [ext_config['name']],
                should_create_as_advanced=True)

        TestIpSecVpn._client.get_task_monitor(). \
            wait_for_success(task=gateway.Tasks.Task[0])
        TestIpSecVpn._gateway_href = gateway.get('href')
        TestIpSecVpn._gateway_obj = Gateway(TestIpSecVpn._client,
                                            href=TestIpSecVpn._gateway_href)
        TestIpSecVpn._gateway_resource = TestIpSecVpn. \
            _gateway_obj.get_resource()
 def __does_exist_gateway(self, gateway_name):
     vdc = VDC(TestIpSecVpn._client, resource=TestIpSecVpn._vdc_resource)
     gateway = vdc.get_gateway(TestIpSecVpn._gateway_name)
     if gateway:
         TestIpSecVpn._gateway_resource = gateway
         TestIpSecVpn._gateway_href = gateway.get('href')
         TestIpSecVpn._gateway_obj = Gateway(
             TestIpSecVpn._client, href=TestIpSecVpn._gateway_href)
         return True
     else:
         return False
Beispiel #4
0
 def __does_exist_gateway(self, gateway_name):
     vdc = VDC(TestIpSecVpn._client, resource=TestIpSecVpn._vdc_resource)
     gateway = vdc.get_gateway(TestIpSecVpn._gateway_name)
     if gateway:
         TestIpSecVpn._gateway_resource = gateway
         TestIpSecVpn._gateway_href = gateway.get('href')
         TestIpSecVpn._gateway_obj = Gateway(
             TestIpSecVpn._client, href=TestIpSecVpn._gateway_href)
         return True
     else:
         return False