Merge lp:~gz/goose/run_server_networks into lp:goose

Proposed by Martin Packman
Status: Merged
Approved by: Martin Packman
Approved revision: 116
Merged at revision: 116
Proposed branch: lp:~gz/goose/run_server_networks
Merge into: lp:goose
Diff against target: 54 lines (+19/-0)
2 files modified
nova/nova.go (+10/-0)
testservices/novaservice/service_http.go (+9/-0)
To merge this branch: bzr merge lp:~gz/goose/run_server_networks
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+203113@code.launchpad.net

Commit message

Add networks attribute to RunServer params

This enables the starting of a server on a specific
network, which is required for some situations where
multiple networks exist.

This is not well tested at present, to do a proper job some
more network related operations need to be added so the
tests can do real operations.

https://codereview.appspot.com/56670043/

R=natefinch

Description of the change

Add networks attribute to RunServer params

This enables the starting of a server on a specific
network, which is required for some situations where
multiple networks exist.

This is not well tested at present, to do a proper job some
more network related operations need to be added so the
tests can do real operations.

https://codereview.appspot.com/56670043/

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Reviewers: mp+203113_code.launchpad.net,

Message:
Please take a look.

Description:
Add networks attribute to RunServer params

This enables the starting of a server on a specific
network, which is required for some situations where
multiple networks exist.

This is not well tested at present, to do a proper job some
more network related operations need to be added so the
tests can do real operations.

https://code.launchpad.net/~gz/goose/run_server_networks/+merge/203113

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/56670043/

Affected files (+21, -0 lines):
   A [revision details]
   M nova/nova.go
   M testservices/novaservice/service_http.go

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: tarmac-20140120121239-twy42hxhmht9f2ru
+New revision: <email address hidden>

Index: nova/nova.go
=== modified file 'nova/nova.go'
--- nova/nova.go 2013-11-25 20:25:17 +0000
+++ nova/nova.go 2014-01-24 16:33:31 +0000
@@ -296,6 +296,15 @@
   Name string `json:"name"`
  }

+// ServerNetworks sets what networks a server should be connected to on
boot.
+// - FixedIp may be supplied only when NetworkId is also given.
+// - PortId may be supplied only if neither NetworkId or FixedIp is set.
+type ServerNetworks struct {
+ NetworkId string `json:"uuid,omitempty"`
+ FixedIp string `json:"fixed_ip,omitempty"`
+ PortId string `json:"port,omitempty"`
+}
+
  // RunServerOpts defines required and optional arguments for RunServer().
  type RunServerOpts struct {
   Name string `json:"name"` //
Required
@@ -303,6 +312,7 @@
   ImageId string `json:"imageRef"` //
Required
   UserData []byte `json:"user_data"` //
Optional
   SecurityGroupNames []SecurityGroupName `json:"security_groups"` //
Optional
+ Networks []ServerNetworks `json:"networks"` //
Optional
  }

  // RunServer creates a new server, based on the given RunServerOpts.

Index: testservices/novaservice/service_http.go
=== modified file 'testservices/novaservice/service_http.go'
--- testservices/novaservice/service_http.go 2014-01-16 10:50:02 +0000
+++ testservices/novaservice/service_http.go 2014-01-24 16:33:31 +0000
@@ -539,6 +539,7 @@
     Name string
     Metadata map[string]string
     SecurityGroups []map[string]string `json:"security_groups"`
+ Networks []map[string]string
    }
   }
   if err := json.Unmarshal(body, &req); err != nil {
@@ -570,6 +571,14 @@
     }
    }
   }
+ // TODO(gz) some kind of sane handling of networks
+ for _, network := range req.Server.Networks {
+ networkId := network["uuid"]
+ _, ok := n.networks[networkId]
+ if !ok {
+ return errNotFoundJSON
+ }
+ }
   // TODO(dimitern) - 2013-02-11 bug=1121684
   // make sure flavor/image exist (if needed)
   flavor := nova.FlavorDetail{Id: req.Server.FlavorRef}

Revision history for this message
Nate Finch (natefinch) wrote :
Revision history for this message
Dimiter Naydenov (dimitern) wrote :

In the future, please make sure you've updated the dependencies.tsv file
when making changes that need newer revisions of external libraries like
goose.

https://codereview.appspot.com/56670043/

Revision history for this message
Martin Packman (gz) wrote :

On 2014/01/27 01:02:57, dimitern wrote:
> In the future, please make sure you've updated the dependencies.tsv
file when
> making changes that need newer revisions of external libraries like
goose.

The juju-core change that requires this does include a dep bump to r116.

https://codereview.appspot.com/56670043/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/nova.go'
2--- nova/nova.go 2013-11-25 20:25:17 +0000
3+++ nova/nova.go 2014-01-24 16:40:57 +0000
4@@ -296,6 +296,15 @@
5 Name string `json:"name"`
6 }
7
8+// ServerNetworks sets what networks a server should be connected to on boot.
9+// - FixedIp may be supplied only when NetworkId is also given.
10+// - PortId may be supplied only if neither NetworkId or FixedIp is set.
11+type ServerNetworks struct {
12+ NetworkId string `json:"uuid,omitempty"`
13+ FixedIp string `json:"fixed_ip,omitempty"`
14+ PortId string `json:"port,omitempty"`
15+}
16+
17 // RunServerOpts defines required and optional arguments for RunServer().
18 type RunServerOpts struct {
19 Name string `json:"name"` // Required
20@@ -303,6 +312,7 @@
21 ImageId string `json:"imageRef"` // Required
22 UserData []byte `json:"user_data"` // Optional
23 SecurityGroupNames []SecurityGroupName `json:"security_groups"` // Optional
24+ Networks []ServerNetworks `json:"networks"` // Optional
25 }
26
27 // RunServer creates a new server, based on the given RunServerOpts.
28
29=== modified file 'testservices/novaservice/service_http.go'
30--- testservices/novaservice/service_http.go 2014-01-16 10:50:02 +0000
31+++ testservices/novaservice/service_http.go 2014-01-24 16:40:57 +0000
32@@ -539,6 +539,7 @@
33 Name string
34 Metadata map[string]string
35 SecurityGroups []map[string]string `json:"security_groups"`
36+ Networks []map[string]string
37 }
38 }
39 if err := json.Unmarshal(body, &req); err != nil {
40@@ -570,6 +571,14 @@
41 }
42 }
43 }
44+ // TODO(gz) some kind of sane handling of networks
45+ for _, network := range req.Server.Networks {
46+ networkId := network["uuid"]
47+ _, ok := n.networks[networkId]
48+ if !ok {
49+ return errNotFoundJSON
50+ }
51+ }
52 // TODO(dimitern) - 2013-02-11 bug=1121684
53 // make sure flavor/image exist (if needed)
54 flavor := nova.FlavorDetail{Id: req.Server.FlavorRef}

Subscribers

People subscribed via source and target branches