@@ -51,6 +51,7 @@ import {
51
51
requireFleetViewer ,
52
52
requireRole ,
53
53
unavailableErr ,
54
+ updateDesc ,
54
55
} from './util'
55
56
56
57
// Note the *JSON types. Those represent actual API request and response bodies,
@@ -99,7 +100,7 @@ export const handlers = makeHandlers({
99
100
}
100
101
project . name = body . name
101
102
}
102
- project . description = body . description || ''
103
+ updateDesc ( project , body )
103
104
104
105
return project
105
106
} ,
@@ -242,7 +243,7 @@ export const handlers = makeHandlers({
242
243
} ,
243
244
floatingIpCreate ( { body, query } ) {
244
245
const project = lookup . project ( query )
245
- errIfExists ( db . floatingIps , { name : body . name } )
246
+ errIfExists ( db . floatingIps , { name : body . name , project_id : project . id } )
246
247
247
248
// TODO: when IP is specified, use ipInAnyRange to check that it is in the pool
248
249
const pool = body . pool
@@ -276,7 +277,7 @@ export const handlers = makeHandlers({
276
277
}
277
278
floatingIp . name = body . name
278
279
}
279
- floatingIp . description = body . description || ''
280
+ updateDesc ( floatingIp , body )
280
281
return floatingIp
281
282
} ,
282
283
floatingIpDelete ( { path, query } ) {
@@ -644,7 +645,7 @@ export const handlers = makeHandlers({
644
645
if ( body . name ) {
645
646
nic . name = body . name
646
647
}
647
- nic . description = body . description || ''
648
+ updateDesc ( nic , body )
648
649
649
650
if ( typeof body . primary === 'boolean' && body . primary !== nic . primary ) {
650
651
if ( nic . primary ) {
@@ -880,7 +881,8 @@ export const handlers = makeHandlers({
880
881
}
881
882
pool . name = body . name
882
883
}
883
- pool . description = body . description || ''
884
+
885
+ updateDesc ( pool , body )
884
886
885
887
return pool
886
888
} ,
@@ -923,7 +925,7 @@ export const handlers = makeHandlers({
923
925
throw 'Cannot snapshot disk'
924
926
}
925
927
926
- errIfExists ( db . snapshots , { name : body . name } )
928
+ errIfExists ( db . snapshots , { name : body . name , project_id : project . id } )
927
929
928
930
const disk = lookup . disk ( { ...query , disk : body . disk } )
929
931
if ( ! diskCan . snapshot ( disk ) ) {
@@ -973,7 +975,7 @@ export const handlers = makeHandlers({
973
975
} ,
974
976
vpcCreate ( { body, query } ) {
975
977
const project = lookup . project ( query )
976
- errIfExists ( db . vpcs , { name : body . name } )
978
+ errIfExists ( db . vpcs , { name : body . name , project_id : project . id } )
977
979
978
980
const newVpc : Json < Api . Vpc > = {
979
981
id : uuid ( ) ,
@@ -1011,9 +1013,7 @@ export const handlers = makeHandlers({
1011
1013
vpc . name = body . name
1012
1014
}
1013
1015
1014
- if ( typeof body . description === 'string' ) {
1015
- vpc . description = body . description
1016
- }
1016
+ updateDesc ( vpc , body )
1017
1017
1018
1018
if ( body . dns_name ) {
1019
1019
vpc . dns_name = body . dns_name
@@ -1083,9 +1083,7 @@ export const handlers = makeHandlers({
1083
1083
if ( body . name ) {
1084
1084
subnet . name = body . name
1085
1085
}
1086
- if ( typeof body . description === 'string' ) {
1087
- subnet . description = body . description
1088
- }
1086
+ updateDesc ( subnet , body )
1089
1087
1090
1088
return subnet
1091
1089
} ,
0 commit comments