def create_db(self, instance_name, instance_type,
            admin_username, admin_password, security_groups=None, db_name=None,
            storage_size_gb=DEFAULT_STORAGE_SIZE_GB,
            timeout_s=DEFAULT_TIMEOUT_S):
        """
        Creates a database instance.

        This method blocks until the db instance is active, or until
        :attr:`timeout_s` has elapsed.

        By default, hpcloud *assigns* an automatically-generated set of
        credentials for an admin user.  In addition to launching the db
        instance, this method uses the autogenerated credentials to login to
        the server and create the intended admin user based on the credentials
        supplied as method arguments.

        :param str instance_name:  A name to assign to the db instance.

        :param str instance_type:  The server instance type (e.g. ``medium``).

        :param str admin_username:  The admin username.

        :param str admin_password:  The admin password.

        :param security_groups:  *Not used in hpcloud*.

        :param str db_name:  The database name.  If this is not specified, the
            database will be named the same as the :attr:`instance_name`.

        :param int storage_size_gb:  The size of the storage volume in GB.

        :param float timeout_s:  The number of seconds to poll for an active
            database server before failing.  This value is also used when
            attempting to connect to the running mysql server.

        :rtype:  :class:`dict`

        """
        db = self._create_db(instance_name, instance_type,
                storage_size_gb)

        # hang on to these... hpcloud only provides a way to generate a new
        # set of username/password - there is no way to retrieve the originals.
        default_creds = db.credential
        log.debug('Credentials for %s: %s' % (instance_name, default_creds))

        instance = self._poll_instance_status(db, timeout_s)

        # we're taking advantage of a security bug in hpcloud's dbaas security
        # group rules.  the default *security* is to allow connections from
        # everywhere in the world.
        def connect():
            try:
                return pymysql.connect(
                        host=instance.hostname,
                        port=instance.port,
                        # db=self.database,
                        user=default_creds['username'],
                        passwd=default_creds['password'],
                        connect_timeout=timeout_s,
                        )
            except:
                log.warn("Could not connect to db, %s" % instance_name)
                # log.debug("Connection exception", exc_info=True)

        log.info("Connecting to %s..." % instance_name)
        db = poll_with_timeout(timeout_s, connect, 10)
        cur = db.cursor()
        cur.execute(
                "grant all privileges on *.* "
                "to '%s'@'%%' identified by '%s' "
                "with grant option"
                % (admin_username, admin_password)
                )
        cur.execute("flush privileges")
        return db_to_dict(instance)