Example #1
0
 def testArraySubstitution(self):
     patches = {'Pool': [{'match_name': 'p1', 'patch': {'servers': []}}]}
     cp = ConfigPatch(self.acfg, patches)
     patched_cfg = cp.patch()
     pools = patched_cfg.get('Pool')
     patched_pool = [pool for pool in pools if pool['name'] == 'p1']
     assert patched_pool
     assert not patched_pool[0]['servers']
Example #2
0
    def process_for_utils(self, avi_config):
        """
        Check if patch args present then execute the config_patch.py with args
        :param avi_config: converted avi object dict
        :return: avi_config
        """

        if self.patch:
            with open(self.patch) as f:
                patches = yaml.load(f)
            cp = ConfigPatch(avi_config, patches)
            avi_config = cp.patch()
        # Check if vs_filter args present then execute vs_filter.py with args
        if self.vs_filter:
            avi_config = filter_for_vs(avi_config, self.vs_filter)
        return avi_config
Example #3
0
    def process_for_utils(self, avi_config):
        """
        Check if patch args present then execute the config_patch.py with args
        :param avi_config: converted avi object dict
        :return: avi_config
        """

        if self.patch:
            with open(self.patch) as f:
                patches = yaml.load(f)
            cp = ConfigPatch(avi_config, patches)
            avi_config = cp.patch()
        # Check if vs_filter args present then execute vs_filter.py with args
        if self.vs_filter:
            avi_config = filter_for_vs(avi_config, self.vs_filter)
        return avi_config
Example #4
0
 def testArraySubstitution(self):
     patches = {
         'Pool': [
             {
                 'match_name': 'p1',
                 'patch': {
                     'servers': []
                 }
             }
         ]
     }
     cp = ConfigPatch(self.acfg, patches)
     patched_cfg = cp.patch()
     pools = patched_cfg.get('Pool')
     patched_pool = [pool for pool in pools if pool['name'] == 'p1']
     assert patched_pool
     assert not patched_pool[0]['servers']
Example #5
0
    def testBasicRun(self):
        cp = ConfigPatch(self.acfg, self.patches)
        patched_cfg = cp.patch()
        assert patched_cfg

        pools = patched_cfg.get('Pool')
        patched_pool = [pool for pool in pools if pool['name'] == 'coolpool']
        assert patched_pool

        vs = [vs for vs in patched_cfg.get('VirtualService') if vs['name'] == 'vs1']
        assert vs
        print json.dumps(vs, indent=2)
        assert vs[0]['pool_ref'] == '/api/pool/?tenant=admin&name=coolpool&cloud=AWS'
        cicd_pools = [pool for pool in pools if pool['name'].find('cicd') != -1]
        for p in cicd_pools:
            assert p['enabled'] is False
            assert p['tenant_ref'] == '/api/tenant/?name=awesome'