def __init__(self, request, context, *args, **kwargs): self._init_images_cache() self.request = request self.context = context super(SetInstanceDetailsAction, self).__init__(request, context, *args, **kwargs) # Hide the device field if the hypervisor doesn't support it. if not nova.can_set_mount_point(): self.fields['device_name'].widget = forms.widgets.HiddenInput() source_type_choices = [ ('', _("Select source")), ("image_id", _("Boot from image")), ("instance_snapshot_id", _("Boot from snapshot")), ] if cinder.is_volume_service_enabled(request): source_type_choices.append(("volume_id", _("Boot from volume"))) try: if api.nova.extension_supported("BlockDeviceMappingV2Boot", request): source_type_choices.append( ("volume_image_id", _("Boot from image (creates a new volume)"))) except Exception: exceptions.handle( request, _('Unable to retrieve extensions ' 'information.')) source_type_choices.append( ("volume_snapshot_id", _("Boot from volume snapshot (creates a new volume)"))) self.fields['source_type'].choices = source_type_choices
def __init__(self, *args, **kwargs): super(AttachForm, self).__init__(*args, **kwargs) # Hide the device field if the hypervisor doesn't support it. if not nova.can_set_mount_point(): self.fields['device'].widget = forms.widgets.HiddenInput() # populate volume_id volume = kwargs.get('initial', {}).get("volume", None) if volume: volume_id = volume.id else: volume_id = None self.fields['volume_id'] = forms.CharField(widget=forms.HiddenInput(), initial=volume_id) # Populate instance choices instance_list = kwargs.get('initial', {}).get('instances', []) instances = [] for instance in instance_list: if instance.status in tables.VOLUME_ATTACH_READY_STATES and \ not any(instance.id == att["server_id"] for att in volume.attachments): instances.append((instance.id, '%s (%s)' % (instance.name, instance.id))) if instances: instances.insert(0, ("", _("Select an instance"))) else: instances = (("", _("No instances available")),) self.fields['instance'].choices = instances
def __init__(self, request, context, *args, **kwargs): self._init_images_cache() self.request = request self.context = context super(SetInstanceDetailsAction, self).__init__( request, context, *args, **kwargs) # Hide the device field if the hypervisor doesn't support it. if not nova.can_set_mount_point(): self.fields['device_name'].widget = forms.widgets.HiddenInput() source_type_choices = [ ('', _("Select source")), ("image_id", _("Boot from image")), ("instance_snapshot_id", _("Boot from snapshot")), ] if cinder.is_volume_service_enabled(request): source_type_choices.append(("volume_id", _("Boot from volume"))) try: if api.nova.extension_supported("BlockDeviceMappingV2Boot", request): source_type_choices.append( ("volume_image_id", _("Boot from image (creates a new volume)"))) except Exception: exceptions.handle(request, _('Unable to retrieve extensions ' 'information.')) source_type_choices.append( ("volume_snapshot_id", _("Boot from volume snapshot (creates a new volume)"))) self.fields['source_type'].choices = source_type_choices
def __init__(self, request, context, *args, **kwargs): self._init_images_cache() self.request = request self.context = context super(SetInstanceDetailsAction, self).__init__(request, context, *args, **kwargs) # Hide the device field if the hypervisor doesn't support it. if not nova.can_set_mount_point(): self.fields['device_name'].widget = forms.widgets.HiddenInput() source_type_choices = [ ('', _("Select source")), # ("image_id", _("Boot from image")), # ("instance_snapshot_id", _("Boot from snapshot")), ] if base.is_service_enabled(request, 'volume'): source_type_choices.append(("volume_id", _("Boot from volume"))) try: if api.nova.extension_supported("BlockDeviceMappingV2Boot", request): source_type_choices.append( ("volume_image_id", _("Boot from image (creates a new volume)"))) except Exception: exceptions.handle( request, _('Unable to retrieve extensions ' 'information.')) source_type_choices.append( ("volume_snapshot_id", _("Boot from volume snapshot (creates a new volume)"))) self.fields['source_type'].choices = source_type_choices # # Astute: handle pay-as-you-go accounts # type_map = get_project_type_mapping(request, self.initial['project_id']) if type_map and type_map['billing_type']['code'] == 'payg': del self.fields['flavor'] plans_choices = [] for item in get_project_plan_mappings(request, self.initial['project_id'], unassociated=True): plans_choices.append( (str(item['id']) + '::' + str(item['flavor_id']), item['plan_name'])) self.fields['plan_flavor'].choices = plans_choices self.fields['count'].widget = forms.widgets.HiddenInput() self.fields['count'].value = 1 else: if type_map: plan_maps = get_project_plan_mappings( request, self.initial['project_id']) if len(plan_maps) < 1: self.fields['flavor'].choices = [] del self.fields['plan_flavor']
def __init__(self, request, context, *args, **kwargs): self._init_images_cache() self.request = request self.context = context super(SetInstanceDetailsAction, self).__init__(request, context, *args, **kwargs) # Hide the device field if the hypervisor doesn't support it. if not nova.can_set_mount_point(): self.fields['device_name'].widget = forms.widgets.HiddenInput() self.fields['volume_size'].widget = forms.widgets.HiddenInput() source_type_choices = [ ('', _("Select source")), #("image_id", _("Boot from image")), #("instance_snapshot_id", _("Boot from snapshot")), ] if base.is_service_enabled(request, 'volume'): source_type_choices.append(("volume_id", _("Boot from volume"))) try: if api.nova.extension_supported("BlockDeviceMappingV2Boot", request): source_type_choices.append( ("volume_image_id", _("Boot from image (creates a new volume)"))) except Exception: exceptions.handle( request, _('Unable to retrieve extensions ' 'information.')) source_type_choices.append( ("volume_snapshot_id", _("Boot from volume snapshot (creates a new volume)"))) self.fields['source_type'].choices = source_type_choices # add by zhihao.ding 2015/7/16 for kill_flavor start self.fields['memory_mb'].choices = [ ('512', '512MB'), ('1024', '1GB'), ('2048', '2GB'), ('4096', '4GB'), ('8192', '8GB'), ('16384', '16GB'), ('32768', '32GB'), ('65536', '64GB'), ] self.fields['vcpus'].choices = [('1', '1'), ('2', '2'), ('4', '4'), ('8', '8'), ('16', '16'), ('24', '24')] self.fields['memory_mb'].initial = '4096' self.fields['vcpus'].initial = '2' self.fields['availability_zone'].widget = forms.widgets.HiddenInput() flavors = instance_utils.flavor_field_data(self.request, False) self.flavor = str(flavors[0][0])
def __init__(self, request, context, *args, **kwargs): self._init_images_cache() self.request = request self.context = context super(SetInstanceDetailsAction, self).__init__( request, context, *args, **kwargs) # Hide the device field if the hypervisor doesn't support it. if not nova.can_set_mount_point(): self.fields['device_name'].widget = forms.widgets.HiddenInput() self.fields['volume_size'].widget = forms.widgets.HiddenInput() source_type_choices = [ ('', _("Select source")), #("image_id", _("Boot from image")), #("instance_snapshot_id", _("Boot from snapshot")), ] if base.is_service_enabled(request, 'volume'): source_type_choices.append(("volume_id", _("Boot from volume"))) try: if api.nova.extension_supported("BlockDeviceMappingV2Boot", request): source_type_choices.append( ("volume_image_id", _("Boot from image (creates a new volume)"))) except Exception: exceptions.handle(request, _('Unable to retrieve extensions ' 'information.')) source_type_choices.append( ("volume_snapshot_id", _("Boot from volume snapshot (creates a new volume)"))) self.fields['source_type'].choices = source_type_choices # add by zhihao.ding 2015/7/16 for kill_flavor start self.fields['memory_mb'].choices = [ ('512', '512MB'), ('1024', '1GB'), ('2048', '2GB'), ('4096', '4GB'), ('8192', '8GB'), ('16384', '16GB'), ('32768', '32GB'), ('65536', '64GB'),] self.fields['vcpus'].choices = [ ('1', '1'), ('2', '2'), ('4', '4'), ('8', '8'), ('16', '16'), ('24', '24')] self.fields['memory_mb'].initial = '4096' self.fields['vcpus'].initial = '2' self.fields['availability_zone'].widget = forms.widgets.HiddenInput() flavors = instance_utils.flavor_field_data(self.request, False) self.flavor = str(flavors[0][0])
def __init__(self, request, context, *args, **kwargs): self._init_images_cache() self.request = request self.context = context super(SetInstanceDetailsAction, self).__init__(request, context, *args, **kwargs) projectname = str(request.user.tenant_name).lower() controllername = api.nova.get_controllername(request) LOG.info("Aman Tenant ID : %s" % request.user.tenant_id) LOG.info("Aman Controller Name : %s" % controllername) if api.lease.lease_project_verify(request.user.tenant_id, controllername) == False: self.fields['lease_days'].initial = "1" self.fields['lease_days'].widget.attrs['readonly'] = True # Hide the device field if the hypervisor doesn't support it. if not nova.can_set_mount_point(): self.fields['device_name'].widget = forms.widgets.HiddenInput() source_type_choices = [ ('', _("Select source")), ("image_id", _("Boot from image")), ("instance_snapshot_id", _("Boot from snapshot")), ] if base.is_service_enabled(request, 'volume'): source_type_choices.append(("volume_id", _("Boot from volume"))) try: if api.nova.extension_supported("BlockDeviceMappingV2Boot", request): source_type_choices.append( ("volume_image_id", _("Boot from image (creates a new volume)"))) except Exception: exceptions.handle( request, _('Unable to retrieve extensions ' 'information.')) source_type_choices.append( ("volume_snapshot_id", _("Boot from volume snapshot (creates a new volume)"))) self.fields['source_type'].choices = source_type_choices
def __init__(self, request, context, *args, **kwargs): self._init_images_cache() self.request = request self.context = context super(SetInstanceDetailsAction, self).__init__( request, context, *args, **kwargs) print "COURSE TO SESSION" tmp = self.request.GET.get('course', None) if (tmp != None): request.session['course'] = tmp # Hide the device field if the hypervisor doesn't support it. if not nova.can_set_mount_point(): self.fields['device_name'].widget = forms.widgets.HiddenInput() source_type_choices = [ ('', _("Select source")), ("image_id", _("Boot from image")), ("instance_snapshot_id", _("Boot from snapshot")), ] self.fields['source_type'].choices = source_type_choices
def __init__(self, request, context, *args, **kwargs): self._init_images_cache() self.request = request self.context = context super().__init__(request, context, *args, **kwargs) # Hide the device field if the hypervisor doesn't support it. if not nova.can_set_mount_point(): self.fields['device_name'].widget = forms.widgets.HiddenInput() source_type_choices = [ ('', _("Select source")), ("image_id", _("Boot from image")), ("instance_snapshot_id", _("Boot from snapshot")), ] if cinder.is_volume_service_enabled(request): source_type_choices += [ ("volume_id", _("Boot from volume")), ("volume_image_id", _("Boot from image (creates a new volume)")), ("volume_snapshot_id", _("Boot from volume snapshot (creates a new volume)")), ] self.fields['source_type'].choices = source_type_choices