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

def sdt(self):

    self.module.debug('Running    Host.sdt...')
    if self.info:
        self.module.debug('System    changed')
        self.change = True
        if self.check_mode:
            self.exit(changed=True)
        duration = self.duration
        starttime = self.starttime
        offset = 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 = {'hostId': self.info['id'], 'type': 1, '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    'setHostSDT'")
        resp = json.loads(self.rpc('setHostSDT', 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'])
    else:
        self.fail(msg="Error:    Host    doesn't    exit.")
