File tree Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 56
56
57
57
When this option is set to true configuration drive functionality will be
58
58
forced enabled by default, otherwise user can still enable configuration
59
- drives via the REST API or image metadata properties.
59
+ drives via the REST API or image metadata properties. Launched VMs are not
60
+ affected by this option.
60
61
61
62
Possible values:
62
63
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ def setUp(self):
55
55
'ephemeral_gb' : 20 ,
56
56
'instance_type_id' : 2 , # m1.tiny
57
57
'config_drive' : None ,
58
+ 'launched_at' : None ,
58
59
'system_metadata' : {},
59
60
}
60
61
self .test_image_meta = {
Original file line number Diff line number Diff line change @@ -42,18 +42,32 @@ def test_image_meta_force(self):
42
42
43
43
self .assertTrue (configdrive .required_by (instance ))
44
44
45
- def test_config_flag_force (self ):
45
+ def test_config_flag_force_for_new_vms (self ):
46
46
self .flags (force_config_drive = True )
47
47
48
48
instance = objects .Instance (
49
49
config_drive = None ,
50
+ launched_at = None ,
50
51
system_metadata = {
51
52
"image_img_config_drive" : "optional" ,
52
53
}
53
54
)
54
55
55
56
self .assertTrue (configdrive .required_by (instance ))
56
57
58
+ def test_config_flag_force_for_existing_vms (self ):
59
+ self .flags (force_config_drive = True )
60
+
61
+ instance = objects .Instance (
62
+ config_drive = None ,
63
+ launched_at = '2019-05-17T00:00:00.000000' ,
64
+ system_metadata = {
65
+ "image_img_config_drive" : "optional" ,
66
+ }
67
+ )
68
+
69
+ self .assertFalse (configdrive .required_by (instance ))
70
+
57
71
def test_no_config_drive (self ):
58
72
self .flags (force_config_drive = False )
59
73
Original file line number Diff line number Diff line change @@ -160,8 +160,13 @@ def required_by(instance):
160
160
"img_config_drive" ,
161
161
fields .ConfigDrivePolicy .OPTIONAL )
162
162
163
+ # NOTE(pandatt): Option CONF.force_config_drive only applies to newly
164
+ # being-built VMs. And already launched VMs shouldn't be forced a config
165
+ # drive, because they may have been cloud-inited via metadata service, and
166
+ # do not need and have any config drive device. The `launched_at` property
167
+ # is an apparent flag to tell VMs being built from launched ones.
163
168
return (instance .config_drive or
164
- CONF .force_config_drive or
169
+ ( CONF .force_config_drive and not instance . launched_at ) or
165
170
image_prop == fields .ConfigDrivePolicy .MANDATORY
166
171
)
167
172
You can’t perform that action at this time.
0 commit comments