Skip to content

Commit

Permalink
Updating to Service Fabric 6.0 SDK (#35)
Browse files Browse the repository at this point in the history
* Updating dependent packages

* Updating dependent packages

* Adding 6.0 runtime information

* Fixing cluster report-health command

* First cut cluster upgrade

* Adding missing files

* Fixing messed up help

* First pass on sa cluster upgrade

* Adding missed command mapping

* Renaming and fixing

* Adding update-upgrade command

* Removed deprecated node commands

* Adding application load command

* Adding application list new int argument

* Adding application report-health documentation

* Fixing application upgrade doc string

* Adding service create comment on new names

* Adding service update updated docstring

* Adding immediate arg to report service health

* Adding custom partition health and also repair manager commands

* Adding replica report health helps

* starting compose rename

* Adding compose upgrade support

* Adding new files

* moving compose create to new API and seperate file

* Removing old compose app command

* Fixing PyLint

* Fixing PyLint

* Adding histor

* Removing whitespace
  • Loading branch information
samedder committed Sep 25, 2017
1 parent 5cbf448 commit 3985d25
Show file tree
Hide file tree
Showing 16 changed files with 1,608 additions and 422 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Expand Up @@ -50,7 +50,7 @@ confidence=
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
# --disable=W"
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,too-many-arguments
disable=print-statement,parameter-unpacking,unpacking-in-except,old-raise-syntax,backtick,long-suffix,old-ne-operator,old-octal-literal,import-star-module-level,raw-checker-failed,bad-inline-option,locally-disabled,locally-enabled,file-ignored,suppressed-message,useless-suppression,deprecated-pragma,apply-builtin,basestring-builtin,buffer-builtin,cmp-builtin,coerce-builtin,execfile-builtin,file-builtin,long-builtin,raw_input-builtin,reduce-builtin,standarderror-builtin,unicode-builtin,xrange-builtin,coerce-method,delslice-method,getslice-method,setslice-method,no-absolute-import,old-division,dict-iter-method,dict-view-method,next-method-called,metaclass-assignment,indexing-exception,raising-string,reload-builtin,oct-method,hex-method,nonzero-method,cmp-method,input-builtin,round-builtin,intern-builtin,unichr-builtin,map-builtin-not-iterating,zip-builtin-not-iterating,range-builtin-not-iterating,filter-builtin-not-iterating,using-cmp-argument,eq-without-hash,div-method,idiv-method,rdiv-method,exception-message-attribute,invalid-str-codec,sys-max-int,bad-python3-import,deprecated-string-function,deprecated-str-translate-call,too-many-arguments,duplicate-code

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
1 change: 1 addition & 0 deletions .vscode/cSpell.json
Expand Up @@ -9,6 +9,7 @@
"JMES",
"Stateful",
"Unmonitored",
"creds",
"isdir",
"isfile",
"opencode",
Expand Down
20 changes: 20 additions & 0 deletions src/README.rst
Expand Up @@ -16,6 +16,26 @@ To get started, after installation run the following:
Change Log
==========

2.0.0
-----

- Update to official 6.0 Service Fabric SDK
- Report cluster health command added
- Report health commands now have an immediate argument to tell the Fabric
gateway to send the report immeditately
- Get cluster configuration and upgrade configuration for stand alone clusters
commands added
- Added start and update cluster upgrade commands
- Start node command removed (use enable node)
- Stop node command removed (use disable node)
- Added information about new Fabric name hierarchical delimiter (~)
- Health commands now include statistics, can be optionally removed
- Limited set of repair manager commands added
- Infrastructure service commands no longer accept a callback function
- Docker compose commands have had arguments renamed to reflect Service Fabric
API changes
- Added support to upgrade Docker compose deployments

1.2.0rc2
--------

Expand Down
4 changes: 2 additions & 2 deletions src/setup.py
Expand Up @@ -17,7 +17,7 @@ def read(fname):

setup(
name='sfctl',
version='1.2.0rc2',
version='2.0.0',
description='Azure Service Fabric command line',
long_description=read('README.rst'),
url='https://github.com/Azure/service-fabric-cli',
Expand Down Expand Up @@ -46,7 +46,7 @@ def read(fname):
'knack==0.1.1',
'msrest>=0.4.4',
'requests',
'sfctl-azure-servicefabric==6.0.0rc1',
'azure-servicefabric==6.0',
'jsonpickle'
],
extras_require={
Expand Down
49 changes: 42 additions & 7 deletions src/sfctl/commands.py
Expand Up @@ -17,6 +17,9 @@
# Need to import so global help dict gets updated
import sfctl.helps.app # pylint: disable=unused-import
import sfctl.helps.main # pylint: disable=unused-import
import sfctl.helps.health # pylint: disable=unused-import
import sfctl.helps.cluster_upgrade # pylint: disable=unused-import
import sfctl.helps.compose # pylint: disable=unused-import

class SFCommandHelp(CLIHelp):
"""Service Fabric CLI help loader"""
Expand All @@ -36,6 +39,18 @@ def load_command_table(self, args): #pylint: disable=too-many-statements
client_func_path = 'azure.servicefabric#ServiceFabricClientAPIs.{}'
with CommandSuperGroup(__name__, self, client_func_path,
client_factory=client_create) as super_group:

with super_group.group('rpm') as group:
group.command('delete', 'delete_repair_task')
group.command('list', 'get_repair_task_list')
group.command('approve-force', 'force_approve_repair_task')


with super_group.group('sa-cluster') as group:
group.command('config', 'get_cluster_configuration')
group.command('upgrade-status',
'get_cluster_configuration_upgrade_status')

with super_group.group('cluster') as group:
group.command('health', 'get_cluster_health')
group.command('manifest', 'get_cluster_manifest')
Expand All @@ -51,6 +66,10 @@ def load_command_table(self, args): #pylint: disable=too-many-statements
group.command('recover-system', 'recover_system_partitions')
group.command('operation-list', 'get_fault_operation_list')
group.command('operation-cancel', 'cancel_operation')
group.command('provision', 'provision_cluster')
group.command('unprovision', 'unprovision_cluster')
group.command('upgrade-rollback', 'rollback_cluster_upgrade')
group.command('upgrade-resume', 'resume_cluster_upgrade')

with super_group.group('node') as group:
group.command('list', 'get_node_info_list')
Expand All @@ -60,8 +79,6 @@ def load_command_table(self, args): #pylint: disable=too-many-statements
group.command('disable', 'disable_node')
group.command('enable', 'enable_node')
group.command('remove-state', 'remove_node_state')
group.command('start', 'start_node')
group.command('stop', 'stop_node')
group.command('restart', 'restart_node')
group.command('transition', 'start_node_transition')
group.command(
Expand Down Expand Up @@ -94,6 +111,7 @@ def load_command_table(self, args): #pylint: disable=too-many-statements
'get_deployed_application_health'
)
group.command('manifest', 'get_application_manifest')
group.command('load', 'get_application_load_info')

with super_group.group('service') as group:
group.command('type-list', 'get_service_type_info_list')
Expand Down Expand Up @@ -166,9 +184,11 @@ def load_command_table(self, args): #pylint: disable=too-many-statements
group.command('remove', 'remove_replica')

with super_group.group('compose') as group:
group.command('status', 'get_compose_application_status')
group.command('list', 'get_compose_application_status_list')
group.command('remove', 'remove_compose_application')
group.command('status', 'get_compose_deployment_status')
group.command('list', 'get_compose_deployment_status_list')
group.command('remove', 'remove_compose_deployment')
group.command('upgrade-status',
'get_compose_deployment_upgrade_progress')

with super_group.group('chaos') as group:
group.command('stop', 'stop_chaos')
Expand All @@ -185,10 +205,23 @@ def load_command_table(self, args): #pylint: disable=too-many-statements

# Custom commands

with CommandSuperGroup(__name__, self, 'sfctl.custom_app#{}',
with CommandSuperGroup(__name__, self,
'sfctl.custom_cluster_upgrade#{}',
client_factory=client_create) as super_group:
with super_group.group('cluster') as group:
group.command('upgrade', 'upgrade')
group.command('upgrade-update', 'update_upgrade')
with super_group.group('sa-cluster') as group:
group.command('config-upgrade', 'sa_configuration_upgrade')

with CommandSuperGroup(__name__, self, 'sfctl.custom_compose#{}',
client_factory=client_create) as super_group:
with super_group.group('compose') as group:
group.command('create', 'create_compose_application')
group.command('upgrade', 'upgrade')
group.command('create', 'create')

with CommandSuperGroup(__name__, self, 'sfctl.custom_app#{}',
client_factory=client_create) as super_group:
with super_group.group('application') as group:
group.command('create', 'create')
group.command('upgrade', 'upgrade')
Expand Down Expand Up @@ -220,6 +253,8 @@ def load_command_table(self, args): #pylint: disable=too-many-statements
group.command('report-health', 'report_replica_health')
with super_group.group('node') as group:
group.command('report-health', 'report_node_health')
with super_group.group('cluster') as group:
group.command('report-health', 'report_cluster_health')

with CommandSuperGroup(__name__, self, 'sfctl.custom_service#{}',
client_factory=client_create) as super_group:
Expand Down
89 changes: 1 addition & 88 deletions src/sfctl/custom_app.py
Expand Up @@ -13,48 +13,6 @@
import shutil
from knack.util import CLIError

def create_compose_application(client, compose_file, application_id,
repo_user=None, encrypted=False,
repo_pass=None, timeout=60):
"""
Creates a Service Fabric application from a Compose file
:param str application_id: The id of application to create from
Compose file. This is typically the full id of the application
including "fabric:" URI scheme
:param str compose_file: Path to the Compose file to use
:param str repo_user: Container repository user name if needed for
authentication
:param bool encrypted: If true, indicate to use an encrypted password
rather than prompting for a plaintext one
:param str repo_pass: Encrypted container repository password
"""
from azure.servicefabric.models.create_compose_application_description import CreateComposeApplicationDescription # pylint: disable=line-too-long
from azure.servicefabric.models.repository_credential import (
RepositoryCredential
)
from getpass import getpass

if (any([encrypted, repo_pass]) and
not all([encrypted, repo_pass, repo_user])):
raise CLIError('Invalid credentials syntax')

if repo_user and not repo_pass:
repo_pass = getpass('Repository password: ')

repo_cred = RepositoryCredential(repo_user, repo_pass, encrypted)

file_contents = None
with open(compose_file) as f_desc:
file_contents = f_desc.read()
if not file_contents:
raise CLIError('Could not read {}'.format(compose_file))

model = CreateComposeApplicationDescription(application_id, file_contents,
repo_cred)

client.create_compose_application(model, timeout)


def validate_app_path(app_path):
"""Validate and return application package as absolute path"""

Expand Down Expand Up @@ -292,7 +250,7 @@ def create(client, # pylint: disable=too-many-locals,too-many-arguments

client.create_application(app_desc, timeout)

def upgrade( # pylint: disable=too-many-arguments,too-many-locals
def upgrade( # pylint: disable=too-many-arguments,too-many-locals,missing-docstring
client, app_id, app_version, parameters, mode="UnmonitoredAuto",
replica_set_check_timeout=None, force_restart=None,
failure_action=None, health_check_wait_duration="0",
Expand All @@ -303,51 +261,6 @@ def upgrade( # pylint: disable=too-many-arguments,too-many-locals
warning_as_error=False,
max_unhealthy_apps=0, default_service_health_policy=None,
service_health_policy=None, timeout=60):
"""
Starts upgrading an application in the Service Fabric cluster.
Validates the supplied application upgrade parameters and starts upgrading
the application if the parameters are valid. Please note that upgrade
description replaces the existing application description. This means that
if the parameters are not specified, the existing parameters on the
applications will be overwritten with the empty parameters list. This
would results in application using the default value of the parameters
from the application manifest.
:param str app_id: The identity of the application. This is typically the
full name of the application without the 'fabric:' URI scheme.
:param str app_version: The target application type version (found in the
application manifest) for the application upgrade.
:param str parameters: A JSON encoded list of application parameter
overrides to be applied when upgrading the application.
:param str mode: The mode used to monitor health during a rolling upgrade.
:param int replica_set_check_timeout: The maximum amount of time to block
processing of an upgrade domain and prevent loss of availability when
there are unexpected issues. Measured in seconds.
:param bool force_restart: Forcefully restart processes during upgrade even
when the code version has not changed.
:param str failure_action: The action to perform when a Monitored upgrade
encounters monitoring policy or health policy violations.
:param str health_check_wait_duration: The amount of time to wait after
completing an upgrade domain before applying health policies. Measured in
milliseconds.
:param str health_check_stable_duration: The amount of time that the
application or cluster must remain healthy before the upgrade proceeds
to the next upgrade domain. Measured in milliseconds.
:param str health_check_retry_timeout: The amount of time to retry health
evaluations when the application or cluster is unhealthy before the failure
action is executed. Measured in milliseconds.
:param str upgrade_timeout: The amount of time the overall upgrade has to
complete before FailureAction is executed. Measured in milliseconds.
:param str upgrade_domain_timeout: The amount of time each upgrade domain
has to complete before FailureAction is executed. Measured in milliseconds.
:param bool warning_as_error: Treat health evaluation warnings with the
same severity as errors.
:param int max_unhealthy_apps: The maximum allowed percentage of unhealthy
deployed applications. Represented as a number between 0 and 100.
:param str default_service_health_policy: JSON encoded specification of the
health policy used by default to evaluate the health of a service type.
:param str service_health_policy: JSON encoded map with service type health
policy per service type name. The map is empty be default.
"""
from azure.servicefabric.models.application_upgrade_description import (
ApplicationUpgradeDescription
)
Expand Down

0 comments on commit 3985d25

Please sign in to comment.