48 from openstack_dashboard.dashboards.project.networks.tables import \ |
56 from openstack_dashboard.dashboards.project.networks.tables import \ |
49 DeleteNetwork as projectDeleteNetwork |
57 DeleteNetwork as projectDeleteNetwork |
50 from openstack_dashboard.dashboards.project.networks.tables import \ |
58 from openstack_dashboard.dashboards.project.networks.tables import \ |
51 NetworksTable as projectNetworksTable |
59 NetworksTable as projectNetworksTable |
52 from openstack_dashboard.dashboards.project.networks.workflows import \ |
60 from openstack_dashboard.dashboards.project.networks.workflows import \ |
53 CreateNetworkInfoAction, CreateSubnetDetailAction, CreateSubnetInfoAction |
61 CreateNetworkInfoAction, CreateSubnetDetailAction |
|
62 |
|
63 # Bootargs feature: |
|
64 # Add bootargs feature to 'SetAdvanced' workflow action. |
|
65 # Part of Project/Compute/Instances/Launch Instance |
|
66 class SolarisSetAdvancedAction(create_instance.SetAdvancedAction): |
|
67 if getattr(settings, 'SOLARIS_BOOTARGS', True): |
|
68 boot_options = forms.CharField( |
|
69 label=_("Instance Boot Options"), required=False, max_length=255, |
|
70 help_text=_("Solaris kernel(8) and boot(8) options.")) |
|
71 |
|
72 bootargs_persist = forms.BooleanField( |
|
73 label=_("Make Instance Boot Options Persistent"), |
|
74 required=False, |
|
75 help_text=_("Instance Boot Options are retained and used for each " |
|
76 "subsequent boot.")) |
|
77 |
|
78 def __init__(self, request, context, *args, **kwargs): |
|
79 super(SolarisSetAdvancedAction, self).__init__(request, context, |
|
80 *args, **kwargs) |
|
81 try: |
|
82 if context.get('workflow_slug') != 'launch_instance' and \ |
|
83 getattr(settings, 'SOLARIS_BOOTARGS', True): |
|
84 self.fields.pop('boot_options', None) |
|
85 self.fields.pop('bootargs_persist', None) |
|
86 self.fields.pop('disk_config', None) |
|
87 self.fields.pop('config_drive', None) |
|
88 except Exception: |
|
89 exceptions.handle(request, _('Unable to retrieve extensions ' |
|
90 'information.')) |
|
91 |
|
92 class Meta(object): |
|
93 name = _("Advanced Options") |
|
94 help_text_template = ("project/instances/" |
|
95 "_launch_advanced_help.html") |
|
96 |
|
97 # Bootargs feature: |
|
98 # If locally configured to do so add bootargs metadata vars |
|
99 # to Project/Compute/Instances/Launch Instance/Advanced Options |
|
100 if getattr(settings, 'SOLARIS_BOOTARGS', True): |
|
101 create_instance.SetAdvanced.action_class = SolarisSetAdvancedAction |
|
102 create_instance.SetAdvanced.contributes += ( |
|
103 'boot_options', 'bootargs_persist', |
|
104 ) |
54 |
105 |
55 # Remove 'PostCreationStep', 'SetAdvanced' from |
106 # Remove 'PostCreationStep', 'SetAdvanced' from |
56 # Project/Compute/Instances/Launch Instance |
107 # Project/Compute/Instances/Launch Instance |
57 create_instance.LaunchInstance.default_steps = ( |
108 create_instance.LaunchInstance.default_steps = ( |
58 create_instance.SelectProjectUser, |
109 create_instance.SelectProjectUser, |
59 create_instance.SetInstanceDetails, |
110 create_instance.SetInstanceDetails, |
60 create_instance.SetAccessControls, |
111 create_instance.SetAccessControls, |
61 create_instance.SetNetwork |
112 create_instance.SetNetwork |
62 ) |
113 ) |
63 |
114 |
|
115 # Bootargs feature: |
|
116 # if locally configured to do so add back 'SetAdvanced' |
|
117 # to Project/Compute/Instances/Launch Instance |
|
118 if getattr(settings, 'SOLARIS_BOOTARGS', True): |
|
119 create_instance.LaunchInstance.default_steps += ( |
|
120 create_instance.SetAdvanced, |
|
121 ) |
|
122 |
64 # Disable 'Security Groups' in Project/Instances/Launch Instance/Access & |
123 # Disable 'Security Groups' in Project/Instances/Launch Instance/Access & |
65 # Security. Note that this is unchecked by default. |
124 # Security. Note that this is unchecked by default. |
66 groups_widget = create_instance.SetAccessControlsAction.base_fields['groups'] |
125 groups_widget = create_instance.SetAccessControlsAction.base_fields['groups'] |
67 groups_widget.widget.attrs['disabled'] = True |
126 groups_widget.widget.attrs['disabled'] = True |
68 |
127 |
|
128 |
|
129 # Bootargs feature: |
|
130 # Add bootargs feature to 'UpdateInstance' workflow action class. |
|
131 # Part of Project/Compute/Instances/Actions/Edit Instance |
|
132 class UpdateInstanceBootargAction(workflows.Action): |
|
133 bootargs = forms.CharField( |
|
134 label=_("Instance Boot Options"), required=False, max_length=255, |
|
135 help_text=_("Solaris kernel(8) and boot(8) options.")) |
|
136 |
|
137 bootargs_persist = forms.BooleanField( |
|
138 label=_("Make Instance Boot Options Persistent"), |
|
139 required=False, |
|
140 help_text=_("Instance Boot Options are retained and used for each " |
|
141 "subsequent boot.")) |
|
142 |
|
143 def handle(self, request, data): |
|
144 if data is None: |
|
145 return True |
|
146 metadata = {'bootargs': data['bootargs'].strip()} |
|
147 if metadata['bootargs']: |
|
148 metadata['bootargs_persist'] = str(data['bootargs_persist']) |
|
149 else: |
|
150 metadata['bootargs_persist'] = "False" |
|
151 try: |
|
152 api.nova.server_set_meta(request, |
|
153 data['instance_id'], |
|
154 metadata) |
|
155 except Exception: |
|
156 exceptions.handle(request, ignore=True) |
|
157 return False |
|
158 return True |
|
159 |
|
160 class Meta(object): |
|
161 name = _("Instance Boot Options") |
|
162 slug = 'instance_bootargs' |
|
163 help_text = _("Edit Instance Boot Options.") |
|
164 |
|
165 |
|
166 # Bootargs feature: |
|
167 # Add bootargs To the action class for UpdateInstance |
|
168 # contained in Project/Compute/Instances/Actions/Edit Instance |
|
169 class UpdateInstanceBootarg(workflows.Step): |
|
170 action_class = UpdateInstanceBootargAction |
|
171 depends_on = ("instance_id",) |
|
172 contributes = ("bootargs", "bootargs_persist",) |
|
173 |
|
174 |
69 # Remove 'UpdateInstanceSecurityGroups' from |
175 # Remove 'UpdateInstanceSecurityGroups' from |
70 # Project/Compute/Instances/Actions/Edit Instance |
176 # Project/Compute/Instances/Actions/Edit Instance |
71 update_instance.UpdateInstance.default_steps = ( |
177 update_instance.UpdateInstance.default_steps = ( |
72 update_instance.UpdateInstanceInfo, |
178 update_instance.UpdateInstanceInfo, |
73 ) |
179 ) |
|
180 |
|
181 # Bootargs feature: |
|
182 # if locally configured to do so add UpdateInstanceBootarg |
|
183 # to Project/Compute/Instances/Actions/Edit Instance |
|
184 if getattr(settings, 'SOLARIS_BOOTARGS', True): |
|
185 update_instance.UpdateInstance.default_steps += ( |
|
186 UpdateInstanceBootarg, |
|
187 ) |
74 |
188 |
75 # Remove 'SecurityGroupsTab' tab from Project/Compute/Access & Security |
189 # Remove 'SecurityGroupsTab' tab from Project/Compute/Access & Security |
76 AccessAndSecurityTabs.tabs = (KeypairsTab, FloatingIPsTab, APIAccessTab) |
190 AccessAndSecurityTabs.tabs = (KeypairsTab, FloatingIPsTab, APIAccessTab) |
77 |
191 |
78 # Remove 'TogglePause', 'MigrateInstance' actions from |
192 # Remove 'TogglePause', 'MigrateInstance' actions from |
112 project_tables.StopInstance, |
226 project_tables.StopInstance, |
113 project_tables.RebuildInstance, |
227 project_tables.RebuildInstance, |
114 project_tables.TerminateInstance |
228 project_tables.TerminateInstance |
115 ) |
229 ) |
116 |
230 |
|
231 # Bootargs feature: |
|
232 # If locally configured to do so add 'EditBootargs' to |
|
233 # Project/Compute/Instances/Actions |
|
234 if getattr(settings, 'SOLARIS_BOOTARGS', True): |
|
235 project_tables_row_actions = project_tables.InstancesTable._meta.row_actions |
|
236 pos = project_tables.InstancesTable._meta.row_actions.index( |
|
237 project_tables.ConsoleLink |
|
238 ) |
|
239 project_tables.InstancesTable._meta.row_actions = ( |
|
240 project_tables_row_actions[:pos] + (project_tables.EditBootargs,) + |
|
241 project_tables_row_actions[pos:] |
|
242 ) |
|
243 |
117 # Disable 'disk_over_commit', 'block_migration' in |
244 # Disable 'disk_over_commit', 'block_migration' in |
118 # Admin/System/Instances/Actions/Live Migrate Instance. Note that this is |
245 # Admin/System/Instances/Actions/Live Migrate Instance. Note that this is |
119 # unchecked by default. |
246 # unchecked by default. |
120 LiveMigrateForm.base_fields['disk_over_commit'].widget.attrs['disabled'] = True |
247 LiveMigrateForm.base_fields['disk_over_commit'].widget.attrs['disabled'] = True |
121 LiveMigrateForm.base_fields['block_migration'].widget.attrs['disabled'] = True |
248 LiveMigrateForm.base_fields['block_migration'].widget.attrs['disabled'] = True |