OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package frontend | 5 package frontend |
6 | 6 |
7 import ( | 7 import ( |
8 "golang.org/x/net/context" | 8 "golang.org/x/net/context" |
9 | 9 |
10 "google.golang.org/grpc" | 10 "google.golang.org/grpc" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 ret.Ranges, | 50 ret.Ranges, |
51 &crimson.IPRange{ | 51 &crimson.IPRange{ |
52 Site: row.Site, | 52 Site: row.Site, |
53 Vlan: row.Vlan, | 53 Vlan: row.Vlan, |
54 StartIp: row.StartIP, | 54 StartIp: row.StartIP, |
55 EndIp: row.EndIP, | 55 EndIp: row.EndIP, |
56 }) | 56 }) |
57 } | 57 } |
58 return &ret, nil | 58 return &ret, nil |
59 } | 59 } |
| 60 |
| 61 func (s *crimsonService) CreateHost(ctx context.Context, req *crimson.HostList)
(*crimson.HostStatus, error) { |
| 62 err := crimsondb.InsertHost(ctx, req) |
| 63 return &crimson.HostStatus{}, userErrorToGRPCError(err) |
| 64 } |
| 65 |
| 66 func (s *crimsonService) ReadHost(ctx context.Context, req *crimson.HostQuery) (
*crimson.HostList, error) { |
| 67 rows, err := crimsondb.SelectHost(ctx, req) |
| 68 |
| 69 if err == nil { |
| 70 return rows, nil |
| 71 } |
| 72 return nil, userErrorToGRPCError(err) |
| 73 } |
OLD | NEW |