Esempio n. 1
0
    def set_folder(self, folder):
        """ Set Folder """
        if not folder:
            msg = 'set_folder failed: No folder specified!'
            Log.error('System', msg)
            raise exceptions.SystemUpdateException(msg)

        if not self.folder_exists(folder):
            msg = 'set_folder:set_active_folder failed, ' + \
                  'folder does not exist!'
            Log.error('System', msg)
            raise exceptions.SystemUpdateException(msg)

        if not str(folder).startswith('/'):
            folder = '/' + folder
        if self.current_folder and folder == self.current_folder:
            return
        try:
            self.sys_session.set_active_folder(folder)
            self.current_folder = folder
        except WebFault as webfault:
            Log.error(
                'System', 'set_folder:set_active_folder failed: ' +
                str(webfault.message))
            raise exceptions.SystemUpdateException(webfault.message)
Esempio n. 2
0
 def set_provision_extramb(self, extramdb=500):
     request_url = self.bigip.icr_url + '/sys/db/provision.extramb'
     response = self.bigip.icr_session.put(request_url,
                                           data=json.dumps(
                                               {'value': extramdb}),
                                           timeout=const.CONNECTION_TIMEOUT)
     if response.status_code < 400:
         return True
     else:
         raise exceptions.SystemUpdateException(response.text)
Esempio n. 3
0
 def set_hostname(self, hostname):
     request_url = self.bigip.icr_url + '/sys/global-settings'
     response = self.bigip.icr_session.put(request_url,
                                           data=json.dumps(
                                               {'hostname': hostname}),
                                           timeout=const.CONNECTION_TIMEOUT)
     if response.status_code < 400:
         return True
     else:
         raise exceptions.SystemUpdateException(response.text)
Esempio n. 4
0
 def set_ntp_server(self, addr):
     request_url = self.bigip.icr_url + '/sys/ntp'
     if not isinstance(addr, list):
         addr = [addr]
     response = self.bigip.icr_session.put(request_url,
                                           data=json.dumps(
                                               {'servers': addr}),
                                           timeout=const.CONNECTION_TIMEOUT)
     if response.status_code < 400:
         return True
     else:
         raise exceptions.SystemUpdateException(response.text)
Esempio n. 5
0
 def set_folder(self, folder):
     if folder:
         if not self.folder_exists(folder):
             self.create_folder_and_domain(folder, self.bigip)
         else:
             if not str(folder).startswith('/'):
                 folder = '/' + folder
             if self.current_folder and folder == self.current_folder:
                 return
             try:
                 self.sys_session.set_active_folder(folder)
                 self.current_folder = folder
             except WebFault as wf:
                 Log.error('System',
                       'set_folder:set_active_folder failed: ' + \
                       str(wf.message))
                 raise exceptions.SystemUpdateException(wf.message)
Esempio n. 6
0
    def force_to_standby(self, traffic_group):
        """ Force traffic group to standby """
        request_url = self.bigip.icr_url + '/sys/failover'

        payload = dict()
        payload['command'] = 'run'
        payload['standby'] = None
        payload['trafficGroup'] = traffic_group

        response = self.bigip.icr_session.post(
            request_url, data=json.dumps(payload),
            timeout=const.CONNECTION_TIMEOUT)
        if response.status_code < 400:
            return True

        Log.error('traffic-group', response.text)
        raise exceptions.SystemUpdateException(response.text)
Esempio n. 7
0
 def set_tunnel_sync(self, enabled=False):
     """ Set option for syncing tunnels """
     request_url = self.bigip.icr_url + '/sys/db/iptunnel.configsync'
     if enabled:
         response = self.bigip.icr_session.put(
             request_url, data=json.dumps({'value': 'enable'}),
             timeout=const.CONNECTION_TIMEOUT)
     else:
         response = self.bigip.icr_session.put(
             request_url, data=json.dumps({'value': 'disable'}),
             timeout=const.CONNECTION_TIMEOUT)
     if response.status_code < 400:
         response_obj = json.loads(response.text)
         if 'value' in response_obj:
             return response_obj['value']
         return None
     elif response.status_code != 404:
         raise exceptions.SystemUpdateException(response.text)