You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2013/01/21 17:57:21 UTC

Network API Models - RFC

[patches also available from http://tracker.deltacloud.org/set/263]

Initial implementation for networks - in particular seeking feedback
with respect to models and how they 'sit' for vsphere/rhevm (I've taken
CIMI, EC2 VPC and Openstack into consideration already). Initial
implementation of 'networks' collection for EC2 driver (create, list, show
and destroy VPC).

marios

[PATCH 1/3] Network API Models

Posted by ma...@redhat.com.
From: marios <ma...@redhat.com>


Signed-off-by: marios <ma...@redhat.com>
---
 server/lib/deltacloud/models.rb         |  3 +++
 server/lib/deltacloud/models/network.rb | 25 +++++++++++++++++++++++++
 server/lib/deltacloud/models/port.rb    | 27 +++++++++++++++++++++++++++
 server/lib/deltacloud/models/subnet.rb  | 26 ++++++++++++++++++++++++++
 4 files changed, 81 insertions(+)
 create mode 100644 server/lib/deltacloud/models/network.rb
 create mode 100644 server/lib/deltacloud/models/port.rb
 create mode 100644 server/lib/deltacloud/models/subnet.rb

diff --git a/server/lib/deltacloud/models.rb b/server/lib/deltacloud/models.rb
index e6020e6..1fb3b27 100644
--- a/server/lib/deltacloud/models.rb
+++ b/server/lib/deltacloud/models.rb
@@ -32,3 +32,6 @@ require_relative 'models/realm'
 require_relative 'models/state_machine'
 require_relative 'models/storage_snapshot'
 require_relative 'models/storage_volume'
+require_relative 'models/network'
+require_relative 'models/subnet'
+require_relative 'models/port'
diff --git a/server/lib/deltacloud/models/network.rb b/server/lib/deltacloud/models/network.rb
new file mode 100644
index 0000000..e5fdb6b
--- /dev/null
+++ b/server/lib/deltacloud/models/network.rb
@@ -0,0 +1,25 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+class Network < BaseModel
+
+  attr_accessor :name
+  attr_accessor :subnets
+  attr_accessor :address_block
+  attr_accessor :ports
+  attr_accessor :state
+
+end
diff --git a/server/lib/deltacloud/models/port.rb b/server/lib/deltacloud/models/port.rb
new file mode 100644
index 0000000..f6d2036
--- /dev/null
+++ b/server/lib/deltacloud/models/port.rb
@@ -0,0 +1,27 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+class Port < BaseModel
+
+  attr_accessor :name
+  attr_accessor :attachment
+  attr_accessor :network
+  attr_accessor :mac_address
+  attr_accessor :ip_address
+  attr_accessor :state
+  attr_accessor :type
+
+end
diff --git a/server/lib/deltacloud/models/subnet.rb b/server/lib/deltacloud/models/subnet.rb
new file mode 100644
index 0000000..fff80f4
--- /dev/null
+++ b/server/lib/deltacloud/models/subnet.rb
@@ -0,0 +1,26 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+class Subnet < BaseModel
+
+  attr_accessor :name
+  attr_accessor :network
+  attr_accessor :address_block
+  attr_accessor :ports
+  attr_accessor :state
+  attr_accessor :type
+
+end
-- 
1.7.11.7


[PATCH 3/3] Networks initial impl. for EC2 driver

Posted by ma...@redhat.com.
From: marios <ma...@redhat.com>


Signed-off-by: marios <ma...@redhat.com>
---
 server/lib/deltacloud/drivers/base_driver.rb    |  3 +++
 server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 35 +++++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/server/lib/deltacloud/drivers/base_driver.rb b/server/lib/deltacloud/drivers/base_driver.rb
index 4496a46..9ac38d4 100644
--- a/server/lib/deltacloud/drivers/base_driver.rb
+++ b/server/lib/deltacloud/drivers/base_driver.rb
@@ -256,6 +256,9 @@ module Deltacloud
       addresses(credentials, opts).first if has_capability?(:addresses)
     end
 
+    def network(credentials, opts={})
+      networks(credentials, opts).first if has_capability?(:networks)
+    end
 
     MEMBER_SHOW_METHODS = [ :realm, :image, :instance, :storage_volume, :bucket, :blob,
                             :key, :firewall ] unless defined?(MEMBER_SHOW_METHODS)
diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index 9c10ff8..115180d 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -826,6 +826,33 @@ module Deltacloud
           end
         end
 
+        #Deltacloud Networks == Amazon VPC
+        def networks(credentials, opts={})
+          ec2 = new_client(credentials)
+          networks=[]
+          safely do
+            ec2.describe_vpcs.each do |vpc|
+              networks << convert_vpc(vpc)
+            end
+          end
+          networks = filter_on(networks, :id, opts)
+        end
+
+        def create_network(credentials, opts={})
+          ec2 = new_client(credentials)
+          safely do
+            network = ec2.create_vpc(opts[:address_block]).first
+            convert_vpc(network)
+          end
+        end
+
+        def destroy_network(credentials, opts={})
+          ec2 = new_client(credentials)
+          safely do
+            ec2.delete_vpc(opts[:id])
+          end
+        end
+
         def providers(credentials, opts={})
           ec2 = new_client(credentials)
           @providers ||= ec2.describe_regions.map{|r| Provider.new( {:id=>r, :name=>r,
@@ -1145,6 +1172,14 @@ module Deltacloud
           end
         end
 
+        def convert_vpc(vpc)
+          Network.new({ :id => vpc[:vpc_id],
+                        :name => vpc[:vpc_id],
+                        :state=> vpc[:state],
+                        :address_block=> vpc[:cidr_block] })
+        end
+
+
         exceptions do
           on /(AuthFailure|InvalidAccessKeyId)/ do
             status 401
-- 
1.7.11.7


Re: Network API Models - RFC

Posted by "marios@redhat.com" <ma...@redhat.com>.
On 13/02/13 10:31, Jan Provazník wrote:
> On 01/21/2013 05:57 PM, marios@redhat.com wrote:
>> [patches also available from http://tracker.deltacloud.org/set/263]
>>
>> Initial implementation for networks - in particular seeking feedback
>> with respect to models and how they 'sit' for vsphere/rhevm (I've taken
>> CIMI, EC2 VPC and Openstack into consideration already). Initial
>> implementation of 'networks' collection for EC2 driver (create, list,
>> show
>> and destroy VPC).
>>
>> marios
>>
> 
> Hi,
> overall, the models in this patchset look reasonable to me. After
> discussing this topic with Heat/PM and some other people, here are my
> findings:
> 
> 1) There are 2 levels of networking support we would like to have:
>   a) be able to specify an existing network (or subnet?) when
>      launching an instance
>   b) be able to dynamically create whole network/subnets or firewall
>      rules when launching a deployment (cloud formation)
> 
> 2) For RHEV it is currently not possible to achieve 1b. Network creation
> is admin task. Nice description is here [1]. Good news is that RHEV will
> probably support Quantum networking in future, currently there is POC
> where Quantum network can be used as an external network in ovirt [2]
> (note that dynamic network creation is not possible in this POC too).
> Will do more investigation about Quantum plans tomorrow.
> 
> Mapping RHEV networking entities to entities in Marios' proposal is a
> challenge. A user can just create VM's NICs for which she specifies
> network [3].
> Network model reflects RHEV Network.
> Subnet is not used in RHEV, some related info (netmask, ip range) might
> be fetched from host's NIC entity.
> Port is not used in RHEV, most similar entity is VM's virtual NIC (which
> is associated with a virtual machine though).
> 
> When creating RHEV virtual machine, you specify network by creating
> virtual NIC for the machine in separate request. Also you can manage
> interfaces for virtual machine.
> I wonder if it makes sense to add another entity "VirtualInterface"
> which represents virtual network cards associated with an instance:
> belongs_to :instance
> belongs_to :network
> string     :name
> 
> 3) Didn't look too close but for vSphere 1b features are not possible
> too - the networking model abilities are similar to RHEV. Though their
> virtual distributed switch and VXLAN support looks promising and I could
> be wrong. Francesco was going to look at vSphere closer so he might
> bring more details.
> 
> 
> I think it would make sense to implement step 1a for all major
> providers, this involves:
> - add network listing (so a user can list available networks which she
> can specify then when launching an instance)
> - extend instance create action to automatically add the instance into
> specified network (network name would be passed as another param)
> 
> In the next step network model would be extended to support 1b for
> providers which support it.
> 
> What do you think?
> Jan
> 

Jan - thanks for looking into RHEV-M and for making these notes. We are
planning a meeting this Friday - 15th @ 1600 Brno time - most likely a
google hangout - for further discussion and next steps. It would be
great if you can bring your ideas and notes to this meeting. We can meet
on #deltacloud channel and organise the hangout there.

thanks, marios


> 
> 
> [1]
> https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Virtualization/3.0/html/Technical_Reference_Guide/sect-Technical_Reference_Guide-Networking_in_Data_Centers_and_Clusters.-Logical_Networks.html
> 
> 
> [2] http://www.ovirt.org/images/9/96/Ovirt-quantum-integration2.pdf
> 
> [3]
> https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Virtualization/3.0/html-single/REST_API_Guide/index.html#sect-REST_API_Guide-Example-Attach_NIC
> 


Re: Network API Models - RFC

Posted by Jan Provazník <jp...@redhat.com>.
On 01/21/2013 05:57 PM, marios@redhat.com wrote:
> [patches also available from http://tracker.deltacloud.org/set/263]
>
> Initial implementation for networks - in particular seeking feedback
> with respect to models and how they 'sit' for vsphere/rhevm (I've taken
> CIMI, EC2 VPC and Openstack into consideration already). Initial
> implementation of 'networks' collection for EC2 driver (create, list, show
> and destroy VPC).
>
> marios
>

Hi,
overall, the models in this patchset look reasonable to me. After 
discussing this topic with Heat/PM and some other people, here are my 
findings:

1) There are 2 levels of networking support we would like to have:
   a) be able to specify an existing network (or subnet?) when
      launching an instance
   b) be able to dynamically create whole network/subnets or firewall
      rules when launching a deployment (cloud formation)

2) For RHEV it is currently not possible to achieve 1b. Network creation 
is admin task. Nice description is here [1]. Good news is that RHEV will 
probably support Quantum networking in future, currently there is POC 
where Quantum network can be used as an external network in ovirt [2] 
(note that dynamic network creation is not possible in this POC too). 
Will do more investigation about Quantum plans tomorrow.

Mapping RHEV networking entities to entities in Marios' proposal is a 
challenge. A user can just create VM's NICs for which she specifies 
network [3].
Network model reflects RHEV Network.
Subnet is not used in RHEV, some related info (netmask, ip range) might 
be fetched from host's NIC entity.
Port is not used in RHEV, most similar entity is VM's virtual NIC (which 
is associated with a virtual machine though).

When creating RHEV virtual machine, you specify network by creating 
virtual NIC for the machine in separate request. Also you can manage
interfaces for virtual machine.
I wonder if it makes sense to add another entity "VirtualInterface" 
which represents virtual network cards associated with an instance:
belongs_to :instance
belongs_to :network
string     :name

3) Didn't look too close but for vSphere 1b features are not possible 
too - the networking model abilities are similar to RHEV. Though their 
virtual distributed switch and VXLAN support looks promising and I could 
be wrong. Francesco was going to look at vSphere closer so he might 
bring more details.


I think it would make sense to implement step 1a for all major 
providers, this involves:
- add network listing (so a user can list available networks which she 
can specify then when launching an instance)
- extend instance create action to automatically add the instance into 
specified network (network name would be passed as another param)

In the next step network model would be extended to support 1b for 
providers which support it.

What do you think?
Jan



[1] 
https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Virtualization/3.0/html/Technical_Reference_Guide/sect-Technical_Reference_Guide-Networking_in_Data_Centers_and_Clusters.-Logical_Networks.html

[2] http://www.ovirt.org/images/9/96/Ovirt-quantum-integration2.pdf

[3] 
https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Virtualization/3.0/html-single/REST_API_Guide/index.html#sect-REST_API_Guide-Example-Attach_NIC

Re: Network API Models - RFC

Posted by "marios@redhat.com" <ma...@redhat.com>.
Hi David:

On 22/01/13 03:06, David Lutterkort wrote:
> On Mon, 2013-01-21 at 18:57 +0200, marios@redhat.com wrote:
>> [patches also available from http://tracker.deltacloud.org/set/263]
>>
>> Initial implementation for networks - in particular seeking feedback
>> with respect to models and how they 'sit' for vsphere/rhevm (I've taken
>> CIMI, EC2 VPC and Openstack into consideration already). Initial
>> implementation of 'networks' collection for EC2 driver (create, list, show
>> and destroy VPC).
> 
> It might help to explain the model in words for those who are not too
> familiar with DC internals; in particular, it might not be obvious what
> relationships the various classes have (since we do not express that in
> our models)

obviously there's a lot to be discussed - for now here's some prelim
notes and answers to your initial questions (inline). I can organise
these into some kind of blog post if that would help, but for now:

=============

+ Links to APIs:

* Amazon VPC:
http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Introduction.html
,
http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeVpcs.html
,
http://docs.aws.amazon.com/AWSEC2/latest/APIReference/ApiReference-query-DescribeSubnets.html

* Openstack Quantum:
http://docs.openstack.org/api/openstack-network/2.0/content/Concepts-d1e369.html

* CIMI Networks: http://dmtf.org/standards/cloud (see DSP0263):
http://dmtf.org/sites/default/files/standards/documents/DSP0263_1.0.0.pdf

==============

+ Proposed Mappings:

* Network <===> EC2 'VPC', Quantum 'Network', CIMI 'ForwardingGroup'

* Subnet  <===> EC2 'Subnet', Quantum 'Subnet', CIMI 'Network'

* Port    <===> EC2 'Elastic Network Interface' (not necessarily -
perhaps no mapping needed),  Quantum 'Port', CIMI 'Network Port'



> 
> Just to restate what's in the model code (patch 1/3), the model seems to
> be (in some pseudo-AR notation):
> 
>         class Network
>                 string :name
>                 string :address_block
>                 enum   :state           # What values are allowed ?
>                 

* EC2 VPC: {pending, available},
* Quantum Network: either the 'status' attribute which can be {ACTIVE,
DOWN, BUILD, ERROR} OR the 'admin_state_up' attribute which can be
{true, false} ,
* CIMI ForwardingGroup: none - though CIMI Networks have state (mapped
to subnet, see below)



>                 has_many :subnets
>                 has_many :ports         # Can you attach a port to a network directly ?


* EC2 VPC: no, you launch machines into 'subnets',
* Quantum Network: yes, Port has a 'network_id' attribute,
* CIMI Network: yes, Network has a NetworkPort collection.


>         end
>         
>         class Subnet
>                 string :name
>                 enum   :state           # What values are allowed ?

* EC2 Subnet: state attribute {pending,available},
* Quantum Subnet: none (no state/status attribute),
* CIMI Network: state attribute
{CREATING,STARTING,STARTED,STOPPING,STOPPED,DELETING,ERROR}


>                 enum   :type            # What values are allowed ?

* EC2 Subnet: none - potentially could report the 'availability-zone'
here (perhaps change variable name? type => 'availability' or 'realm' -
still makes sense for CIMI Network... availability/realm = PUBLIC ||
PRIVATE)
* Quantum Subnet: none
* CIMI Network: networkType attribute: {PUBLIC, PRIVATE}


>                 string :address_block
>                 
>                 belongs_to :network
>                 has_many   :ports
>         end
>         
>         class Port
>                 string  :name
>                 string  :attachment
>                 string  :mac_address
>                 string  :ip_address
>                 enum    :state
>                 enum    :type
>                 
>                 belongs_to :network     # Do we get a network or subnet here or both ?

* EC2: no 'Port' entity - unless we want to involve Elastic Network
Interfaces but not convinced we need it - machines are launched into
'subnet' by providing the subnet_id
* Quantum Port: this points to a 'network'. A port *is* also associated
with a 'subnet' but via the 'ip_address', since in Quantum Subnets have
cidr block but networks don't.
* CIMI Network Port: points to a Network

>         end
> 
> There are various questions about the code I have based on the above but
> it might best to make sure we all understand what the model is supposed
> to be and go from there. In particular, in the above, we need to explain
> what the possible values for the various enums are, and I am not clear
> on whether a subnet can be used in various places where the code expects
> a network (e.g., when creating a port)

hope the above is at least of some help - at least to get the
conversation going,

marios

> 
> David
> 
> 
> 


Re: Network API Models - RFC

Posted by David Lutterkort <lu...@redhat.com>.
On Mon, 2013-01-21 at 18:57 +0200, marios@redhat.com wrote:
> [patches also available from http://tracker.deltacloud.org/set/263]
> 
> Initial implementation for networks - in particular seeking feedback
> with respect to models and how they 'sit' for vsphere/rhevm (I've taken
> CIMI, EC2 VPC and Openstack into consideration already). Initial
> implementation of 'networks' collection for EC2 driver (create, list, show
> and destroy VPC).

It might help to explain the model in words for those who are not too
familiar with DC internals; in particular, it might not be obvious what
relationships the various classes have (since we do not express that in
our models)

Just to restate what's in the model code (patch 1/3), the model seems to
be (in some pseudo-AR notation):

        class Network
                string :name
                string :address_block
                enum   :state           # What values are allowed ?
                
                has_many :subnets
                has_many :ports         # Can you attach a port to a network directly ?
        end
        
        class Subnet
                string :name
                enum   :state           # What values are allowed ?
                enum   :type            # What values are allowed ?
                string :address_block
                
                belongs_to :network
                has_many   :ports
        end
        
        class Port
                string  :name
                string  :attachment
                string  :mac_address
                string  :ip_address
                enum    :state
                enum    :type
                
                belongs_to :network     # Do we get a network or subnet here or both ?
        end

There are various questions about the code I have based on the above but
it might best to make sure we all understand what the model is supposed
to be and go from there. In particular, in the above, we need to explain
what the possible values for the various enums are, and I am not clear
on whether a subnet can be used in various places where the code expects
a network (e.g., when creating a port)

David




[PATCH 2/3] Network API Routes and Views

Posted by ma...@redhat.com.
From: marios <ma...@redhat.com>


Signed-off-by: marios <ma...@redhat.com>
---
 server/lib/deltacloud/collections/networks.rb | 62 +++++++++++++++++++++++++++
 server/lib/deltacloud/collections/ports.rb    | 57 ++++++++++++++++++++++++
 server/lib/deltacloud/collections/subnets.rb  | 58 +++++++++++++++++++++++++
 server/views/networks/index.html.haml         | 10 +++++
 server/views/networks/index.xml.haml          |  4 ++
 server/views/networks/new.html.haml           | 10 +++++
 server/views/networks/show.html.haml          | 24 +++++++++++
 server/views/networks/show.xml.haml           | 16 +++++++
 8 files changed, 241 insertions(+)
 create mode 100644 server/lib/deltacloud/collections/networks.rb
 create mode 100644 server/lib/deltacloud/collections/ports.rb
 create mode 100644 server/lib/deltacloud/collections/subnets.rb
 create mode 100644 server/views/networks/index.html.haml
 create mode 100644 server/views/networks/index.xml.haml
 create mode 100644 server/views/networks/new.html.haml
 create mode 100644 server/views/networks/show.html.haml
 create mode 100644 server/views/networks/show.xml.haml
 create mode 100644 server/views/ports/index.html.haml
 create mode 100644 server/views/ports/index.xml.haml
 create mode 100644 server/views/ports/show.html.haml
 create mode 100644 server/views/ports/show.xml.haml
 create mode 100644 server/views/subnets/index.html.haml
 create mode 100644 server/views/subnets/index.xml.haml
 create mode 100644 server/views/subnets/show.html.haml
 create mode 100644 server/views/subnets/show.xml.haml

diff --git a/server/lib/deltacloud/collections/networks.rb b/server/lib/deltacloud/collections/networks.rb
new file mode 100644
index 0000000..f0a6c70
--- /dev/null
+++ b/server/lib/deltacloud/collections/networks.rb
@@ -0,0 +1,62 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+module Deltacloud::Collections
+  class Networks < Base
+
+    include Deltacloud::Features
+
+    set :capability, lambda { |m| driver.respond_to? m }
+    check_features :for => lambda { |c, f| driver.class.has_feature?(c, f) }
+
+    get '/networks/new' do
+      respond_to do |format|
+        format.html { haml :"networks/new" }
+      end
+    end
+
+    collection :networks do
+
+      standard_show_operation
+      standard_index_operation
+
+      operation :create, :with_capability => :create_network do
+        param :address_block, :string, :optional
+        control do
+          @network = driver.create_network(credentials, { :address_block => params[:address_block]})
+          respond_to do |format|
+            format.xml  { haml :"networks/show" }
+            format.html { haml :"networks/show" }
+            format.json { xml_to_json("networks/show")}
+          end
+        end
+      end
+
+      operation :destroy, :with_capability => :destroy_network do
+        control do
+          driver.destroy_network(credentials, { :id => params[:id]})
+          status 204
+          respond_to do |format|
+            format.xml
+            format.json
+            format.html { redirect(networks_url) }
+          end
+        end
+      end
+
+    end
+
+  end
+end
diff --git a/server/lib/deltacloud/collections/ports.rb b/server/lib/deltacloud/collections/ports.rb
new file mode 100644
index 0000000..2947246
--- /dev/null
+++ b/server/lib/deltacloud/collections/ports.rb
@@ -0,0 +1,57 @@
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+module Deltacloud::Collections
+  class Ports < Base
+
+    include Deltacloud::Features
+
+    set :capability, lambda { |m| driver.respond_to? m }
+    check_features :for => lambda { |c, f| driver.class.has_feature?(c, f) }
+
+    collection :ports do
+
+      standard_show_operation
+      standard_index_operation
+
+      operation :create, :with_capability => :create_port do
+        param :network,  :string,  :required
+        control do
+          @port = driver.create_port(credentials, { :network => params[:network] })
+          respond_to do |format|
+            format.xml  { haml :"ports/show"}
+            format.html { haml :"ports/show" }
+            format.json { xml_to_json("ports/show")}
+          end
+        end
+      end
+
+      operation :destroy, :with_capability => :destroy_port do
+        control do
+          driver.destroy_port(credentials, { :id => params[:id]})
+          status 204
+          respond_to do |format|
+            format.xml
+            format.json
+            format.html { redirect(ports_url) }
+          end
+        end
+      end
+
+    end
+
+  end
+end
diff --git a/server/lib/deltacloud/collections/subnets.rb b/server/lib/deltacloud/collections/subnets.rb
new file mode 100644
index 0000000..7d70ae4
--- /dev/null
+++ b/server/lib/deltacloud/collections/subnets.rb
@@ -0,0 +1,58 @@
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+module Deltacloud::Collections
+  class Subnets < Base
+
+    include Deltacloud::Features
+
+    set :capability, lambda { |m| driver.respond_to? m }
+    check_features :for => lambda { |c, f| driver.class.has_feature?(c, f) }
+
+    collection :subnets do
+
+      standard_show_operation
+      standard_index_operation
+
+      operation :create, :with_capability => :create_subnet do
+        param :address_block,  :string,  :optional
+        param :ports, :string, :optional
+        control do
+          @subnet = driver.create_subnet(credentials, { :ports => params[:ports], :address_block => params[:address_block]})
+          respond_to do |format|
+            format.xml  { haml :"subnets/show"}
+            format.html { haml :"subnets/show" }
+            format.json { xml_to_json("subnets/show")}
+          end
+        end
+      end
+
+      operation :destroy, :with_capability => :destroy_subnet do
+        control do
+          driver.destroy_subnet(credentials, { :id => params[:id]})
+          status 204
+          respond_to do |format|
+            format.xml
+            format.json
+            format.html { redirect(subnets_url) }
+          end
+        end
+      end
+
+    end
+
+  end
+end
diff --git a/server/views/networks/index.html.haml b/server/views/networks/index.html.haml
new file mode 100644
index 0000000..aa0050b
--- /dev/null
+++ b/server/views/networks/index.html.haml
@@ -0,0 +1,10 @@
+=header "Networks" do
+  %a{ :href => url_for('networks/new'), :'data-icon' => :plus, :'data-role' => :button, :class => 'ui-btn-right'} Create new network
+
+%div{ :'data-role' => :content, :'data-theme' => 'c'}
+  %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'a'}
+    - @elements.each do |net|
+      %li
+        %a{ :href => network_url(net.id), :'data-ajax' => 'false'}
+          %img{ :class => 'ui-link-thumb', :src => '/images/cloud.png'}
+          %h3=net.id
diff --git a/server/views/networks/index.xml.haml b/server/views/networks/index.xml.haml
new file mode 100644
index 0000000..f2eaac6
--- /dev/null
+++ b/server/views/networks/index.xml.haml
@@ -0,0 +1,4 @@
+!!!XML
+%networks
+  - @elements.each do |c|
+    = haml :'networks/show', :locals => { :@network => c, :partial => true }
diff --git a/server/views/networks/new.html.haml b/server/views/networks/new.html.haml
new file mode 100644
index 0000000..0087259
--- /dev/null
+++ b/server/views/networks/new.html.haml
@@ -0,0 +1,10 @@
+=header "Create new network"
+
+%div{ :'data-role' => :content, :'data-theme' => 'c', :class => 'middle-dialog'}
+  %form{ :action => networks_url, :method => :post}
+    %div{ 'data-role' => :fieldcontain }
+      %p
+        %label{ :for => :address_block} CIDR Address block (optional):
+      %p
+        %input{ :type => :text, :id => :address_block, :name => :address_block, :value => '' }
+    %button{ :type => :submit} Create network
diff --git a/server/views/networks/show.html.haml b/server/views/networks/show.html.haml
new file mode 100644
index 0000000..db69784
--- /dev/null
+++ b/server/views/networks/show.html.haml
@@ -0,0 +1,24 @@
+=header "Network"
+=subheader @network.id
+
+%div{ :'data-role' => :content, :'data-theme' => 'c'}
+  %ul{ :'data-role' => :listview , :'data-inset' => :true, :'data-divider-theme' => 'd'}
+    %li{ :'data-role' => 'list-divider'} Identifier
+    %li
+      %p{ :'data-role' => 'fieldcontain'}=@network.id
+    %li{ :'data-role' => 'list-divider'} Name
+    %li
+      %p{ :'data-role' => 'fieldcontain'}=@network.name
+    %li{ :'data-role' => 'list-divider'} State
+    %li
+      %p{ :'data-role' => 'fieldcontain'}=@network.state
+    %li{ :'data-role' => 'list-divider'} Address Block
+    %li
+      %p{ :'data-role' => 'fieldcontain'}=(@network.address_block ? @network.address_block : nil)
+    %li{ :'data-role' => 'list-divider'} Subnets
+    %li
+      %p{ :'data-role' => 'fieldcontain'}= (@network.subnets ? @network.subnets.join(",") : nil)
+    %li{ :'data-role' => 'list-divider'} Actions
+    %li
+      %div{ :'data-role' => 'controlgroup', :'data-type' => "horizontal" }
+        =link_to_action "Destroy", destroy_network_url(@network.id), :delete
diff --git a/server/views/networks/show.xml.haml b/server/views/networks/show.xml.haml
new file mode 100644
index 0000000..4b4e07a
--- /dev/null
+++ b/server/views/networks/show.xml.haml
@@ -0,0 +1,16 @@
+- unless defined?(partial)
+  !!! XML
+%network{ :href => network_url(@network.id), :id => @network.id }
+  %name=@network.name
+  %state<
+    =@network.state
+  %address_block=@network.address_block
+  %subnets
+    - (@network.subnets || []).each do |subnet|
+      %subnet{:href => subnet_url(subnet), :id=>subnet}
+  %ports
+    - (@network.ports || []).each do |port|
+      %port{:href => port_url(port), :id=>port}
+  %actions
+    - if driver.respond_to?(:destroy_network)
+      %link{ :rel => "destroy", :method => "delete", :href => destroy_network_url(@network.id)}
diff --git a/server/views/ports/index.html.haml b/server/views/ports/index.html.haml
new file mode 100644
index 0000000..e69de29
diff --git a/server/views/ports/index.xml.haml b/server/views/ports/index.xml.haml
new file mode 100644
index 0000000..e69de29
diff --git a/server/views/ports/show.html.haml b/server/views/ports/show.html.haml
new file mode 100644
index 0000000..e69de29
diff --git a/server/views/ports/show.xml.haml b/server/views/ports/show.xml.haml
new file mode 100644
index 0000000..e69de29
diff --git a/server/views/subnets/index.html.haml b/server/views/subnets/index.html.haml
new file mode 100644
index 0000000..e69de29
diff --git a/server/views/subnets/index.xml.haml b/server/views/subnets/index.xml.haml
new file mode 100644
index 0000000..e69de29
diff --git a/server/views/subnets/show.html.haml b/server/views/subnets/show.html.haml
new file mode 100644
index 0000000..e69de29
diff --git a/server/views/subnets/show.xml.haml b/server/views/subnets/show.xml.haml
new file mode 100644
index 0000000..e69de29
-- 
1.7.11.7