Beispiel #1
0
    def test_find(self):
        assert tcol.find() == [], "find should return an empty list when there are no templates loaded"

        # load some templates
        dir_path = os.path.join(os.path.dirname(__file__), 'fixtures/templates/node')
        tcol._load_template("https://github.com/threefoldtech/0-robot", dir_path)

        assert tcol.find() != [], "find should not return an empty list when there are some templates loaded"
        assert len(tcol.find()) == len(tcol.list_templates()), "find without argument should return the full list of loaded templates"

        assert len(tcol.find(host='github.com')) != 0
        assert len(tcol.find(host='gitlab.com')) == 0

        assert len(tcol.find(account='threefoldtech')) != 0
        assert len(tcol.find(account='nonexisting')) == 0

        assert len(tcol.find(repo='0-robot')) != 0
        assert len(tcol.find(repo='nonexisting')) == 0

        assert len(tcol.find(name='node')) == 1
        assert len(tcol.find(name='nonexisting')) == 0

        assert len(tcol.find(version='0.0.1')) != 0
        assert len(tcol.find(version='nonexisting')) == 0

        found = tcol.find(host='github.com', account='threefoldtech', repo='0-robot', name='node', version='0.0.1')
        assert len(found) == 1
        assert str(found[0].template_uid) == 'github.com/threefoldtech/0-robot/node/0.0.1'
Beispiel #2
0
 def preTest(cls, path, template):
     config.data_repo = config.DataRepo(
         tempfile.mkdtemp(prefix='0-templates_'))
     template_collection._load_template(
         'https://github.com/zero-os/0-templates', path)
     template.template_uid = TemplateUID.parse(
         'github.com/zero-os/0-templates/%s/%s' %
         (template.template_name, template.version))
Beispiel #3
0
 def test_get_template_name_conflict(self):
     dir_path = os.path.join(os.path.dirname(__file__), 'fixtures/templates/node')
     tcol._load_template("https://github.com/threefoldtech/0-robot", dir_path)
     dir_path = os.path.join(os.path.dirname(__file__), 'fixtures/templates_2/node')
     tcol._load_template("https://github.com/threefoldtech/0-robot", dir_path)
     self.assertEqual(len(tcol._templates), 2, 'should have loaded 2 templates')
     with self.assertRaises(tcol.TemplateConflictError) as err:
         tmpl = tcol.get('node')
Beispiel #4
0
    def test_list_template(self):
        # valid template
        file_path = os.path.join(os.path.dirname(__file__), 'fixtures/templates/node')
        tcol._load_template("https://github.com/threefoldtech/0-robot", file_path)

        templates = tcol.list_templates()
        self.assertEqual(len(templates), 1, "size of templates list should 1")
        tmpl = templates[0]
        self.assertEqual(tmpl.template_name, "node")
Beispiel #5
0
    def test_load_template(self):
        # valid template
        file_path = os.path.join(os.path.dirname(__file__), 'fixtures/templates/node')
        tcol._load_template("https://github.com/threefoldtech/0-robot", file_path)
        self.assertEqual(len(tcol._templates), 1, 'should have loaded a template')

        # non existing template
        with self.assertRaises(Exception, msg='loading non existing template should fail'):
            tcol._load_template("/not/existing/path", file_path)
Beispiel #6
0
    def test_get_template_uid(self):
        dir_path = os.path.join(os.path.dirname(__file__), 'fixtures/templates/node')
        tcol._load_template("https://github.com/threefoldtech/0-robot", dir_path)
        self.assertGreater(len(tcol._templates), 0, 'should have loaded template, actual loaded')

        template = tcol.get('github.com/threefoldtech/0-robot/node/0.0.1')
        self.assertTrue(template is not None)
        self.assertEqual(template.template_dir, dir_path)

        with self.assertRaises(TemplateNotFoundError, msg="should raise TemplateNotFoundError"):
            tcol.get('github.com/threefoldtech/0-robot/noexists/0.0.1')
Beispiel #7
0
    def setUp(self):
        config.DATA_DIR = '/tmp'
        self.type = template_collection._load_template(
            "https://github.com/openvcloud/0-templates",
            os.path.dirname(__file__))

        self.ovc = {
            'service': 'test_ovc_service',
            'info': {
                'name': 'connection_instance_name'
            }
        }
        self.acc = {
            'service': 'test_account_service',
            'info': {
                'name': 'test_account',
                'openvcloud': self.ovc['service']
            }
        }
        self.vdcuser = {
            'service': 'test_vdcuser_service',
            'base_name': 'test_vdcuser',
            'accesstype': 'R',
            'info': {
                'name': 'test_vdcuser@itsyouonline',
                'openvcloud': self.ovc['service']
            }
        }
 def setUpClass(cls):
     cls.valid_data = {
         'node':
         'node',
         'rpcPort':
         23112,
         'apiPort':
         23110,
         'walletAddr':
         '',
         'walletSeed':
         '',
         'walletPassphrase':
         'walletPassphrase',
         'network':
         'standard',
         'parentInterface':
         '',
         'tfchainFlist':
         'https://hub.gig.tech/tfchain/ubuntu-16.04-tfchain-latest.flist',
     }
     config.DATA_DIR = tempfile.mkdtemp(prefix='0-templates_')
     cls.type = template_collection._load_template(
         "https://github.com/threefoldtoken/0-templates",
         os.path.dirname(__file__))
Beispiel #9
0
 def _load_template(self, name):
     """
     name of the template to load from the
     fixtures/templates folder
     """
     dir_path = os.path.dirname(os.path.realpath(__file__))
     tmpl = _load_template("https://github.com/threefoldtech/0-robot",
                           os.path.join(dir_path, 'fixtures', 'templates', name))
     return tmpl
Beispiel #10
0
 def setUp(self):
     config.DATA_DIR = '/tmp'
     self.type = template_collection._load_template(
         "https://github.com/openvcloud/0-templates",
         os.path.dirname(__file__))
     # define properties of space mock
     space_mock = MagicMock(model={'acl': []})
     acc_mock = MagicMock(space_get=MagicMock(return_value=space_mock))
     self.ovc_mock = MagicMock(account_get=MagicMock(return_value=acc_mock))
Beispiel #11
0
 def setUpClass(cls):
     cls.valid_data = {
         'node': 'node',
         'container': 'container',
         'rpcPort': 23112,
         'apiPort': 23110,
         'intervalScanNetwork': 3600,
         'intervalAddPeer': 300,
         'discoveredPeers': [],
     }
     config.DATA_DIR = tempfile.mkdtemp(prefix='0-templates_')
     cls.type = template_collection._load_template(
         "https://github.com/threefoldtoken/0-templates",
         os.path.dirname(__file__))
Beispiel #12
0
    def setUp(self):
        config.DATA_DIR = '/tmp'
        self.type = template_collection._load_template(
            "https://github.com/openvcloud/0-templates",
            os.path.dirname(__file__))

        self.ovc = {
            'service': 'test_ovc_service',
            'info': {
                'name': 'connection_instance_name'
            }
        }
        self.acc = {
            'service': 'test_account-service',
            'info': {
                'name': 'test_account_real_name',
                'openvcloud': self.ovc['service']
            }
        }
        self.vdc = {
            'service': 'test-vdc-service',
            'info': {
                'name': 'test_vdc_real_name',
                'account': self.acc['service']
            }
        }
        self.disk = {
            'service': 'test_disk_service',
            'info': {
                'name': 'disk_real_name',
                'vdc': self.vdc['service'],
                'diskId': 1,
                'diskType': 'D',
            },
        }
        self.sshkey = {
            'service': 'test_node_service',
            'info': {
                'name': 'test_sshkey_name',
            }
        }
        self.node = {
            'service': 'test_node_service',
            'info': {
                'name': 'test_node_name',
                'vdc': self.vdc['service'],
                'sshKey': self.sshkey['service']
            }
        }
Beispiel #13
0
 def setUp(self):
     config.DATA_DIR = '/tmp'
     self.type = template_collection._load_template(
         "https://github.com/openvcloud/0-templates",
         os.path.dirname(__file__))
     # define properties of space mock
     self.initial_user = {
         'name': 'initial_user@itsyouonline',
         'accesstype': 'ACDRUX'
     }
     space_mock = MagicMock(
         model={
             'acl': [{
                 'userGroupId': self.initial_user['name'],
                 'right': self.initial_user['accesstype']
             }]
         })
     acc_mock = MagicMock(space_get=MagicMock(return_value=space_mock))
     self.ovc_mock = MagicMock(account_get=MagicMock(return_value=acc_mock))
Beispiel #14
0
    def setUp(self):
        config.DATA_DIR = '/tmp'
        self.type = template_collection._load_template(
            "https://github.com/openvcloud/0-templates",
            os.path.dirname(__file__))

        self.valid_data = {'vdc': 'test_vdc', 'name': 'test_disk'}
        self.location = {'name': 'be-gen-demo', 'gid': 123}

        self.ovc = {
            'service': 'test_ovc_service',
            'info': {
                'name': 'connection_instance_name'
            }
        }
        self.acc = {
            'service': 'test_account_service',
            'info': {
                'name': 'test_account_real_name',
                'openvcloud': self.ovc['service']
            }
        }
        self.vdc = {
            'service': 'test_vdc_service',
            'info': {
                'name': 'test_vdc_real_name',
                'account': self.acc['service']
            }
        }
        self.disk = {
            'service': 'test_disk_service',
            'info': {
                'name': 'disk_real_name',
                'vdc': self.vdc['service'],
                'diskId': '1111',
                'diskType': 'D',
            },
        }
Beispiel #15
0
 def setUp(self):
     config.DATA_DIR = '/tmp'
     self.type = template_collection._load_template(
         "https://github.com/openvcloud/0-templates",
         os.path.dirname(__file__))
Beispiel #16
0
    def setUp(self):
        config.DATA_DIR = '/tmp'
        self.type = template_collection._load_template(
            "https://github.com/openvcloud/0-templates",
            os.path.dirname(__file__))

        self.ovc = {
            'service': 'test_ovc_service',
            'info': {
                'name': 'connection_instance_name'
            }
        }
        self.acc = {
            'service': 'test_account_service',
            'info': {
                'name': 'test_account',
                'openvcloud': self.ovc['service']
            }
        }
        self.vdc = {
            'service': 'test_vdc_service',
            'info': {
                'name': 'test_vdc',
                'account': self.acc['service']
            }
        }
        self.vdcuser = {
            'service': 'test_vdcuser_service',
            'base_name': 'test_vdcuser',
            'accesstype': 'R',
            'info': {
                'name': 'test_vdcuser@itsyouonline',
                'openvcloud': self.ovc['service']
            }
        }
        self.new_vdcuser = {
            'service': 'new_test_vdcuser_service',
            'base_name': 'new_test_user',
            'accesstype': 'RCX',
            'info': {
                'name': 'new_test_user@itsyouonline',
                'openvcloud': self.ovc['service']
            }
        }
        self.node = {
            'service': 'test_node_service',
            'info': {
                'name': 'test_node_name',
                'vdc': self.vdc['service'],
                'id': 123
            }
        }
        # set up existing user
        self.user = {
            'service': self.vdcuser['service'],
            'info': {
                'name': self.vdcuser['info']['name'],
                'accesstype': 'R'
            }
        }
        # set up new user
        self.new_user = {
            'service': self.new_vdcuser['service'],
            'info': {
                'name': self.new_vdcuser['info']['name'],
                'accesstype': 'RCX'
            }
        }