Example #1
0
 def wrapper(*args, **kw):
     config = ctx.node.properties.get(VERSA_CONFIG)
     path = _create_path()
     with VersaClient(config, path) as client:
         kw['versa_client'] = client
         result = f(*args, **kw)
     return result
 def notest_create_rule(self):
     with VersaClient(self.config) as client:
         app = 'testapp'
         org = 'child'
         pool_name = "testpool"
         rule_name = "testrule"
         source_addr = ["1.2.3.0/24"]
         versa_plugin.cgnat.create_rule(client, app, org, rule_name,
                                        source_addr, pool_name)
Example #3
0
def get_configuration(url):
    def info(x):
        print x

    fake_ctx = mock.MagicMock()
    fake_ctx.logger.info = info
    patcher_ctx1 = mock.patch('versa_plugin.versaclient.ctx', fake_ctx)
    patcher_ctx1.start()
    with VersaClient(configuration.versa_config, '/tmp/versakey') as client:
        result = client.get(url, None, None, codes.ok)
        patcher_ctx1.stop()
        return result
 def notest_create_pool(self):
     with VersaClient(self.config) as client:
         app = 'testapp'
         org = 'child'
         pool_name = "testpool"
         routing = "vr",
         provider = "mytestorg"
         addr_range = [AddressRange("range",
                                    "172.168.35.1", "175.168.35.30")]
         versa_plugin.cgnat.create_pool(client, app, org, pool_name,
                                        addr_range,
                                        routing, provider)
Example #5
0
import configuration
import sys
import os
from versa_plugin.versaclient import VersaClient
if len(sys.argv) != 2:
    print 'Need file'
    quit()

file_name = sys.argv[1]

if not os.path.isfile(file_name):
    print 'Wrong file'
    quit()

client = VersaClient(configuration.data, '')
for line in open(file_name):
    if line.startswith('nms rbac oauth'):
        token = line.split()[5]
        print token
        client.access_token = token
        client.revoke_token()
 def notest_get_all_tasks(self):
     with VersaClient(self.config) as client:
         print versa_plugin.tasks.get_all_tasks(client)
 def test_get_task_info(self):
     with VersaClient(self.config) as client:
         task = '25'
         print versa_plugin.tasks.get_task_info(client, task)
 def test_get_revoke_token(self):
     config = configuration.data
     client = VersaClient(config, '/tmp/versa.key')
     client.get_token()
     client.revoke_token()
 def test_delete_rule(self):
     with VersaClient(self.config) as client:
         app = 'testapp'
         org = 'child'
         rule_name = "testrule"
         versa_plugin.cgnat.delete_rule(client, app, org, rule_name)
 def notest_delete_pool(self):
     with VersaClient(self.config) as client:
         app = 'testapp'
         org = 'child'
         pool_name = "testpool"
         versa_plugin.cgnat.delete_pool(client, app, org, pool_name)
 def notest_get_rules(self):
     with VersaClient(self.config) as client:
         app = 'mytestapp'
         org = 'mytestorg'
         print versa_plugin.cgnat.get_list_nat_rules(client, app, org)
 def setUp(self):
     self.client = VersaClient(configuration, '/tmp/testkey')