Commit 129ef147 authored by xiaohua guan's avatar xiaohua guan Committed by Yas Naoi
Browse files

Issue #3014213 by Xiaohua Guan, baldwinlouie, yas: Update Elastic IP Address fields on cron run

parent f7db9a4d
Loading
Loading
Loading
Loading
+42
Changes for modules/cloud_service_providers/aws_cloud/src/Entity/Ec2/ElasticIp.php: 42 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -80,6 +80,13 @@ class ElasticIp extends CloudContentEntityBase implements ElasticIpInterface {
    return $this->get('domain')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setDomain($domain) {
    return $this->set('domain', $domain);
  }

  /**
   * {@inheritdoc}
   */
@@ -87,6 +94,13 @@ class ElasticIp extends CloudContentEntityBase implements ElasticIpInterface {
    return $this->get('association_id')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setAssociationId($association_id) {
    return $this->set('association_id', $association_id);
  }

  /**
   * {@inheritdoc}
   */
@@ -108,6 +122,13 @@ class ElasticIp extends CloudContentEntityBase implements ElasticIpInterface {
    return $this->get('instance_id')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setInstanceId($instance_id) {
    return $this->set('instance_id', $instance_id);
  }

  /**
   * {@inheritdoc}
   */
@@ -122,6 +143,13 @@ class ElasticIp extends CloudContentEntityBase implements ElasticIpInterface {
    return $this->get('network_interface_id')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setNetworkInterfaceId($network_interface_id) {
    return $this->set('network_interface_id', $network_interface_id);
  }

  /**
   * {@inheritdoc}
   */
@@ -129,6 +157,13 @@ class ElasticIp extends CloudContentEntityBase implements ElasticIpInterface {
    return $this->get('private_ip_address')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setPrivateIpAddress($private_ip_address) {
    return $this->set('private_ip_address', $private_ip_address);
  }

  /**
   * {@inheritdoc}
   */
@@ -136,6 +171,13 @@ class ElasticIp extends CloudContentEntityBase implements ElasticIpInterface {
    return $this->get('network_interface_owner')->value;
  }

  /**
   * {@inheritdoc}
   */
  public function setNetworkInterfaceOwner($network_interface_owner) {
    return $this->set('network_interface_owner', $network_interface_owner);
  }


  /**
   * {@inheritdoc}
+10
Changes for modules/cloud_service_providers/aws_cloud/src/Service/AwsEc2Service.php: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -967,6 +967,16 @@ class AwsEc2Service implements AwsEc2ServiceInterface {
        // Skip if $entity already exists, by updating 'refreshed' time.
        if (!empty($entity_id)) {
          $entity = ElasticIp::load($entity_id);

          // Update fields
          $entity->setInstanceId(!empty($elastic_ip['InstanceId']) ? $elastic_ip['InstanceId'] : '');
          $entity->setNetworkInterfaceId(!empty($elastic_ip['NetworkInterfaceId']) ? $elastic_ip['NetworkInterfaceId'] : '');
          $entity->setPrivateIpAddress(!empty($elastic_ip['PrivateIpAddress']) ? $elastic_ip['PrivateIpAddress'] : '');
          $entity->setNetworkInterfaceOwner(!empty($elastic_ip['NetworkInterfaceOwnerId']) ? $elastic_ip['NetworkInterfaceOwnerId'] : '');
          $entity->setAllocationId(!empty($elastic_ip['AllocationId']) ? $elastic_ip['AllocationId'] : '');
          $entity->setAssociationId(!empty($elastic_ip['AssociationId']) ? $elastic_ip['AssociationId'] : '');
          $entity->setDomain(!empty($elastic_ip['Domain']) ? $elastic_ip['Domain'] : '');

          $entity->setRefreshed($timestamp);
          $entity->save();
          continue;