예제 #1
0
파일: adccore.py 프로젝트: jonozzz/nosest
    def run(self):
        super(CreatePoolOnBigiq, self).run()
        LOG.debug('starting create_pool_on_bigiq')
        device_ref = {
            'link':
            'https://localhost' + DeviceResolver.DEVICE_URI %
            (DEFAULT_CM_ADC_DEVICE_GROUP, self.device_id)
        }
        payload = WorkingLtmPool(name=self.name,
                                 partition=self.partition,
                                 deviceReference=device_ref,
                                 loadBalancingMode=self.load_balancing_mode)

        for attrib in self.optional_attributes:
            if getattr(self, attrib) is not None:
                setattr(payload, attrib, getattr(self, attrib))

        response = self.api.post(WorkingLtmPool.URI, payload)

        # Attach pool members after we get the pool's ID
        for node_name, port in self.members:
            nodes = filter_search_for_item(WorkingLtmNode.URI,
                                           'name',
                                           node_name,
                                           return_top_result=False)
            # Just in case you did a bad thing and have multiple nodes with the same names on different devices.
            node = [
                x for x in nodes if x.deviceReference.id == self.device_id
            ][0]
            add_pool_member_to_bigiq_virtual(response.id, node.selfLink, port)

        return response
예제 #2
0
파일: adccore.py 프로젝트: jonozzz/nosest
    def setup(self):
        super(RefreshAdcCurrentConfig, self).setup()
        LOG.info("refresh current config on {0}".format(
            str(self.device.get_discover_address())))
        machine_id = get_machine_id(self.device)

        existing_discovery_task = filter_search_for_item(
            base_uri=DeviceDiscovery.URI,
            search_key='deviceReference/link',
            search_value='*' + machine_id)

        module_list = [{'module': CM_GLOBAL_ADC_NAME}]
        payload = DeviceDiscovery(moduleList=module_list, status='STARTED')
        self.set_uri(existing_discovery_task)
        self.api.patch(self.uri, payload=payload)
        resp = wait_args(
            self.api.get,
            func_args=[self.uri],
            condition=lambda x: x.status in DeviceDiscovery.FINAL_STATUSES,
            interval=10,
            timeout=self.timeout,
            timeout_message='Re-discovery did not complete in {0} seconds')
        if resp.status == DeviceDiscovery.FAIL_STATE:
            raise TaskError(
                "Re-discovery failed for {0} for ADC service".format(
                    self.device.get_discover_address()))
예제 #3
0
파일: system.py 프로젝트: jonozzz/nosest
    def setup(self):
        if self.service == CM_GLOBAL_ACCESS_NAME:
            # access has their own solution
            return

        LOG.debug('ImportServiceConfig.setup()')

        LOG.info('Finding existing import task...')
        device_reference_link = 'https://localhost' + MachineIdResolver.URI + '/' + self.machineid
        old_task = filter_search_for_item(base_uri=self.uri,
                                          search_key='deviceReference/link',
                                          search_value=device_reference_link,
                                          ifc=self.ifc)
        if old_task:
            LOG.info('Deleting existing import task...')
            self.api.delete("{0}/{1}".format(self.uri, old_task.id))

        if self.from_bigiq:
            resolution = 'USE_BIGIQ'
        else:
            resolution = 'USE_BIGIP'

        LOG.info("import {0} config for {1}...".format(self.service, self.device.get_discover_address()))
        dma = CmTask(createChildTask=self.create_child_tasks,
                     skipDiscovery=True,
                     deviceReference={'link': 'https://localhost' + MachineIdResolver.ITEM_URI % self.machineid},
                     snapshotWorkingConfig=self.snapshot_working_config)
        if self.cluster:
            dma.clusterName = self.cluster
        if self.bypass_validation:
            dma.validationBypassMode = "BYPASS_ALL"
        task = self.api.post(self.uri, payload=dma)

        def wait_for_conflicts():
            resp = self.api.get(task.selfLink)
            if (resp.status not in ('STARTED',) and
                    resp.currentStep in ('PENDING_CONFLICTS', 'PENDING_CHILD_CONFLICTS')):
                LOG.info('Conflicts detected, setting resolution: %s' % resolution)
                payload = Options(status='STARTED',
                                  conflicts=resp.conflicts[:])
                for conflict in payload.conflicts:
                    conflict.resolution = resolution
                resp = self.api.patch(task.selfLink, payload=payload)
            return resp
        # emulate CmTask Wait without the babbling
        wait(wait_for_conflicts, timeout=self.timeout, interval=2,
             condition=lambda x: x.status != 'CREATED',
             timeout_message="DMA task did not create in {0} seconds")
        resp = wait(wait_for_conflicts, timeout=self.timeout, interval=3,
                    condition=lambda x: x.status != 'STARTED',
                    timeout_message="DMA task did not complete in {0} seconds")
        if resp.status == dma.FAIL_STATE:
            raise ImportServiceException("{0} import config for {1} Failed resp:{2.errorMessage}".format(self.service,
                                                                                            self.device.get_discover_address(),
                                                                                            resp),
                                         address=self.device.get_discover_address(), service=self.service)
예제 #4
0
파일: adccore.py 프로젝트: jonozzz/nosest
    def run(self):
        super(CreateSelfipOnBigiq, self).run()
        LOG.debug('starting create_selfip_on_bigiq')
        device_ref = {
            'link':
            'https://localhost' + DeviceResolver.DEVICE_URI %
            (DEFAULT_CM_ADC_DEVICE_GROUP, self.device_id)
        }
        payload = WorkingNetSelfIp(name=self.name,
                                   partition=self.partition,
                                   deviceReference=device_ref,
                                   address=self.address,
                                   floating=self.floating)

        _, vlan_partition, vlan_name = self.vlan.split(
            '/')  # Hopefully no one is silly and uses a vlan with a subPath

        vlans = filter_search_for_item(WorkingNetVlan.URI,
                                       'name',
                                       vlan_name,
                                       return_top_result=False)
        vlan_link = [
            x.selfLink for x in vlans if x.deviceReference.id == self.device_id
            and x.partition == vlan_partition
        ][0]
        payload.vlanReference = {'link': vlan_link}

        if self.trafficGroup:
            traffic_group_link = filter_search_for_item(
                WorkingNetTrafficGroup.URI, 'name', self.trafficGroup).selfLink
            payload.trafficGroupReference = {'link': traffic_group_link}

        for attrib in self.simple_optional_attributes:
            if getattr(self, attrib) is not None:
                setattr(payload, attrib, getattr(self, attrib))

        response = self.api.post(WorkingNetSelfIp.URI, payload)

        return response
예제 #5
0
파일: adccore.py 프로젝트: jonozzz/nosest
 def setup(self):
     super(RefreshAdcWorkingConfig, self).setup()
     LOG.debug('RefreshAdcWorkingConfig.setup()')
     machine_id = get_machine_id(self.device)
     LOG.info('Finding existing import task...')
     old_task = filter_search_for_item(
         base_uri=AdcDeclareMgmtAuthorityTask.URI,
         search_key='deviceReference/link',
         search_value='*' + machine_id)
     LOG.info('Deleting existing import task...')
     # Hopefully we won't need to wait for this, but the response contains a job status,
     # so it might be possible that the delete won't finish quickly.
     delete_resp = self.api.delete(
         AdcDeclareMgmtAuthorityTask.URI_ITEM.format(old_task.id))
     LOG.info('Re-importing ADC...')
     import_service_config(self.device, CM_GLOBAL_ADC_NAME)
예제 #6
0
파일: adccore.py 프로젝트: jonozzz/nosest
    def run(self):
        super(CreateVirtualOnBigiq, self).run()
        LOG.debug('starting create_virtual_on_bigiq')
        device_ref = {
            'link':
            'https://localhost' + DeviceResolver.DEVICE_URI %
            (DEFAULT_CM_ADC_DEVICE_GROUP, self.device_id)
        }
        payload = WorkingLtmVip(name=self.name,
                                partition=self.partition,
                                deviceReference=device_ref,
                                sourceAddress=self.source_address,
                                destination=self.destination,
                                mask=self.mask)

        if self.pool_ref:
            payload.poolReference = self.pool_ref
        if self.description:
            payload.description = self.description
        if self.irules:
            irule_references = []
            for irule in self.irules:
                if isinstance(irule, dict):
                    irule_references.append(irule)
                else:
                    irule_references.append({
                        'link':
                        filter_search_for_item(WorkingLtmIrule.URI, 'name',
                                               irule).selfLink
                    })

            payload.iRuleReferences = irule_references

        if self.path:
            payload.subPath = self.path

        response = self.api.post(WorkingLtmVip.URI, payload)

        if self.profiles:
            add_profiles_to_bigiq_virtual(response.uuid,
                                          self.profiles,
                                          context='all')

        return response
예제 #7
0
파일: system.py 프로젝트: jonozzz/nosest
    def prep(self):
        super(AddServices, self).prep()
        machineid = get_machine_id(self.device, ifc=self.ifc)
        # asm and firewall require security_shared, add to list
        if ((CM_GLOBAL_ASM_NAME in self.services_list or
                CM_GLOBAL_FIREWALL_NAME in self.services_list) and
                CM_GLOBAL_SECURITY_NAME not in self.services_list):
            self.services_list.append(CM_GLOBAL_SECURITY_NAME)
        # locate existing task
        self.discover_task = filter_search_for_item(base_uri=DeviceDiscovery.URI,
                                                    search_key='deviceReference/link',
                                                    search_value='*' + machineid,
                                                    ifc=self.ifc)
        self.device_reference = {'link': 'https://localhost' + MachineIdResolver.ITEM_URI % machineid}

        if self.services_list:
            bad_names = set(self.services_list) - set(DeviceDiscovery.SERVICES)
            if bad_names:
                raise AddServiceException("{0} Invalid service(s) {1}".format(self.device.get_discover_address(), bad_names),
                                          address=self.device.get_discover_address(), service=bad_names)