Example #1
0
    def test_0076_add_static_ip_pool(self):
        vdc = Environment.get_test_vdc(TestNetwork._client)
        org_vdc_routed_nw = vdc.get_routed_orgvdc_network(
            TestNetwork._routed_org_vdc_network_name)
        vdcNetwork = VdcNetwork(TestNetwork._client,
                                resource=org_vdc_routed_nw)
        result = vdcNetwork.add_static_ip_pool_and_dns([TestNetwork._ip_range],
                                                       TestNetwork._dns1,
                                                       TestNetwork._dns2,
                                                       TestNetwork._dns_suffix)

        task = TestNetwork._client.get_task_monitor().wait_for_success(
            task=result)
        self.assertEqual(task.get('status'), TaskStatus.SUCCESS.value)

        result = vdcNetwork.add_static_ip_pool_and_dns(None, TestNetwork._dns1,
                                                       TestNetwork._dns2,
                                                       TestNetwork._dns_suffix)
        task = TestNetwork._client.get_task_monitor().wait_for_success(
            task=result)
        self.assertEqual(task.get('status'), TaskStatus.SUCCESS.value)

        result = vdcNetwork.add_static_ip_pool_and_dns(None, TestNetwork._dns1)
        task = TestNetwork._client.get_task_monitor().wait_for_success(
            task=result)
        self.assertEqual(task.get('status'), TaskStatus.SUCCESS.value)

        result = vdcNetwork.add_static_ip_pool_and_dns(None, None, None,
                                                       TestNetwork._dns_suffix)
        task = TestNetwork._client.get_task_monitor().wait_for_success(
            task=result)
        self.assertEqual(task.get('status'), TaskStatus.SUCCESS.value)
        # Verify
        vdcNetwork.reload()
        vdc_routed_nw = vdcNetwork.get_resource()
        ip_scope = vdc_routed_nw.Configuration.IpScopes.IpScope
        ip_ranges = ip_scope.IpRanges.IpRange
        match_found = False
        for ip_range in ip_ranges:
            if (ip_range.StartAddress + '-' + ip_range.EndAddress) == \
                    TestNetwork._ip_range:
                match_found = True
        self.assertTrue(match_found)
        self.assertTrue(ip_scope.Dns1, TestNetwork._dns1)
        self.assertTrue(ip_scope.Dns2, TestNetwork._dns2)
        self.assertTrue(ip_scope.DnsSuffix, TestNetwork._dns_suffix)
Example #2
0
def edit_routed_vdc_network(ctx,
                            name,
                            new_vdc_routed_nw_name,
                            description=None,
                            is_shared=None):
    try:
        vdc = _get_vdc_ref(ctx)
        client = ctx.obj['client']
        routed_network = vdc.get_routed_orgvdc_network(name)
        is_shared if is_shared is not None else routed_network.IsShared
        vdcNetwork = VdcNetwork(client, resource=routed_network)
        task = vdcNetwork.edit_name_description_and_shared_state(
            new_vdc_routed_nw_name, description, is_shared)

        stdout(task, ctx)
        stdout('Edit of routed org vdc network successfull.', ctx)
    except Exception as e:
        stderr(e, ctx)
Example #3
0
    def test_0080_routed_vdc_network_metadata(self):
        vdc = Environment.get_test_vdc(TestNetwork._client)
        org_vdc_routed_nw = vdc.get_routed_orgvdc_network(
            TestNetwork._routed_org_vdc_network_name)
        vdc_network = VdcNetwork(TestNetwork._client,
                                 resource=org_vdc_routed_nw)

        # Test data
        metadata_key = "test-key1"
        metadata_value = "test-value1"
        updated_metadata_value = "updated-" + metadata_value

        # Testing add, update and delete metadata
        TestNetwork._add_routed_vdc_network_metadata(self, vdc_network,
                                                     metadata_key,
                                                     metadata_value)
        TestNetwork._update_routed_vdc_network_metadata(
            self, vdc_network, metadata_key, updated_metadata_value)
        TestNetwork._delete_routed_vcd_network_metadata(
            self, vdc_network, metadata_key)
Example #4
0
    def __create_routed_ovdc_network(self):
        """Creates a routed org vdc network.

        :raises: Exception: if the class variable _ovdc_href is not populated.
        """
        vdc_reource = TestIpSecVpn._vdc_resource
        vdc = VDC(TestIpSecVpn._client, resource=vdc_reource)
        routednet = vdc.create_routed_vdc_network(
            network_name=TestIpSecVpn._routed_network_name,
            gateway_name=TestIpSecVpn._gateway_name,
            network_cidr=TestIpSecVpn._routed_orgvdc_network_gateway_ip,
            description='org vdc network description')
        TestIpSecVpn._client.get_task_monitor() \
            .wait_for_success(task=routednet.Tasks.Task[0])

        TestIpSecVpn._routednet_href = routednet.get('href')
        TestIpSecVpn._routednet_obj = VdcNetwork(
            TestIpSecVpn._client, href=TestIpSecVpn._routednet_href)
        TestIpSecVpn._routednet_resource = TestIpSecVpn.\
            _routednet_obj.get_resource()
Example #5
0
    def test_0075_edit_name_description_and_shared_state_for_routed_network(
            self):
        vdc = Environment.get_test_vdc(TestNetwork._client)
        org_vdc_routed_nw = vdc.get_routed_orgvdc_network(
            TestNetwork._routed_org_vdc_network_name)
        vdcNetwork = VdcNetwork(TestNetwork._client,
                                resource=org_vdc_routed_nw)
        result = vdcNetwork.edit_name_description_and_shared_state(
            TestNetwork._routed_org_vdc_network_new_name, 'Test '
            'Description', True)

        task = TestNetwork._client.get_task_monitor().wait_for_success(
            task=result)
        self.assertEqual(task.get('status'), TaskStatus.SUCCESS.value)
        # Resetting to original name
        result = vdcNetwork.edit_name_description_and_shared_state(
            TestNetwork._routed_org_vdc_network_name, None, False)

        task = TestNetwork._client.get_task_monitor().wait_for_success(
            task=result)
        self.assertEqual(task.get('status'), TaskStatus.SUCCESS.value)
Example #6
0
def list_metadata(ctx, name):
    try:
        vdc = _get_vdc_ref(ctx)
        client = ctx.obj['client']
        routed_network = vdc.get_routed_orgvdc_network(name)
        vdcNetwork = VdcNetwork(client, resource=routed_network)
        metadata = vdcNetwork.get_all_metadata()
        result = []
        for metadata_entry in metadata.MetadataEntry:
            visibility = MetadataVisibility.READ_WRITE.value
            if hasattr(metadata_entry, 'Domain'):
                visibility = metadata_entry.Domain.get('visibility')
            type = metadata_entry.TypedValue.get('{' + NSMAP['xsi'] + '}type')
            result.append({
                'Name': metadata_entry.Key,
                'Value': metadata_entry.TypedValue.Value,
                'Type': type,
                'User access': visibility
            })
        stdout(result, ctx)
    except Exception as e:
        stderr(e, ctx)
Example #7
0
    def __convert_to_distributed_interface(self, client):
        self.__convert_enable_dr_in_gateway_using_sys_client(True)

        vdc = Environment.get_test_vdc(client)
        org_vdc_routed_nw = vdc.get_routed_orgvdc_network(
            TestNetwork._routed_org_vdc_network_name)
        vdc_network = VdcNetwork(client, resource=org_vdc_routed_nw)

        result = vdc_network.convert_to_distributed_interface()
        self.__wait_for_success(client, result)

        # Verify
        vdc_network.reload_admin()
        reloaded_vdc_network = vdc_network.admin_resource
        self.assertTrue(
            reloaded_vdc_network.Configuration.DistributedInterface)

        # Revert
        result = vdc_network.convert_to_internal_interface()
        self.__wait_for_success(client, result)

        # Disable the distributed routing on gateway
        self.__convert_enable_dr_in_gateway_using_sys_client(False)
Example #8
0
 def test_0078_remove_static_ip_pool(self):
     vdc = Environment.get_test_vdc(TestNetwork._client)
     org_vdc_routed_nw = vdc.get_routed_orgvdc_network(
         TestNetwork._routed_org_vdc_network_name)
     vdcNetwork = VdcNetwork(TestNetwork._client,
                             resource=org_vdc_routed_nw)
     result = vdcNetwork.remove_static_ip_pool(TestNetwork._new_ip_range)
     task = TestNetwork._client.get_task_monitor().wait_for_success(
         task=result)
     self.assertEqual(task.get('status'), TaskStatus.SUCCESS.value)
     # Verification
     vdcNetwork.reload()
     vdc_routed_nw = vdcNetwork.get_resource()
     ip_scope = vdc_routed_nw.Configuration.IpScopes.IpScope
     # IPRanges element will be missing if there was only one IP range
     if not hasattr(ip_scope, 'IpRanges'):
         return
     ip_ranges = ip_scope.IpRanges.IpRange
     match_found = False
     for ip_range in ip_ranges:
         if (ip_range.StartAddress + '-' + ip_range.EndAddress) == \
                 TestNetwork._new_ip_range:
             match_found = True
     self.assertFalse(match_found)