Beispiel #1
0
    def _Create(self):
        """Creates the Cloud SQL instance and authorizes traffic from anywhere.

    Raises:
      UnsupportedDatabaseEngineException:
        if the database is unmanaged and the engine isn't MYSQL.
      Exception: if an invalid MySQL flag was used.
    """
        if self.spec.engine == relational_db.MYSQL:
            self._InstallMySQLClient()
        if self.is_managed_db:
            self._CreateGcloudSqlInstance()
        else:
            self.endpoint = self.server_vm.ip_address
            if self.spec.engine == relational_db.MYSQL:
                self._InstallMySQLServer()
            else:
                raise UnsupportedDatabaseEngineException(
                    'Engine {0} not supported for unmanaged databases.'.format(
                        self.spec.engine))
            self.firewall = gce_network.GceFirewall()
            self.firewall.AllowPort(self.server_vm,
                                    3306,
                                    source_range=[self.client_vm.ip_address])
            self.unmanaged_db_exists = True
            self._ApplyMySqlFlags()
Beispiel #2
0
  def _Create(self):
    """Creates the Cloud SQL instance and authorizes traffic from anywhere.

    Raises:
      UnsupportedDatabaseEngineError:
        if the database is unmanaged and the engine isn't MYSQL.
      Exception: if an invalid MySQL flag was used.
    """
    if self.is_managed_db:
      self._CreateGcloudSqlInstance()
    else:
      self._SetupUnmanagedDatabase()

      if FLAGS.ip_addresses == vm_util.IpAddressSubset.INTERNAL:
        self.endpoint = self.server_vm.internal_ip
      else:
        self.endpoint = self.server_vm.ip_address
        self.firewall = gce_network.GceFirewall()
        self.firewall.AllowPort(
            self.server_vm, self.port, source_range=[self.client_vm.ip_address])
      self.unmanaged_db_exists = True