예제 #1
0
def lst(args):
    """
    List orgs
    """
    c = VCloudAPIClient()
    for org in c.org_list().orgs:
        _dump(org)
예제 #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')
예제 #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)
예제 #6
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)
예제 #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)
예제 #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')
예제 #10
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')
예제 #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')
예제 #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')
예제 #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')