Loading modules/cloud_service_providers/openstack/openstack.module +5 −4 Original line number Diff line number Diff line Loading @@ -874,6 +874,7 @@ function openstack_entity_view(array &$build, EntityInterface $entity, EntityVie function openstack_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display): void { if ($entity->getEntityTypeId() === 'cloud_launch_template' && $entity->bundle() === 'openstack') { \Drupal::service('cloud')->reorderForm($build, openstack_launch_template_field_orders(FALSE)); unset($build['field_instance_type']); $build['#attached']['library'][] = 'aws_cloud/aws_cloud_view_builder'; } } Loading Loading @@ -1169,8 +1170,9 @@ function openstack_form_cloud_launch_template_openstack_form_common_alter(array unset($form['options']); } $form['instance']['field_instance_type']['widget']['#default_value'] = ['m1.nano']; $form['instance']['field_instance_type']['#access'] = FALSE; $form['field_instance_type']['widget']['#default_value'] = ['m1.nano']; $form['field_instance_type']['#access'] = FALSE; if (!empty($openstack_ec2_service)) { $form['instance']['field_flavor']['widget']['#default_value'] = '1'; $form['instance']['field_flavor']['#access'] = FALSE; Loading Loading @@ -2082,7 +2084,6 @@ function openstack_launch_template_field_orders($include_name = TRUE): array { 'fields' => [ 'name', 'field_description', 'field_instance_type', 'field_flavor', 'field_min_count', 'field_max_count', Loading @@ -2091,7 +2092,7 @@ function openstack_launch_template_field_orders($include_name = TRUE): array { ], [ 'name' => 'ami', 'title' => t('AMI'), 'title' => t('Image'), 'open' => TRUE, 'fields' => [ 'field_openstack_image_id', Loading modules/cloud_service_providers/openstack/src/Entity/OpenStackInstance.php +18 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\openstack\Entity; use Drupal\aws_cloud\Entity\Ec2\Instance; use Drupal\aws_cloud\Entity\Ec2\InstanceInterface; use Drupal\cloud\Service\Util\EntityLinkWithShortNameHtmlGenerator; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\aws_cloud\Entity\Ec2\PublicIpEntityLinkHtmlGenerator; Loading Loading @@ -78,7 +79,7 @@ class OpenStackInstance extends Instance implements InstanceInterface { $fields = parent::baseFieldDefinitions($entity_type); $fields['instance_type'] = BaseFieldDefinition::create('string') ->setLabel(t('Instance type')) ->setLabel(t('Flavor')) ->setDescription(t("The type of instance determines your instance's CPU capacity, memory, and storage (e.g., m1.small, c1.xlarge).")) ->setDisplayOptions('view', [ 'label' => 'inline', Loading Loading @@ -186,6 +187,22 @@ class OpenStackInstance extends Instance implements InstanceInterface { array_slice($fields, $pos + 1) ); $fields['image_id'] = BaseFieldDefinition::create('string') ->setLabel(t('OpenStack Image Name')) ->setDescription(t('The Name of the OpenStack image with which the instance was launched.')) ->setDisplayOptions('view', [ 'label' => 'inline', 'type' => 'entity_link', 'settings' => [ 'target_type' => 'openstack_image', 'field_name' => 'image_id', 'comma_separated' => TRUE, 'html_generator_class' => EntityLinkWithShortNameHtmlGenerator::class, ], 'weight' => -5, ]) ->setReadOnly(TRUE); return $fields; } Loading modules/cloud_service_providers/openstack/src/Entity/OpenStackInstanceViewBuilder.php +6 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,12 @@ class OpenStackInstanceViewBuilder extends InstanceViewBuilder { $defs[0]['fields'][] = 'power_state'; // Remove account_id. $pos = array_search('account_id', $defs[0]['fields']); if ($pos !== FALSE) { unset($defs[0]['fields'][$pos]); } return $defs; } Loading modules/cloud_service_providers/openstack/src/Plugin/cloud/launch_template/OpenStackLaunchTemplatePlugin.php +9 −16 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountProxyInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Routing\Route; Loading Loading @@ -405,14 +404,14 @@ class OpenStackLaunchTemplatePlugin extends CloudPluginBase implements CloudLaun public function buildListHeader(): array { return [ [ 'data' => $this->t('AMI Name'), 'data' => $this->t('Image Name'), 'specifier' => 'field_openstack_image_id', 'field' => 'field_openstack_image_id', ], [ 'data' => $this->t('Instance type'), 'specifier' => 'field_instance_type', 'field' => 'field_instance_type', 'data' => $this->t('Flavor'), 'specifier' => 'field_flavor', 'field' => 'field_flavor', ], [ 'data' => $this->t('Security group'), Loading Loading @@ -469,18 +468,12 @@ class OpenStackLaunchTemplatePlugin extends CloudPluginBase implements CloudLaun $row[] = $empty_row; } // Instance type. $instance_type = $entity->get('field_instance_type')->value; // Flavor. $row[] = [ 'data' => [ '#type' => 'link', '#url' => Url::fromRoute( 'aws_cloud.instance_type_prices', ['cloud_context' => $entity->getCloudContext()], ['fragment' => $instance_type] ), '#title' => $instance_type, ], 'data' => $entity->field_flavor->view([ 'label' => 'hidden', 'type' => 'string', ]), ]; // Security groups. Loading Loading
modules/cloud_service_providers/openstack/openstack.module +5 −4 Original line number Diff line number Diff line Loading @@ -874,6 +874,7 @@ function openstack_entity_view(array &$build, EntityInterface $entity, EntityVie function openstack_entity_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display): void { if ($entity->getEntityTypeId() === 'cloud_launch_template' && $entity->bundle() === 'openstack') { \Drupal::service('cloud')->reorderForm($build, openstack_launch_template_field_orders(FALSE)); unset($build['field_instance_type']); $build['#attached']['library'][] = 'aws_cloud/aws_cloud_view_builder'; } } Loading Loading @@ -1169,8 +1170,9 @@ function openstack_form_cloud_launch_template_openstack_form_common_alter(array unset($form['options']); } $form['instance']['field_instance_type']['widget']['#default_value'] = ['m1.nano']; $form['instance']['field_instance_type']['#access'] = FALSE; $form['field_instance_type']['widget']['#default_value'] = ['m1.nano']; $form['field_instance_type']['#access'] = FALSE; if (!empty($openstack_ec2_service)) { $form['instance']['field_flavor']['widget']['#default_value'] = '1'; $form['instance']['field_flavor']['#access'] = FALSE; Loading Loading @@ -2082,7 +2084,6 @@ function openstack_launch_template_field_orders($include_name = TRUE): array { 'fields' => [ 'name', 'field_description', 'field_instance_type', 'field_flavor', 'field_min_count', 'field_max_count', Loading @@ -2091,7 +2092,7 @@ function openstack_launch_template_field_orders($include_name = TRUE): array { ], [ 'name' => 'ami', 'title' => t('AMI'), 'title' => t('Image'), 'open' => TRUE, 'fields' => [ 'field_openstack_image_id', Loading
modules/cloud_service_providers/openstack/src/Entity/OpenStackInstance.php +18 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\openstack\Entity; use Drupal\aws_cloud\Entity\Ec2\Instance; use Drupal\aws_cloud\Entity\Ec2\InstanceInterface; use Drupal\cloud\Service\Util\EntityLinkWithShortNameHtmlGenerator; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\aws_cloud\Entity\Ec2\PublicIpEntityLinkHtmlGenerator; Loading Loading @@ -78,7 +79,7 @@ class OpenStackInstance extends Instance implements InstanceInterface { $fields = parent::baseFieldDefinitions($entity_type); $fields['instance_type'] = BaseFieldDefinition::create('string') ->setLabel(t('Instance type')) ->setLabel(t('Flavor')) ->setDescription(t("The type of instance determines your instance's CPU capacity, memory, and storage (e.g., m1.small, c1.xlarge).")) ->setDisplayOptions('view', [ 'label' => 'inline', Loading Loading @@ -186,6 +187,22 @@ class OpenStackInstance extends Instance implements InstanceInterface { array_slice($fields, $pos + 1) ); $fields['image_id'] = BaseFieldDefinition::create('string') ->setLabel(t('OpenStack Image Name')) ->setDescription(t('The Name of the OpenStack image with which the instance was launched.')) ->setDisplayOptions('view', [ 'label' => 'inline', 'type' => 'entity_link', 'settings' => [ 'target_type' => 'openstack_image', 'field_name' => 'image_id', 'comma_separated' => TRUE, 'html_generator_class' => EntityLinkWithShortNameHtmlGenerator::class, ], 'weight' => -5, ]) ->setReadOnly(TRUE); return $fields; } Loading
modules/cloud_service_providers/openstack/src/Entity/OpenStackInstanceViewBuilder.php +6 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,12 @@ class OpenStackInstanceViewBuilder extends InstanceViewBuilder { $defs[0]['fields'][] = 'power_state'; // Remove account_id. $pos = array_search('account_id', $defs[0]['fields']); if ($pos !== FALSE) { unset($defs[0]['fields'][$pos]); } return $defs; } Loading
modules/cloud_service_providers/openstack/src/Plugin/cloud/launch_template/OpenStackLaunchTemplatePlugin.php +9 −16 Original line number Diff line number Diff line Loading @@ -23,7 +23,6 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountProxyInterface; use Drupal\Core\Url; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\Routing\Route; Loading Loading @@ -405,14 +404,14 @@ class OpenStackLaunchTemplatePlugin extends CloudPluginBase implements CloudLaun public function buildListHeader(): array { return [ [ 'data' => $this->t('AMI Name'), 'data' => $this->t('Image Name'), 'specifier' => 'field_openstack_image_id', 'field' => 'field_openstack_image_id', ], [ 'data' => $this->t('Instance type'), 'specifier' => 'field_instance_type', 'field' => 'field_instance_type', 'data' => $this->t('Flavor'), 'specifier' => 'field_flavor', 'field' => 'field_flavor', ], [ 'data' => $this->t('Security group'), Loading Loading @@ -469,18 +468,12 @@ class OpenStackLaunchTemplatePlugin extends CloudPluginBase implements CloudLaun $row[] = $empty_row; } // Instance type. $instance_type = $entity->get('field_instance_type')->value; // Flavor. $row[] = [ 'data' => [ '#type' => 'link', '#url' => Url::fromRoute( 'aws_cloud.instance_type_prices', ['cloud_context' => $entity->getCloudContext()], ['fragment' => $instance_type] ), '#title' => $instance_type, ], 'data' => $entity->field_flavor->view([ 'label' => 'hidden', 'type' => 'string', ]), ]; // Security groups. Loading