Skip to content
This repository has been archived by the owner on Jun 13, 2024. It is now read-only.

add get resource command #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tools/dukaan/dukaan/dukaan.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def validate_config():
required = {
'create': ['resource_provider_namespace', 'resource_type', 'subscription_id', 'resource_name', 'purchase_plan'],
'show': ['resource_provider_namespace', 'resource_type', 'subscription_id', 'resource_name'],
'get': ['resource_provider_namespace', 'resource_type', 'subscription_id', 'resource_name'],
'delete': ['resource_provider_namespace', 'resource_type', 'subscription_id', 'resource_name'],
'upgrade': ['resource_provider_namespace', 'resource_type', 'subscription_id', 'resource_name', 'upgrade_plan'],
'sso': ['resource_provider_namespace', 'resource_type', 'subscription_id', 'resource_name'],
Expand Down Expand Up @@ -92,7 +93,7 @@ def read_config():
"""
def parse_arguments():
parser = argparse.ArgumentParser()
parser.add_argument("command", help="Command to run", choices=["init", "create", "show", "upgrade", "delete", "sso", "manifest"])
parser.add_argument("command", help="Command to run", choices=["init", "create", "show", "get", "upgrade", "delete", "sso", "manifest"])
parser.add_argument('--env', help='Environment to run tests in.', choices=['test', 'prod'], default='test')
parser.add_argument('--manifest-path', help='Path to manifest.xml file. If not provided, dukaan will look in working directory for a file named manifest.xml')
parser.add_argument("--resource-provider-namespace", help="Namespace of Resource Provider e.g. contoso")
Expand Down Expand Up @@ -128,6 +129,7 @@ def run_checks():
dispatch = {
'create': validator.create,
'show': validator.get_cloud_service,
'get': validator.get_resource,
'delete': validator.delete,
'upgrade': validator.upgrade,
'manifest': validator.manifest,
Expand All @@ -137,4 +139,4 @@ def run_checks():
dispatch[config['command']]()

if __name__ == '__main__':
main()
main()
21 changes: 21 additions & 0 deletions tools/dukaan/dukaan/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,27 @@ def get_cloud_service(self):

if self.config['resource_name'] not in resource_names:
Printer.error("Resource named '%s' not returned by endpoint" % self.config['resource_name'])
def get_resource(self):
Printer.start_test("Get Resource")
(status, response) = self.client.perform_request(
"subscriptions/%s/cloudservices/%s/resources/%s/%s" % (
self.config["subscription_id"],
self.config["cloud_service_name"],
self.config["resource_type"],
self.config["resource_name"]),
"GET",
None,
validate_xml=True
)
if status in [200, 201]:
Printer.success("Get Resource succeeded.")
Printer.info("Checking XML")
else:
Printer.error("Get Resource failed with HTTP status code %s" % status)
return

t = xmlutil.get_subtree_from_xml_string(response)
self._validate_resource_response(None, t)

def upgrade(self):
etag = generate_etag()
Expand Down