Ejemplo n.º 1
0
    def test_oci_create_subnet(self, mock_init):
        """Test oci create subnet method."""
        mock_init.return_value = None

        client = MagicMock()
        subnet = MagicMock()
        response = MagicMock()
        vcn = MagicMock()
        vcn.id = (
            'ocid1.vcn.oc1..'
            'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
        response.data = subnet

        client.create_subnet_and_wait_for_state.return_value = response

        compartment_id = (
            'ocid1.compartment.oc1..'
            'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')

        cloud = OCICloud(**self.kwargs)
        cloud.vnet_composite_client = client

        result = cloud._create_subnet(compartment_id, 'Omic:PHX-AD-1', vcn,
                                      'subnet-123')
        assert result == subnet
Ejemplo n.º 2
0
    def test_oci_delete_subnet(self, mock_init):
        """Test oci delete subnet method."""
        mock_init.return_value = None

        client = MagicMock()

        cloud = OCICloud(**self.kwargs)
        cloud.vnet_composite_client = client

        subnet_id = (
            'ocid1.subnet.oc1..'
            'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')

        cloud._delete_subnet(subnet_id)
Ejemplo n.º 3
0
    def test_oci_delete_internet_gateway(self, mock_init):
        """Test oci delete internet gateway method."""
        mock_init.return_value = None

        client = MagicMock()

        gateway_id = (
            'ocid1.gateway.oc1..'
            'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')

        cloud = OCICloud(**self.kwargs)
        cloud.vnet_composite_client = client

        cloud._delete_internet_gateway(gateway_id)
Ejemplo n.º 4
0
    def test_oci_clear_route_rules(self, mock_init):
        """Test oci clear route rules method."""
        mock_init.return_value = None

        client = MagicMock()
        vcn = MagicMock()

        cloud = OCICloud(**self.kwargs)
        cloud.vnet_composite_client = client

        vcn.default_route_table_id = (
            'ocid1.routeTable.oc1..'
            'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')

        cloud._clear_route_rules(vcn)
Ejemplo n.º 5
0
    def test_oci_create_internet_gateway(self, mock_init):
        """Test oci create internet gateway method."""
        mock_init.return_value = None

        client = MagicMock()
        vcn = MagicMock()
        route_table = MagicMock()

        vcn.id = (
            'ocid1.vcn.oc1..'
            'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        )
        vcn.default_route_table_id = (
            'ocid1.routeTable.oc1..'
            'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        )

        gateway = MagicMock()
        gateway.id = (
            'ocid1.gateway.oc1..'
            'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        )

        gateway_response = MagicMock()
        gateway_response.data = gateway
        client.create_internet_gateway_and_wait_for_state.return_value = gateway_response  # noqa

        route_table_response = MagicMock()
        route_table_response.data = route_table
        route_table.route_rules = []
        client.get_route_table.return_value = route_table_response

        update_table_response = MagicMock()
        update_table_response.data = []
        client.update_route_table_and_wait_for_state.return_value = update_table_response  # noqa

        cloud = OCICloud(**self.kwargs)
        cloud.vnet_composite_client = client
        cloud.vnet_client = client

        compartment_id = (
            'ocid1.compartment.oc1..'
            'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
        )
        cloud._create_internet_gateway(compartment_id, vcn, 'test-name')
Ejemplo n.º 6
0
    def test_oci_create_vcn(self, mock_init):
        """Test oci create vcn method."""
        mock_init.return_value = None

        client = MagicMock()
        vcn = MagicMock()
        response = MagicMock()
        response.data = vcn

        client.create_vcn_and_wait_for_state.return_value = response

        cloud = OCICloud(**self.kwargs)
        cloud.compartment_id = (
            'ocid1.compartment.oc1..'
            'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')
        cloud.vnet_composite_client = client

        result = cloud._create_vcn('vcn-123')
        assert result == vcn