Use resource methods for metadata get/set

The current approach of using the Metadata descriptor
class has some issues including:
* Unintended database queries on accessing a metadata attribute
* get/modify/set patterns since the attribute isn't backed by a real dict
* lack of control over whether to fetch metadata locally or from the db

This change creates Resource methods metadata_get and metadata_set to use
for reading and modifying resource data. This is a refactoring change only so
there should be no change in behaviour.

This change will help in the future with
Related-Bug: #1306743

Change-Id: I7cd87a071ac410a388d787f132c9aee194030714
Do not query database for every metadata_get

This change stores the rsrc_metadata locally when the Resource object
is created so that the database is not queried every time
metadata_get is called. There are some instances where the metadata
must come from the database (eg, polling for waitcondition signal) so
an optional refresh arg is added to metadata_get to force a database
refresh of the stored rsrc_metadata.

This results in one less sql query for every time metadata_get is called,
which will help the optimising effort for
Related-Bug: #1306743

Change-Id: Iad2d810c299347ae3b6a4a8329bbd314ee4b5c16
Refactor DB resource fetching from Resource to Stack

By moving this database call to the stack, this allows a future
change to adopt a loading strategy which avoids one sql call
per resource.

Change-Id: Ie29edaf3ffc0a332db421ad01edfa7445eb806e5
Merge "Use resource methods for metadata get/set"
Merge "Do not query database for every metadata_get"
Merge "Refactor DB resource fetching from Resource to Stack"