'Create a scheduled down time
(maintenance window) for this host'

def sdt(self):

    self.module.debug('Running    Datasource.sdt...')
    self.module.debug('System    changed')
    self.change = True
    if self.check_mode:
        self.exit(changed=True)
    duration = self.duration
    starttime = self.starttime
    offsetstart = starttime
    if starttime:
        self.module.debug('Start    time    specified')
        start = datetime.datetime.strptime(starttime, '%Y-%m-%d    %H:%M')
        offsetstart = start
    else:
        self.module.debug('No    start    time    specified.    Using    default.')
        start = datetime.datetime.utcnow()
        self.module.debug("Making    RPC    call    to    'getTimeZoneSetting'")
        accountresp = json.loads(self.rpc('getTimeZoneSetting', {}))
        if (accountresp['status'] == 200):
            self.module.debug('RPC    call    succeeded')
            offset = accountresp['data']['offset']
            offsetstart = (start + datetime.timedelta(0, offset))
        else:
            self.fail(msg='Error:    Unable    to    retrieve    timezone    offset')
    offsetend = (offsetstart + datetime.timedelta(0, (int(duration) * 60)))
    h = {'hostDataSourceId': self.id, 'type': 1, 'notifyCC': True, 'year': offsetstart.year, 'month': (offsetstart.month - 1), 'day': offsetstart.day, 'hour': offsetstart.hour, 'minute': offsetstart.minute, 'endYear': offsetend.year, 'endMonth': (offsetend.month - 1), 'endDay': offsetend.day, 'endHour': offsetend.hour, 'endMinute': offsetend.minute}
    self.module.debug("Making    RPC    call    to    'setHostDataSourceSDT'")
    resp = json.loads(self.rpc('setHostDataSourceSDT', h))
    if (resp['status'] == 200):
        self.module.debug('RPC    call    succeeded')
        return resp['data']
    else:
        self.module.debug('RPC    call    failed')
        self.fail(msg=resp['errmsg'])
