Fixes lp915212

Adds gateway as an optional paramter to the ip block creation

Change-Id: Ie6c80a0712b8dd6f48840efab7af2e18b6cedbf9
This commit is contained in:
Matt Dietz 2012-03-09 17:11:16 -06:00
parent 04c9548d53
commit 052b7fe901
3 changed files with 23 additions and 2 deletions

View File

@ -122,11 +122,13 @@ class IpBlockClient(BaseClient):
auth_client,
tenant_id)
def create(self, type, cidr, network_id=None, policy_id=None):
def create(self, type, cidr, network_id=None, policy_id=None,
gateway=None):
return self.resource.create(type=type,
cidr=cidr,
network_id=network_id,
policy_id=policy_id)
policy_id=policy_id,
gateway=gateway)
def list(self):
return self.resource.all()

View File

@ -16,6 +16,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import mock
from melange.client import ipam_client
from melange.client import tests
@ -34,3 +36,19 @@ class TestFactory(tests.BaseTest):
"Factory has no attribute "
"non_existent_client",
lambda: factory.non_existent_client)
class TestIpBlockCreate(tests.BaseTest):
def test_create_ip_block_with_gateway(self):
factory = ipam_client.Factory("host", "8080")
client = ipam_client.IpBlockClient(factory._client,
factory._auth_client, 'fake')
with mock.patch('melange.client.ipam_client.Resource.create') as patch:
client.create(type='public', cidr='10.0.0.0/24',
gateway='10.0.0.1')
patch.assert_called_with(type='public',
cidr='10.0.0.0/24',
network_id=None,
policy_id=None,
gateway='10.0.0.1')

View File

@ -2,6 +2,7 @@
distribute>=0.6.24
coverage
mock
mox
nose
nosexcover