Resource

A resource is a normalized, Divvy representation of a particular component of cloud computing. DivvyCloud supports over 50 resources today which range from instances to load balancers. You can do a variety of interesting things using resources. A few examples of how to interfact with resources are listed below.

Forming a resource

Resources are typically formed from resource ID objects. You can form a resource and get access to all of its functionality using the following code:

from DivvyResource.ResourceIds import ResourceId
from DivvyResource.Resources import Resource

resource_id = ResourceId.from_string('instance:10:us-east-1:i-6a8f369b:')
resource = Resource.from_resource_id(resource_id)
print dir(resource)
['CreateDatabaseAction', '_check_resource_group_auto_filters', '_db', '_db_obj', '_filter_supported_actions',
 '_insert_change_history', '_insert_default_history', '_insert_default_system_event', '_organization',
 '_organization_service', 'add_resource_to_user_group', 'bulk_load', 'clear_cached_db_object',
 'clone_db_object', 'contains_resource', 'create', 'db', 'deactivate_resource_backups', 'delete',
 'delete_db_object', 'delete_property', 'delete_setting', 'fill_cache', 'filter_collection_by_exact_match',
 'from_resource_id', 'get_attached_ips', 'get_attached_network_interfaces', 'get_attached_networks',
 'get_attached_private_ips', 'get_attached_public_ips', 'get_attached_volumes', 'get_availability_zone',
 'get_available_actions', 'get_backup_configurations', 'get_change_history', 'get_cloud_type',
 'get_containing_project', 'get_containing_project_resource_id', 'get_containing_resource_group_ids',
 'get_db_class', 'get_db_object', 'get_db_pk', 'get_db_pk_criteria', 'get_image', 'get_image_id',
 'get_image_name', 'get_instance_type', 'get_organization', 'get_organization_id',
 'get_organization_service', 'get_organization_service_added_time', 'get_organization_service_id',
 'get_organization_service_region', 'get_parent_resource_id', 'get_parent_resource_ops',
 'get_primary_network_interface_id', 'get_properties', 'get_property', 'get_resource_dependencies',
 'get_resource_name', 'get_resource_type', 'get_retained_backups', 'get_scheduled_events',
 'get_security_groups', 'get_service_type', 'get_setting', 'get_settings', 'get_supported_actions',
 'get_tag', 'handle_resource_child_added', 'handle_resource_child_removing', 'handle_resource_created',
 'handle_resource_destroyed', 'handle_resource_modified', 'instance', 'instance_id', 'is_action_supported',
 'list', 'list_with_permission_check', 'organization_service_id', 'region_name', 'resource_id',
 'set_property', 'set_setti

List instances within a cloud account

This example lists all instances within cloud account 10, which happens to be an AWS account:

from DivvyResource.Resources import Instance

instances = Instance.list(organization_service=10)
for instance in instances:
    print instance.instance_id, instance.name

i-a4c6b554 TestServer1
i-6a8f369b ElasticSearch
i-d67af975 LinuxTest
i-9d306358 MySQL-5.6
i-05dc8bd5 divvy-ami-test
i-8e9fbd5c Jenkins Tester
i-07e250d4 Build Server