network: update API.md

Define get and create API for networks collection.
Define get, delete, activate and deactivate API for network resource.

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
network: update controller

define Networks collection and Network resource according to API.md

update API.json

Do not add a pattern for subnet parameter.
we can define it as follow:
192.168.0.1/24 or 192.168.0.1/255.255.255.0
"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)/
(((254|252|248|240|224|192|128|0)\.0\.0\.0)|
 (255\.(254|252|248|240|224|192|128|0)\.0\.0)|
 (255\.255\.(254|252|248|240|224|192|128|0)\.0)|
 (255\.255\.255\.(254|252|248|240|224|192|128|0))|
 (30|[1-2]\d|[2-9]))$"

A invalid parameter {"subnet": "192.168.0.1/255.255.255.1"},
json-schema will report an error like this:
Invalid parameter: '192.168.1.123/34' does not match
'^((2[0-4]\\d|25[0-5]|[01]?\\d\\d?)\\.){3}(2[0-4]\\d|25[0-5]|[01]?\\d\\d?)/
(((254|252|248|240|224|192|128|0)\\.0\\.0\\.0)|
 (255\\.(254|252|248|240|224|192|128|0)\\.0\\.0)|
 (255\\.255\\.(254|252|248|240|224|192|128|0)\\.0)|
 (255\\.255\\.255\\.(254|252|248|240|224|192|128|0))|
 (30|[0-2]?\\d))$'

This message is not friendly to user.

We can use ip-address format in draft3 for IP, that is same with ipV4 in
draft4.
But it does not work.
The json-schema doc says:
format support is optional, and as such other tools may ignore this keyword:
this can lead to a different validation outcome for the same data;

I also try ip-address format, it do can not work.

Also there is not a format to verify netmask in json-schema draft3 and draft4.
So json-schema can not easy to verify subnet.

json-schema doc says:
Not all constraints can be expressed.

So these checks are left to kimchi applications.
And python netaddr can verify subnet easily.

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
network: generate network xml and testcast for it

Define a network xml template.
Also a test case for this xml template.

info: http://libvirt.org/formatnetwork.html

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
network: update model

model implements these fuctions:
list all netwoks
lookup a network
create/delete a network
activate/deactivate a network

This patch can also add a new file to find a free subnet
for isolated and NAT networks.

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
network: update makefile, spec file and README

Add the extra python lib in spec file and README
add the new pythons files in source dist list of makefile

split this as individual patch.
come into notice that every new file we should put in the dist list
and every new python lib we should update spec file and README

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
network: update mockmodel

list netwoks
lookup network
create/delete network
activate/deactivate network

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
network: update test case

test model and rest

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>
Authentication is required to access networks

As the other collections, authentication is required.

Signed-off-by: ShaoHe Feng <shaohef@linux.vnet.ibm.com>