コード例 #1
0
def main():
    """Useful to run this from the command line so we can see the input and
    output of the translation when debugging.
    """
    mock_factory = mox.Mox()
    neutron_client = mock_factory.CreateMock(
        neutronclient.v2_0.client.Client)
    neutron_client.list_networks().InAnyOrder(1).AndReturn(network1)
    neutron_client.list_ports().InAnyOrder(1).AndReturn(port_response)
    neutron_client.list_routers().InAnyOrder(1).AndReturn(router_response)
    neutron_client.list_security_groups().InAnyOrder(1).AndReturn(
        security_group_response)
    neutron_client.list_networks().InAnyOrder(2).AndReturn(network2)
    neutron_client.list_ports().InAnyOrder(2).AndReturn(port_response)
    neutron_client.list_routers().InAnyOrder(2).AndReturn(router_response)
    neutron_client.list_security_groups().InAnyOrder(2).AndReturn(
        security_group_response)
    mock_factory.ReplayAll()

    args = helper.datasource_openstack_args()
    args['poll_time'] = 0
    args['client'] = neutron_client
    driver = NeutronDriver(name="testneutron", args=args)

    driver.update_from_datasource()
    print "Original api data"
    print str(driver.raw_state)
    print "Resulting state"
    print str(driver.state)

    driver.update_from_datasource()
    print "Original api data"
    print str(driver.raw_state)
    print "Resulting state"
    print str(driver.state)