Exemplo n.º 1
0
class CreateTeam(ctmcommands.cmd.CSKCommand):

    Description = 'Creates a new Team.'
    API = 'create_team'
    Examples = '''
    ctm-create-team -n "dev"
'''
    Options = [
        Param(name='name',
              short_name='n',
              long_name='name',
              optional=False,
              ptype='string',
              doc='A name for the new Team.'),
        Param(name='description',
              short_name='d',
              long_name='description',
              optional=True,
              ptype='string',
              doc='A description of the new Team'),
    ]

    def main(self):
        results = self.call_api(self.API, ['name', 'description'])
        print(results)
Exemplo n.º 2
0
class ListCanvasItems(ctmcommands.cmd.CSKCommand):

    Description = 'Lists Canvas Items'
    API = 'list_canvas_items'
    Examples = ''''''
    Options = [
        Param(name='project',
              short_name='p',
              long_name='project',
              optional=True,
              ptype='string',
              doc='Filter by a single Canvas Project.'),
        Param(
            name='component',
            short_name='c',
            long_name='component',
            optional=True,
            ptype='string',
            doc='Further filter a Project by Component. (project is required.)'
        ),
        Param(
            name='repository',
            short_name='r',
            long_name='repository',
            optional=True,
            ptype='string',
            doc='Specify either "file" or "db" repository. ("db" if omitted)')
    ]

    def main(self):
        results = self.call_api(self.API,
                                ['project', 'component', 'repository'])
        print(results)
Exemplo n.º 3
0
class InstallAddOn(ctmcommands.cmd.CSKCommand):

    Description = """Installs an Add-On from the VS-Exchange

Returns success or an error message."""

    API = 'install_add_on'
    Examples = ''''''
    Options = [
        Param(name='name',
              short_name='n',
              long_name='name',
              optional=False,
              ptype='string',
              doc='The name of the add-on to install from the VS-Exchange'),
        Param(
            name='team',
            short_name='t',
            long_name='team',
            optional=True,
            ptype='string',
            doc=
            """The name of the team in which to install any projects, packages, pipelines, and tasks included in this add-on.
                            Required if any any projects, packages, pipelines, or tasks exist in the add-on"""
        ),
    ]

    def main(self):
        results = self.call_api(self.API, ['name', 'team'])
        print(results)
Exemplo n.º 4
0
class RemoveTeamUser(ctmcommands.cmd.CSKCommand):

    Description = 'Remove the specified User from a Team.'
    API = 'remove_team_user'
    Examples = '''
    ctm-remove-team-user -t "dev team" -u "bob"
'''
    Options = [
        Param(name='team',
              short_name='t',
              long_name='team',
              optional=False,
              ptype='string',
              doc='Name or ID of the Team to change.'),
        Param(name='user',
              short_name='u',
              long_name='user',
              optional=False,
              ptype='string',
              doc='Name or ID of the User to remove.'),
        Param(
            name='default',
            short_name='d',
            long_name='default',
            optional=True,
            ptype='string',
            doc=
            'Users must be in at least one Team.  If the removal operation would leave this user Teamless, specify a new `Default` team for the User. Will attempt to use `Default` if omitted.'
        ),
    ]

    def main(self):
        results = self.call_api(self.API, ['team', 'user', 'default'])
        print(results)
Exemplo n.º 5
0
class AddProjectSource(ctmcommands.cmd.CSKCommand):

    Description = """ Adds a "Changes from" source to a Project. Will also mark a Project type as "Source".
    > Returns a CTM endpoint """
    API = 'add_project_source'
    Examples = '''
    ctm-add-project-source -p "ProjectName" -o "github"
'''
    Options = [
        Param(name='project',
              short_name='p',
              long_name='project',
              optional=False,
              ptype='string',
              doc='Value can be either a Project ID or Name.'),
        Param(name='origin',
              short_name='o',
              long_name='origin',
              optional=False,
              ptype='string',
              doc='Name of VCS to add to Project.'),
        Param(name='secret',
              short_name='s',
              long_name='secret',
              optional=True,
              ptype='string',
              doc='Webhook secret for GitHub.'),
    ]

    def main(self):
        results = self.call_api(self.API, ['project', 'origin', 'secret'])
        print(results)
Exemplo n.º 6
0
class AddTeamUser(ctmcommands.cmd.CSKCommand):

    Description = 'Add the specified User to a Team.'
    API = 'add_team_user'
    Examples = '''
    ctm-add-team-user -t "dev team" -u "bob" -r "User"
'''
    Options = [
        Param(name='team',
              short_name='t',
              long_name='team',
              optional=False,
              ptype='string',
              doc='Name or ID of the Team to change.'),
        Param(name='user',
              short_name='u',
              long_name='user',
              optional=False,
              ptype='string',
              doc='Name or ID of the User to add.'),
        Param(
            name='team_role',
            short_name='r',
            long_name='team_role',
            optional=False,
            ptype='string',
            doc=
            'Name of the Role for new user to adopt on new team. Please specify either "Team Administrator", "Developer", or "User".'
        ),
    ]

    def main(self):
        results = self.call_api(self.API, ['team', 'user', 'team_role'])
        print(results)
class ListPipelineGroups(ctmcommands.cmd.CSKCommand):

    Description = 'Lists all Pipeline Instance Groups.'
    API = 'list_pipelinegroups'
    Examples = '''
_List all Pipeline Instance Groups

    ctm-list-pipelinegroups
'''
    Options = [Param(name='pipeline', short_name='p', long_name='pipeline',
                     optional=True, ptype='string',
                     doc='Limit the results to a specific Pipeline.'),
               Param(name='project', short_name='r', long_name='project',
                     optional=True, ptype='string',
                     doc='Limit the results to a specific project.'),
               Param(name='group', short_name='g', long_name='group',
                     optional=True, ptype='string',
                     doc='Limit the results to a specific group.'),
               Param(name='limit', short_name='l', long_name='limit',
                     optional=True, ptype='string',
                     doc=('The maximum number of items to retrieve, or '
                          '0 for unlimited. (Default is unlimited.)'))]

    def main(self):
        results = self.call_api(self.API, ['pipeline', 'project', 'group', 'limit'])
        print(results)
Exemplo n.º 8
0
class CreateWebhook(ctmcommands.cmd.CSKCommand):

    Description = 'Creates a new Outbound Webhook configuration.'
    API = 'create_webhook'
    Examples = '''
    ctm-create-webhook -n "MyApplication" -u "http://my.application.net/api/send_here"
'''
    Options = [
        Param(name='name',
              short_name='n',
              long_name='name',
              optional=False,
              ptype='string',
              doc='The name of the Webhook'),
        Param(
            name='destinationurl',
            short_name='d',
            long_name='destinationurl',
            doc=
            'URL of the REST API endpoint. ex: http://my.application.net/api/send_here',
            optional=True)
    ]

    def main(self):
        results = self.call_api(self.API, ['name', 'destinationurl'])
        print(results)
Exemplo n.º 9
0
class TestHipChat(ctmcommands.cmd.CSKCommand):

    Description = "Test HipChat Server connectivity"
    API = "test_plugin_connection"
    Examples = """
    ctm-testhipchat -i instancename
"""
    Options = [
        Param(
            name='instance',
            short_name='i',
            long_name='instance',
            optional=True,
            ptype='string',
            doc=
            'HipChat instance name in the Continuum configuration. Optional, do not use if testing default HipChat instance.'
        ),
        Param(
            name='team',
            short_name='t',
            long_name='team',
            optional=True,
            ptype='string',
            doc=
            "The Team to search for the Plugin Instance to use. Defaults to plugins available to All Teams."
        ),
    ]

    def main(self):
        print("Please wait ... this could take a while ...")
        self.plugin_name = "hipchatplugin"
        results = self.call_api(self.API, ['plugin_name', 'instance', 'team'],
                                timeout=70)
        print(results)
Exemplo n.º 10
0
class CreatePackage(ctmcommands.cmd.CSKCommand):

    Description = """Creates a Package Definition.

Returns a Package Definition Object."""

    API = 'create_package'
    Examples = ''''''
    Options = [Param(name='name', short_name='n', long_name='name',
                     optional=False, ptype='string',
                     doc='A name for the Package Definition.'),
               Param(name='team', short_name='t', long_name='team',
                     optional=False, ptype='string',
                     doc='Team which the Package Definition should belong to'),
               Param(name='description', short_name='d', long_name='description',
                     optional=True, ptype='string',
                     doc='A description for the Package Definition.'),
               Param(name='progression', short_name='p', long_name='progression',
                     optional=True, ptype='string',
                     doc='Value can be either a Progression ID or Name.')               
               ]

    def main(self):
        results = self.call_api(self.API,
                                ['name', 'team', 'description', 'progression'])
        print(results)
Exemplo n.º 11
0
class PromoteRevision(ctmcommands.cmd.CSKCommand):

    Description = 'Promotes a Package Revision to a particular Phase.'
    API = 'promote_revision'
    Examples = '''
    ctm-promote-revision -p "Some Package Name" -r 205 -h "Regression Testing"

    - or -

    ctm-promote-revision -p "Some Package Name" -f "15.2.3.205" -h "Regression Testing"
'''
    Options = [Param(name='package', short_name='p', long_name='package',
                     optional=False, ptype='string',
                     doc='Name of the Package to promote to a Progression Phase.'),
               Param(name='revision', short_name='r', long_name='revision',
                     optional=True, ptype='string',
                     doc='Revision number of a Package to promote, takes precedence over "full_version".'),
               Param(name='full_version', short_name='f', long_name='full_version',
                     optional=True, ptype='string',
                     doc='Optional Full Version of package to promote, optional alternative selector to "revision".'),
               Param(name='phase', short_name='h', long_name='phase',
                     optional=False, ptype='string',
                     doc='Name of the Phase to which the specified Package Revision will be promoted.'),
               Param(name='new_version', short_name='v', long_name='new_version',
                     optional=True, ptype='string',
                     doc='Optional "new version" for this and all prior revisions of this Package.')
               ]

    def main(self):
        results = self.call_api(self.API, ['package', 'revision', 'full_version', 'phase', 'new_version'])
        print(results)
Exemplo n.º 12
0
class ListProjects(ctmcommands.cmd.CSKCommand):

    Description = 'Lists all Projects.'
    API = 'list_projects'
    Examples = '''
_List all Projects

    ctm-list-projects
'''
    Options = [
        Param(name='filter',
              short_name='f',
              long_name='filter',
              optional=True,
              ptype='string',
              doc='A filter.'),
        Param(name='limit',
              short_name='l',
              long_name='limit',
              optional=True,
              ptype='string',
              doc=('The maximum number of items to retrieve, or '
                   '0 for unlimited. (Default is unlimited.)'))
    ]

    def main(self):
        results = self.call_api(self.API, ['filter', 'limit'])
        print(results)
Exemplo n.º 13
0
class GetPIData(ctmcommands.cmd.CSKCommand):

    Description = 'Gets a Pipeline Instance Data object.'
    API = 'get_pi_data'
    Examples = '''
    ctm-get-pidata -i "Pipeline Instance Name or ID"
'''
    Options = [
        Param(name='pi',
              short_name='i',
              long_name='pi',
              optional=False,
              ptype='string',
              doc='Value can be either a Pipeline Instance ID or Name.'),
        Param(
            name='lookup',
            short_name='l',
            long_name='lookup',
            optional=True,
            ptype='string',
            doc=
            'Lookup an expression that evaluates to a subsection of the document.'
        )
    ]

    def main(self):
        results = self.call_api(self.API, ['pi', 'lookup'])
        print(results)
Exemplo n.º 14
0
class ListUsers(ctmcommands.cmd.CSKCommand):

    Description = 'Lists Users, Authentication type will be set to SSO if SSO is enabled in this instance'
    API = 'list_users'
    Examples = '''
_List all users_

    ctm-list-users

_List all users with Administrator role_

    ctm-list-users -f "Administrator"
'''
    Options = [Param(name='filter', short_name='f', long_name='filter',
                     optional=True, ptype='string',
                     doc=('A string to use to filter the resulting data. '
                          'Any row of data that has one field contains '
                          'the string will be returned.')),
               Param(name='limit', short_name='l', long_name='limit',
                     optional=True, ptype='string',
                     doc=('The maximum number of items to retrieve, or '
                          '0 for unlimited. (Default is unlimited.)'))]

    def main(self):
        results = self.call_api(self.API, ['filter', 'limit'])
        print(results)
Exemplo n.º 15
0
class CopyProject(ctmcommands.cmd.CSKCommand):

    Description = 'Copy a Project object.'
    API = 'copy_project'
    Examples = '''
    ctm-copy-project -p "ProjectName"
'''
    Options = [
        Param(name='project',
              short_name='p',
              long_name='project',
              optional=False,
              ptype='string',
              doc='Value can be either a Project ID or Name.'),
        Param(name='newname',
              short_name='n',
              long_name='newname',
              optional=False,
              ptype='string',
              doc='A name for the new Project.')
    ]

    def main(self):
        go = False
        if self.force:
            go = True
        else:
            answer = input("Are you sure (y/n)? ")
            if answer:
                if answer.lower() in ['y', 'yes']:
                    go = True

        if go:
            results = self.call_api(self.API, ['project', 'newname'])
            print(results)
Exemplo n.º 16
0
class UpdateCloud(ctmcommands.cmd.CSKCommand):

    Description = 'Updates the properties of a Cloud Endpoint.'
    API = 'update_cloud'
    Examples = '''
_Update the address of a vCloud cloud endpoint_

    ctm-update-cloud -n "vcloud-test" -u "iad2.vcloudservice.vmware.com"
'''
    Options = [Param(name='name', short_name='n', long_name='name',
                     optional=False, ptype='string',
                     doc='The ID or Name of a Cloud.'),
               Param(name='apiurl', short_name='u', long_name='apiurl',
                     optional=True, ptype='string',
                     doc='URL of the Cloud API endpoint.'),
               Param(name='apiprotocol', short_name='p', long_name='apiprotocol',
                     optional=True, ptype='string',
                     doc='Cloud API endpoint protocol.'),
               Param(name='default_account', short_name='d', long_name='default_account',
                     optional=True, ptype='string',
                     doc='A default Account to be associated with this Cloud.')
               ]

    def main(self):
        results = self.call_api(self.API, ['name', 'apiurl', 'apiprotocol', 'default_account'])
        print(results)
Exemplo n.º 17
0
class UpdateSettings(ctmcommands.cmd.CSKCommand):

    Description = """Update the configuration settings of a specific module.
    
This command accepts a JSON object representing the settings for a module.
    
"""
    API = 'update_settings'
    Examples = '''
_To change the SMTPServerAddress of the Messenger_
    
    ctm-update-settings -m Messenger -s '{"SMTPServerAddress":"smtp.gmail.com"}'
    
_To update all settings for a particular module using a json formatted settings file__
    
    ctm-update-settings -m Messenger -f /tmp/messenger_settings.json
'''
    Options = [
        Param(name='module',
              short_name='m',
              long_name='module',
              optional=False,
              ptype='string',
              doc='Name of the module to update.'),
        Param(name='settings',
              short_name='s',
              long_name='settings',
              optional=True,
              ptype='string',
              doc='JSON Settings object.'),
        Param(name='settingsfile',
              short_name='f',
              long_name='settingsfile',
              optional=True,
              ptype='string',
              doc='A JSON file representing a module Settings object.')
    ]

    def main(self):
        go = False
        if self.force:
            go = True
        else:
            answer = input(
                "WARNING: This is a Administrator function.\n\nUpdating settings will change the operation of the system.\n\nAre you sure? "
            )
            if answer:
                if answer.lower() in ['y', 'yes']:
                    go = True

        if go:
            if self.settingsfile:
                import os
                fn = os.path.expanduser(self.settingsfile)
                with open(fn, 'r') as f_in:
                    if not f_in:
                        print("Unable to open file [%s]." % fn)
                    self.settings = f_in.read()
            results = self.call_api(self.API, ['module', 'settings'])
            print(results)
Exemplo n.º 18
0
class CreateTag(ctmcommands.cmd.CSKCommand):

    Description = 'Creates a new Tag to be used to associate objects with one another.'
    API = 'create_tag'
    Examples = '''
    ctm-create-tag -n "staging01" -d "staging environment 1"
'''
    Options = [
        Param(
            name='name',
            short_name='n',
            long_name='name',
            optional=False,
            ptype='string',
            doc=
            'The name of the new Tag.  (AlphaNumeric ONLY. Cannot contain spaces, punctuation or special characters.)'
        ),
        Param(name='description',
              short_name='d',
              long_name='description',
              optional=True,
              ptype='string',
              doc='Tag description.')
    ]

    def main(self):
        results = self.call_api(self.API, ['name', 'description'])
        print(results)
Exemplo n.º 19
0
class ImportPackage(ctmcommands.cmd.CSKCommand):

    Description = """Imports a backup of a Package Definition..

Returns success or error."""

    API = 'import_package'
    Examples = ''''''
    Options = [Param(name='backupfile', short_name='b', long_name='backupfile',
                     optional=False, ptype='string',
                     doc='A JSON document formatted as a Package backup.'),
               Param(name='overwrite', short_name='o', long_name='overwrite',
                     optional=True, ptype='string',
                     doc="""Valid values: true|false (default).""")
               ]

    def main(self):
        import os

        self.backup = None
        if self.backupfile:
            fn = os.path.expanduser(self.backupfile)
            with open(fn, 'r') as f_in:
                if not f_in:
                    print("Unable to open file [%s]." % fn)
                self.backup = f_in.read()

        results = self.call_api(self.API, ['backup', 'overwrite'], verb='POST')
        print(results)
Exemplo n.º 20
0
class GetNextId(ctmcommands.cmd.CSKCommand):

    Description = """Get the next ID in an ID set"""
    API = 'get_next_id'
    Examples = ''''''
    Options = [
        Param(name='name',
              short_name='n',
              long_name='name',
              optional=False,
              ptype='string',
              doc='ID set name'),
        Param(name='reseed',
              short_name='r',
              long_name='reseed',
              optional=True,
              ptype='string',
              doc='Reseed the ID set starting with this number'),
        Param(name='fallback',
              short_name='f',
              long_name='fallback',
              optional=True,
              ptype='string',
              doc='Fallback to this number if there is an exception')
    ]

    def main(self):
        results = self.call_api(self.API, ["name", "reseed", "fallback"])
        print(results)
Exemplo n.º 21
0
class ImportBackup(ctmcommands.cmd.CSKCommand):

    Description = '''DEPRECATED: Please use `ctm-import-task`.
    
    Imports a task backup file into the system. This file can include one or
                    more tasks within it and must be XML or JSON formatted'''
    API = 'import_backup'
    Examples = '''
    ctm-import-backup -f ~/mytask01.xml
'''
    Options = [
        Param(name='file',
              short_name='f',
              long_name='file',
              optional=False,
              ptype='string',
              doc='The file name of the backup file.'),
        Param(
            name='on_conflict',
            short_name='c',
            long_name='on_conflict',
            optional=True,
            ptype='string',
            doc=
            'Action to take if one or more Tasks have a conflict. "replace", "cancel".'
        )
    ]

    def main(self):
        self.import_text = None
        if self.file:
            import os
            fn = os.path.expanduser(self.file)
            with open(fn, 'r') as f_in:
                if not f_in:
                    print("Unable to open file [%s]." % fn)
                data = f_in.read()
                if data:
                    self.import_text = data
                else:
                    print("File is empty.")
                    return

        go = False
        if self.force:
            go = True
        else:
            answer = input(
                "\n\n\nDEPRECATION WARNING - This command is deprecated and will be removed soon.  Use `ctm-import-task` instead.\n\n\n\nImporting a backup file will add Tasks to your system, possibly updating existing Tasks.\n\nAre you sure? "
            )
            if answer:
                if answer.lower() in ['y', 'yes']:
                    go = True

        if go:
            results = self.call_api(self.API, ['import_text', 'on_conflict'],
                                    verb='POST')
            print(results)
Exemplo n.º 22
0
class ImportTask(ctmcommands.cmd.CSKCommand):

    Description = '''Imports a Task backup file. This file can include one or
                    more tasks within it and must be JSON formatted.'''
    API = 'import_task'
    Examples = '''
    ctm-import-backup -f ~/mytask02.json
'''
    Options = [
        Param(name='file',
              short_name='f',
              long_name='file',
              optional=False,
              ptype='string',
              doc='The file name of the backup file.'),
        Param(
            name='on_conflict',
            short_name='c',
            long_name='on_conflict',
            optional=True,
            ptype='string',
            doc=
            'Action to take if one or more Tasks have a conflict. "replace", "cancel".'
        )
    ]

    def main(self):
        self.backup = None
        if self.file:
            import os
            fn = os.path.expanduser(self.file)
            with open(fn, 'r') as f_in:
                if not f_in:
                    print("Unable to open file [%s]." % fn)
                data = f_in.read()
                if data:
                    self.backup = data
                else:
                    print("File is empty.")
                    return

        go = False
        if self.force:
            go = True
        else:
            answer = raw_input(
                "\nImporting a Task backup file will add Tasks to your system, possibly updating existing Tasks.\n\nAre you sure? "
            )
            if answer:
                if answer.lower() in ['y', 'yes']:
                    go = True

        if go:
            results = self.call_api(self.API, ['backup', 'on_conflict'],
                                    verb='POST')
            print(results)
Exemplo n.º 23
0
class SendMessage(ctmcommands.cmd.CSKCommand):

    Description = 'Sends a message to an email address using the messenger.'
    API = 'send_message'
    Examples = '''
_To send an email to an email address_

    ctm-send-message -t "*****@*****.**" -s "hello world" -m "this is a test message"

_To send an email to a list of email addresses with a blind copy_

    ctm-send-message -t "[email protected],[email protected]" -b "[email protected] -s "hello world" -m "this is a test message"
'''
    Options = [
        Param(name='to',
              short_name='t',
              long_name='to',
              optional=False,
              ptype='string',
              doc='Comma-separated Users or addresses.'),
        Param(name='subject',
              short_name='s',
              long_name='subject',
              optional=False,
              ptype='string',
              doc='Subject of the message.'),
        Param(
            name='message',
            short_name='m',
            long_name='message',
            optional=False,
            ptype='string',
            doc='Content of the message.',
        ),
        Param(name='cc',
              short_name='c',
              long_name='cc',
              optional=True,
              ptype='string',
              doc='Comma-separated Users or addresses to CC.'),
        Param(name='bcc',
              short_name='b',
              long_name='bcc',
              optional=True,
              ptype='string',
              doc='Comma-separated Users or addresses to BCC.')
    ]

    def main(self):
        results = self.call_api(self.API,
                                ['to', 'subject', 'message', 'cc', 'bcc'])
        print(results)
Exemplo n.º 24
0
class ListPipelineInstances(ctmcommands.cmd.CSKCommand):

    Description = 'Lists all Pipeline Instances.'
    API = 'list_pipelineinstances'
    Examples = '''
_List all Pipeline Instances

    ctm-list-pipelineinstances
'''
    Options = [
        Param(name='definition',
              short_name='d',
              long_name='definition',
              optional=True,
              ptype='string',
              doc='Limit the results to a specific Pipeline Definition.'),
        Param(name='project',
              short_name='r',
              long_name='project',
              optional=True,
              ptype='string',
              doc='Limit the results to a specific project.'),
        Param(name='group',
              short_name='g',
              long_name='group',
              optional=True,
              ptype='string',
              doc='Limit the results to a specific group.'),
        Param(
            name='since',
            short_name='s',
            long_name='since',
            optional=True,
            ptype='string',
            doc='Limit the results to Instances after the provided timestamp.'
        ),
        Param(
            name='limit',
            short_name='l',
            long_name='limit',
            optional=True,
            ptype='integer',
            doc=
            'Limit the number of results.  (0 for all results, 100 if omitted.'
        )
    ]

    def main(self):
        results = self.call_api(
            self.API, ['definition', 'project', 'group', 'since', 'limit'])
        print(results)
Exemplo n.º 25
0
class InitiatePipeline(ctmcommands.cmd.CSKCommand):

    Description = """Initiate a Pipeline Definition with matching 'key' information.

Returns a Pipeline Instance Object."""

    API = 'initiate_pipeline'
    Examples = ''''''
    Options = [
        Param(name='definition',
              short_name='d',
              long_name='definition',
              optional=False,
              ptype='string',
              doc='Pipeline Definition to initiate.'),
        Param(name='project',
              short_name='p',
              long_name='project',
              optional=False,
              ptype='string',
              doc='The Project name with which to associate this instance.'),
        Param(
            name='group',
            short_name='g',
            long_name='group',
            optional=False,
            ptype='string',
            doc=
            'Descriptive label of a group to summarize multiple instances of this definition/project.'
        ),
        Param(
            name='name',
            short_name='n',
            long_name='name',
            optional=True,
            ptype='string',
            doc=
            'An explicit name for the unique instance. (Autogenerated if omitted.)'
        ),
        Param(name='details',
              short_name='j',
              long_name='details',
              optional=True,
              ptype='string',
              doc='A JSON object with additional details about this instance.')
    ]

    def main(self):
        results = self.call_api(
            self.API, ['definition', 'project', 'group', 'name', 'details'])
        print(results)
Exemplo n.º 26
0
class CreateCloud(ctmcommands.cmd.CSKCommand):

    Description = 'Creates a new Cloud endpoint.'
    API = 'create_cloud'
    Examples = '''
_Create vCloud endpoint_

    ctm-create-cloud -n "vcloud-test" -p "HTTP" -v "vCloud" -u "iad.vcloudservice.vmware.com" -d "vcloudtest"
'''
    Options = [
        Param(
            name='provider',
            short_name='v',
            long_name='provider',
            optional=False,
            ptype='string',
            doc=
            'The name of a supported Cloud Provider. One of: Eucalyptus, vCloud, VMware, AWS, OpenStackAws'
        ),
        Param(name='name',
              short_name='n',
              long_name='name',
              optional=False,
              ptype='string',
              doc='A name for the new Cloud.'),
        Param(name='apiurl',
              short_name='u',
              long_name='apiurl',
              optional=False,
              ptype='string',
              doc='URL of the Cloud API endpoint minus the protocol.'),
        Param(name='apiprotocol',
              short_name='p',
              long_name='apiprotocol',
              optional=False,
              ptype='string',
              doc='Cloud API endpoint protocol. Either HTTP or HTTPS'),
        Param(name='default_account',
              short_name='d',
              long_name='default_account',
              optional=True,
              ptype='string',
              doc='A default Account to be associated with this Cloud.')
    ]

    def main(self):
        results = self.call_api(
            self.API,
            ['provider', 'name', 'apiurl', 'apiprotocol', 'default_account'])
        print(results)
Exemplo n.º 27
0
class GetSystemLog(ctmcommands.cmd.CSKCommand):

    Description = 'Get the System Log.'
    API = 'get_system_log'
    Examples = '''
_To get the last 100 denied login attempts_

    ctm-get-system-log -l "Security" -a "UserLoginAttempt"

_To get any log entries attributed to the administrator user between two dates_

    ctm-get-system-log -u "administrator" -l "Object" --from "1/6/2014" --to "1/7/2014"

_To get the last 300 task modifications_

    ctm-get-system-log -t 3 -r 300
'''
    Options = [Param(name='object_id', short_name='i', long_name='object_id',
                     optional=True, ptype='string',
                     doc='An Object ID filter.'),
               Param(name='object_type', short_name='t', long_name='object_type',
                     optional=True, ptype='string',
                     doc='''The integer representation of an internal object type. Can be used with one of the following when log_type = Object: (User = 1, Asset = 2, Task = 3, Schedule = 4, Tag = 7, Image = 8, MessageTemplate = 18, Parameter = 34, Credential = 35, Domain = 36, CloudAccount = 40, Cloud = 41, CloudKeyPair = 45)'''),
               Param(name='user', short_name='u', long_name='user',
                     optional=True, ptype='string',
                     doc='A user name to filter result on.'),
               Param(name='log_type', short_name='l', long_name='log_type',
                     optional=True, ptype='string',
                     doc='The type of log, either Object or Security'),
               Param(name='action', short_name='a', long_name='action',
                     optional=True, ptype='string',
                     doc='''The action that triggered a log entry. One of the following:
(UserLogin, UserLogout, UserLoginAttempt, UserPasswordChange, UserSessionDrop, ObjectAdd, ObjectModify, ObjectDelete, bjectView, ObjectCopy, ConfigChange)'''),
               Param(name='filter', short_name='f', long_name='filter',
                     optional=True, ptype='string',
                     doc='A filter whereby the results would contain this string'),
               Param(name='from', short_name='', long_name='from',
                     optional=True, ptype='string',
                     doc='A "from" date in the format of m/d/yyyy.'),
               Param(name='to', short_name='', long_name='to',
                     optional=True, ptype='string',
                     doc='A "to" date in the format of m/d/yyyy.'),
               Param(name='records', short_name='r', long_name='records',
                     optional=True, ptype='string',
                     doc='Maximum number of records to return, default is 100.')
               ]

    def main(self):
        try:
            results = self.call_api(self.API, ['object_id', 'object_type', 'log_type', 'action', 'filter', 'from', 'to', 'records', 'user'])
            print(results)
        except Exception as ex:
            raise ex
Exemplo n.º 28
0
class ListMethods(ctmcommands.cmd.CSKCommand):

    Description = 'Retrieves a list of all REST API methods and their documentation.'
    API = ''
    Examples = '''
_To print a full listing of all api commands with documentation_

    ctm-describe-api

_To print only the names with the api commands sorted_

    ctm-describe-api -l
'''
    Options = [
        Param(name='listonly',
              short_name='l',
              long_name='listonly',
              optional=True,
              ptype='boolean',
              doc='List the methods without documentation.')
    ]

    def main(self):
        # output format for this command is limited to text
        self.output_format = "text"

        results = self.call_api(self.API, ['listonly'])
        print(results)
Exemplo n.º 29
0
class DeleteSchedule(ctmcommands.cmd.CSKCommand):

    Description = 'Deletes a Task Schedule and all queued execution plans.'
    API = 'delete_schedule'
    Examples = '''
    ctm-delete-schedule -s "157545d8-7df9-11e3-ab87-da5f4e6a2990"
'''
    Options = [
        Param(name='schedule_id',
              short_name='s',
              long_name='schedule_id',
              optional=False,
              ptype='string',
              doc='The UUID of the Schedule to delete.')
    ]

    def main(self):
        go = False
        if self.force:
            go = True
        else:
            answer = input(
                "WARNING: This is a utility function.\n\nDeleting a Schedule cannot be undone.\n\nAre you sure? "
            )
            if answer:
                if answer.lower() in ['y', 'yes']:
                    go = True

        if go:
            results = self.call_api(self.API, ['schedule_id'])
            print(results)
Exemplo n.º 30
0
class DeleteProgression(ctmcommands.cmd.CSKCommand):

    Description = 'Delete a Progression.'
    API = 'delete_progression'
    Examples = '''
    ctm-delete-progression -p "Progression Name"
'''
    Options = [
        Param(name='progression',
              short_name='p',
              long_name='progression',
              optional=False,
              ptype='string',
              doc='Value can be either a Progression ID or Name.')
    ]

    def main(self):
        go = False
        if self.force:
            go = True
        else:
            answer = input(
                "\nThis is a destructive operation.  All configuration and history of this Progression, including references to other objects, will be removed.\n\nAre you sure (y/n)? "
            )
            if answer:
                if answer.lower() in ['y', 'yes']:
                    go = True

        if go:
            results = self.call_api(self.API, ['progression'])
            print(results)