Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/cdpy/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ def _warning_format(message, category, filename, lineno, line=None):
'EXTERNAL_DATABASE_STOP_IN_PROGRESS',
'STOP_IN_PROGRESS',
'STOPPED',
'ENV_STOPPED'
'ENV_STOPPED',
'NOT_ENABLED' # DF
]

self.FAILED_STATES = [
Expand All @@ -193,7 +194,7 @@ def _warning_format(message, category, filename, lineno, line=None):
'DELETE_FAILED',
'Error', # DW
'installation:failed', # ML
'BAD_HEALTH' # DF
'BAD_HEALTH', # DF
]

self.REMOVABLE_STATES = [
Expand Down
18 changes: 14 additions & 4 deletions src/cdpy/df.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from cdpy.common import CdpSdkBase, Squelch
from cdpy.common import CdpSdkBase, Squelch, CdpError


class CdpyDf(CdpSdkBase):
Expand Down Expand Up @@ -37,9 +37,19 @@ def enable_environment(self, env_crn: str, authorized_ips: list = None, min_node
usePublicLoadBalancer=enable_public_ip, authorizedIpRanges=authorized_ips
)

def disable_environment(self, env_crn: str, persist: bool = False):
def disable_environment(self, env_crn: str, persist: bool = False, force: bool = False):
self.sdk.validate_crn(env_crn)
return self.sdk.call(
svc='df', func='disable_environment', ret_field='status',
resp = self.sdk.call(
svc='df', func='disable_environment', ret_field='status', ret_error=True,
crn=env_crn, persist=persist
)
if isinstance(resp, CdpError):
if force:
return self.sdk.call(
svc='df', func='delete_environment',
crn=env_crn
)
else:
resp.update(message=resp.violations)
self.sdk.throw_error(resp)
return resp