diff --git a/modules/cloud_service_providers/aws_cloud/src/Entity/Ec2/Volume.php b/modules/cloud_service_providers/aws_cloud/src/Entity/Ec2/Volume.php index 30c0b0a..9f59a54 100644 --- a/modules/cloud_service_providers/aws_cloud/src/Entity/Ec2/Volume.php +++ b/modules/cloud_service_providers/aws_cloud/src/Entity/Ec2/Volume.php @@ -31,7 +31,7 @@ use Drupal\Core\Field\BaseFieldDefinition; * id = "aws_cloud_volume", * label = @Translation("AWS Cloud Volume"), * handlers = { - * "view_builder" = "Drupal\Core\Entity\EntityViewBuilder" , + * "view_builder" = "Drupal\aws_cloud\Entity\Ec2\VolumeViewBuilder" , * "list_builder" = "Drupal\aws_cloud\Controller\Ec2\VolumeListBuilder", * "views_data" = "Drupal\aws_cloud\Entity\Ec2\VolumeViewsData" , * @@ -268,9 +268,9 @@ class Volume extends CloudContentEntityBase implements VolumeInterface { ->setDisplayConfigurable('view', TRUE) ->setRequired(TRUE); - $fields['volume_id'] = BaseFieldDefinition::create('string') - ->setLabel(t('Volume ID')) - ->setDescription(t('The ID of the Volume')) + $fields['state'] = BaseFieldDefinition::create('string') + ->setLabel(t('State')) + ->setDescription(t('The current state of the volume, for example, creating, available, in-use, deleting, or error.')) ->setDisplayOptions('view', [ 'label' => 'inline', 'type' => 'string', @@ -287,9 +287,10 @@ class Volume extends CloudContentEntityBase implements VolumeInterface { 'weight' => -5, ]); - $fields['state'] = BaseFieldDefinition::create('string') - ->setLabel(t('State')) - ->setDescription(t('The current state of the volume, for example, creating, available, in-use, deleting, or error.')) + + $fields['availability_zone'] = BaseFieldDefinition::create('string') + ->setLabel(t('Availability Zone')) + ->setDescription(t('The Availability Zone in which the volume is located.')) ->setDisplayOptions('view', [ 'label' => 'inline', 'type' => 'string', @@ -297,6 +298,15 @@ class Volume extends CloudContentEntityBase implements VolumeInterface { ]) ->setReadOnly(TRUE); + $fields['volume_type'] = BaseFieldDefinition::create('string') + ->setLabel(t('Volume Type')) + ->setDescription(t('Indicates whether the volume is a standard (Magnetic), gp2 (General Purpose (SSD)) or io1 (Provisioned IOPS (SSD)) volume.')) + ->setDisplayOptions('view', [ + 'label' => 'inline', + 'type' => 'string', + 'weight' => -5, + ]); + $fields['volume_status'] = BaseFieldDefinition::create('string') ->setLabel(t('State')) ->setDescription(t('The current state of the volume, for example, "Okay".')) @@ -307,24 +317,24 @@ class Volume extends CloudContentEntityBase implements VolumeInterface { ]) ->setReadOnly(TRUE); - $fields['attachment_information'] = BaseFieldDefinition::create('string') - ->setLabel(t('Attachment Information')) - ->setDescription(t('Provides the volume attachment details: the ID of the instance the volume is attached to (and its name in parentheses if applicable), the device name, and the status of the attachment, for example, attaching, attached, or detaching.')) + $fields['iops'] = BaseFieldDefinition::create('integer') + ->setLabel(t('IOPS')) + ->setDescription(t('The requested number of I/O operations per second that the volume can support. For Provisioned IOPS (SSD) volumes, you can provision up to 30 IOPS per GiB. For General Purpose (SSD) volumes under 1000 GiB, you get a baseline performance of 100 IOPS per GiB with bursts up to 3000 IOPS. For General Purpose (SSD) volumes above 1000 GiB you get a baseline performance of 100 per GiB up to 10000 IOPS. Learn more about EBS volume types.')) ->setDisplayOptions('view', [ 'label' => 'inline', 'type' => 'string', 'weight' => -5, - ]) - ->setReadOnly(TRUE); + ]); - $fields['volume_type'] = BaseFieldDefinition::create('string') - ->setLabel(t('Volume Type')) - ->setDescription(t('Indicates whether the volume is a standard (Magnetic), gp2 (General Purpose (SSD)) or io1 (Provisioned IOPS (SSD)) volume.')) + $fields['encrypted'] = BaseFieldDefinition::create('boolean') + ->setLabel(t('Encrypted')) + ->setDescription(t('Indicates whether the volume is encrypted.')) ->setDisplayOptions('view', [ 'label' => 'inline', 'type' => 'string', 'weight' => -5, - ]); + ]) + ->setReadOnly(TRUE); $fields['product_codes'] = BaseFieldDefinition::create('string') ->setLabel(t('Product Codes')) @@ -336,18 +346,19 @@ class Volume extends CloudContentEntityBase implements VolumeInterface { ]) ->setReadOnly(TRUE); - $fields['iops'] = BaseFieldDefinition::create('integer') - ->setLabel(t('IOPS')) - ->setDescription(t('The requested number of I/O operations per second that the volume can support. For Provisioned IOPS (SSD) volumes, you can provision up to 30 IOPS per GiB. For General Purpose (SSD) volumes under 1000 GiB, you get a baseline performance of 100 IOPS per GiB with bursts up to 3000 IOPS. For General Purpose (SSD) volumes above 1000 GiB you get a baseline performance of 100 per GiB up to 10000 IOPS. Learn more about EBS volume types.')) + $fields['alarm_status'] = BaseFieldDefinition::create('string') + ->setLabel(t('Alarm Status')) + ->setDescription(t('CloudWatch alarm summary for alarms monitoring metrics for this volume.')) ->setDisplayOptions('view', [ 'label' => 'inline', 'type' => 'string', 'weight' => -5, - ]); + ]) + ->setReadOnly(TRUE); - $fields['alarm_status'] = BaseFieldDefinition::create('string') - ->setLabel(t('Alarm Status')) - ->setDescription(t('CloudWatch alarm summary for alarms monitoring metrics for this volume.')) + $fields['volume_id'] = BaseFieldDefinition::create('string') + ->setLabel(t('Volume ID')) + ->setDescription(t('The ID of the Volume')) ->setDisplayOptions('view', [ 'label' => 'inline', 'type' => 'string', @@ -375,22 +386,16 @@ class Volume extends CloudContentEntityBase implements VolumeInterface { ]) ->setReadOnly(TRUE); - $fields['availability_zone'] = BaseFieldDefinition::create('string') - ->setLabel(t('Availability Zone')) - ->setDescription(t('The Availability Zone in which the volume is located.')) - ->setDisplayOptions('view', [ - 'label' => 'inline', - 'type' => 'string', - 'weight' => -5, - ]) - ->setReadOnly(TRUE); - - $fields['encrypted'] = BaseFieldDefinition::create('boolean') - ->setLabel(t('Encrypted')) - ->setDescription(t('Indicates whether the volume is encrypted.')) + $fields['attachment_information'] = BaseFieldDefinition::create('string') + ->setLabel(t('Attachment Information')) + ->setDescription(t('Provides the volume attachment details: the ID of the instance the volume is attached to (and its name in parentheses if applicable), the device name, and the status of the attachment, for example, attaching, attached, or detaching.')) ->setDisplayOptions('view', [ 'label' => 'inline', - 'type' => 'string', + 'type' => 'entity_link', + 'settings' => [ + 'target_type' => 'aws_cloud_instance', + 'field_name' => 'instance_id', + ], 'weight' => -5, ]) ->setReadOnly(TRUE); diff --git a/modules/cloud_service_providers/aws_cloud/src/Entity/Ec2/VolumeViewBuilder.php b/modules/cloud_service_providers/aws_cloud/src/Entity/Ec2/VolumeViewBuilder.php new file mode 100644 index 0000000..a523db7 --- /dev/null +++ b/modules/cloud_service_providers/aws_cloud/src/Entity/Ec2/VolumeViewBuilder.php @@ -0,0 +1,47 @@ + 'volume', + 'title' => t('Volume'), + 'open' => TRUE, + 'fields' => [ + 'state', + 'size', + 'availability_zone', + 'volume_type', + 'iops', + 'encrypted', + ], + ], + [ + 'name' => 'attachment', + 'title' => t('Attachment'), + 'open' => FALSE, + 'fields' => [ + 'volume_id', + 'snapshot_id', + 'attachment_information', + ], + ], + [ + 'name' => 'others', + 'title' => t('Others'), + 'open' => FALSE, + 'fields' => ['user_id'], + ], + ]; + } + +}