Skip to content
Snippets Groups Projects
Commit 44433605 authored by xiaohua guan's avatar xiaohua guan Committed by Yas Naoi
Browse files

Issue #3220250 by Xiaohua Guan, yas: Add Cloud Orchestrator cloud service...

Issue #3220250 by Xiaohua Guan, yas: Add Cloud Orchestrator cloud service provider (QueueWorker) (Convert payload) (K8s entities)
parent 0d8ed0f7
No related branches found
No related tags found
No related merge requests found
......@@ -135,7 +135,7 @@ class CloudClusterWorkerAdminSettings extends ConfigFormBase {
$worker_id = $config->get('cloud_cluster_worker_id');
if (empty($worker_id)) {
$worker_id = $config->get('system.site')->get('uuid');
$worker_id = $this->config('system.site')->get('uuid');
}
$form['cloud_cluster_worker']['cloud_cluster_worker_id'] = [
......
......@@ -283,3 +283,37 @@ function cloud_cluster_update_9009(): void {
drupal_flush_all_caches();
}
/**
* Add cloud_cluster_name and cloud_cluster_worker_name to k8s_* entities.
*/
function cloud_cluster_update_9010(): void {
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
$fields = [];
$fields['cloud_cluster_name'] = BaseFieldDefinition::create('string')
->setLabel(t('Cloud Orchestrator Name'))
->setDescription(t('The name of cloud orchestrator.'));
$fields['cloud_cluster_worker_name'] = BaseFieldDefinition::create('string')
->setLabel(t('Cloud Orchestrator Worker Name'))
->setDescription(t('The name of cloud orchestrator worker.'));
$entity_type_definitions = \Drupal::entityTypeManager()->getDefinitions();
foreach ($entity_type_definitions ?: [] as $entity_type_key => $entity_type_definition) {
if (!preg_match('/^k8s_[a-z_]+$/', $entity_type_key)) {
continue;
}
foreach ($fields as $name => $field) {
$definition_update_manager->installFieldStorageDefinition(
$name,
$entity_type_key,
'k8s',
$field
);
}
}
drupal_flush_all_caches();
}
......@@ -294,7 +294,7 @@ function cloud_cluster_rest_resource_alter(array &$definitions): void {
* Implements hook_entity_base_field_info().
*/
function cloud_cluster_entity_base_field_info(EntityTypeInterface $entity_type): array {
if (!preg_match('/^(aws_cloud_[a-z_]+$)|^(cloud_config)$/', $entity_type->id())) {
if (!preg_match('/^aws_cloud_[a-z_]+$|^k8s_[a-z_]+$|^cloud_config$/', $entity_type->id())) {
return [];
}
......@@ -314,7 +314,7 @@ function cloud_cluster_entity_base_field_info(EntityTypeInterface $entity_type):
* Implements hook_views_query_alter().
*/
function cloud_cluster_views_query_alter(ViewExecutable $view, QueryPluginBase $query) {
if (!preg_match('/^aws_cloud_[a-z_]+$/', $view->id())) {
if (!preg_match('/^aws_cloud_[a-z_]+$|^k8s_[a-z_]+$/', $view->id())) {
return;
}
......
......@@ -96,7 +96,7 @@ class CloudClusterSyncResourcesQueueWorker extends QueueWorkerBase implements Co
$cloud_cluster_worker_name = $data['cloud_cluster_worker_name'] ?? '';
$cloud_cluster_name = $data['cloud_cluster_name'] ?? '';
if (!preg_match('/^aws_cloud_[a-z_]+$|^(cloud_config)$/', $entity_type)) {
if (!preg_match('/^aws_cloud_[a-z_]+$|^k8s_[a-z_]+$|^cloud_config$/', $entity_type)) {
return;
}
......
......@@ -16,7 +16,7 @@ class CloudClusterRouteSubscriber extends RouteSubscriberBase {
protected function alterRoutes(RouteCollection $collection) {
$collection_to_add = new RouteCollection();
foreach ($collection ?: [] as $name => $route) {
if (!preg_match('/^view\.aws_cloud_[a-z_]+\.[a-z]+$/', $name)) {
if (!preg_match('/^view\.aws_cloud_[a-z_]+\.[a-z]+$|^view\.k8s_[a-z_]+\.[a-z]+$/', $name)) {
continue;
}
......
......@@ -198,7 +198,7 @@ class CloudService extends CloudServiceBase implements CloudServiceInterface {
$container->get('request_stack'),
$container->get('http_client'),
$container->get('plugin.manager.cloud_config_plugin'),
$container->has('plugin.manager.geocoder.provider') ? $container->get('plugin.manager.geocoder.provider') : NULL,
$container->has('plugin.manager.geocoder.provider') ? $container->get('plugin.manager.geocoder.provider') : NULL
);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment