Beispiel #1
0
def lst(args):
    """
    List orgs
    """
    c = VCloudAPIClient()
    for org in c.org_list().orgs:
        _dump(org)
Beispiel #2
0
def show(args):
    """
    Show a specified org
    """
    c = VCloudAPIClient()
    org = c.org(args.name)

    _dump(org)
    def test_browse_gets_specified_path(self):
        c = VCloudAPIClient()
        self.register_response('get',
                               API_ROOT + '/wibble',
                               200,
                               content='BAZ BAT')

        res = c.browse('/wibble')
        assert_equal(res.content, 'BAZ BAT')
Beispiel #4
0
    def test_org_list_should_return_list_of_orgs(self):
        c = VCloudAPIClient()
        org_list_xml = fixture('orglist')

        # org_list should work out where to look from the hypermedia returned
        # at the /session path. "/myCustomOrgListPath/" is where the orgList
        # is defined to exist in the "session" fixture
        self.register_response('get', API_ROOT + '/myCustomOrgListPath/', 200, {}, org_list_xml)

        org_list = c.org_list()
        assert_equal(len(org_list.orgs), 3)
    def test_org_list_should_return_list_of_orgs(self):
        c = VCloudAPIClient()
        org_list_xml = fixture('orglist')

        # org_list should work out where to look from the hypermedia returned
        # at the /session path. "/myCustomOrgListPath/" is where the orgList
        # is defined to exist in the "session" fixture
        self.register_response('get', API_ROOT + '/myCustomOrgListPath/', 200,
                               {}, org_list_xml)

        org_list = c.org_list()
        assert_equal(len(org_list.orgs), 3)
def browse(args):
    """
    Browse the vCloud API using the built-in hypermedia links
    """
    c = VCloudAPIClient()
    res = c.browse(args.path)

    print('HTTP/1.1 {0} {1}'.format(res.status_code, res.reason))

    for k, v in res.headers.items():
        print("{0}: {1}".format(k, v))

    print()
    print(res.content)
Beispiel #7
0
def browse(args):
    """
    Browse the vCloud API using the built-in hypermedia links
    """
    c = VCloudAPIClient()
    res = c.browse(args.path)

    print('HTTP/1.1 {0} {1}'.format(res.status_code, res.reason))

    for k, v in res.headers.items():
        print("{0}: {1}".format(k, v))

    print()
    print(res.content)
Beispiel #8
0
def login(args):
    """
    Log into a vCloud instance, and print the resulting auth token.
    """
    c = VCloudAPIClient()

    login_if_needed(c)

    print("export {0}='{1}'".format(envkey('auth_token'), c.token))
    def test_browse_gets_api_root_with_no_args(self):
        c = VCloudAPIClient()
        self.register_response('get', API_ROOT + '/', 200, content='FOO BAR')

        res = c.browse()
        assert_equal(res.content, 'FOO BAR')
 def test_login_should_set_token(self):
     c = VCloudAPIClient()
     assert_equal(c.token, None)
     c.login('foo', 'bar')
     assert_equal(c.token, 'test_token')
Beispiel #11
0
    def test_browse_gets_specified_path(self):
        c = VCloudAPIClient()
        self.register_response('get', API_ROOT + '/wibble', 200, content='BAZ BAT')

        res = c.browse('/wibble')
        assert_equal(res.content, 'BAZ BAT')
Beispiel #12
0
    def test_browse_gets_api_root_with_no_args(self):
        c = VCloudAPIClient()
        self.register_response('get', API_ROOT + '/', 200, content='FOO BAR')

        res = c.browse()
        assert_equal(res.content, 'FOO BAR')
Beispiel #13
0
 def test_login_should_set_token(self):
     c = VCloudAPIClient()
     assert_equal(c.token, None)
     c.login('foo', 'bar')
     assert_equal(c.token, 'test_token')