Пример #1
0
from .tnco_target import TNCOTarget, LmGet, LmCreate, LmUpdate, LmDelete, LmCmd, LmGen


class DescriptorTemplatesTable(Table):

    columns = [
        Column('name', header='Name'),
        Column('description',
               header='Description',
               accessor=lambda x: (x.get('description')[:75].strip() + '..')
               if x.get('description', None) is not None and len(
                   x.get('description')) > 75 else x.get('description'))
    ]


output_formats = common_output_format_handler(table=DescriptorTemplatesTable())
render_output_formats = default_output_format_handler()
file_inputs = default_file_inputs_handler()


class DescriptorTemplates(TNCOTarget):
    name = 'descriptortemplate'
    plural = 'descriptortemplates'
    display_name = 'Descriptor Template'

    @LmGen()
    def genfile(self, ctx: click.Context, name: str):
        return {
            'name': name,
            'properties': {
                'injected_prop': {
Пример #2
0
from lmctl.cli.arguments import common_output_format_handler, default_file_inputs_handler, set_param_option
from lmctl.cli.format import Table, Column
from .tnco_target import TNCOTarget, LmGet, LmCreate, LmUpdate, LmDelete, LmGen, LmCmd


class AssemblyTable(Table):

    columns = [
        Column('id', header='ID'),
        Column('name', header='Name'),
        Column('descriptorName', header='Descriptor Name'),
        Column('state', header='State')
    ]


output_formats = common_output_format_handler(table=AssemblyTable())
file_inputs = default_file_inputs_handler()


class Assemblies(TNCOTarget):
    name = 'assembly'
    plural = 'assemblies'
    display_name = 'Assembly'

    @LmGen()
    def genfile(self, ctx: click.Context, name: str):
        return {
            'name': name,
            'descriptorName': 'assembly::example::1.0',
            'intendedState': 'Active',
            'properties': {
Пример #3
0
from lmctl.client import TNCOClient, TNCOClientHttpError
from lmctl.cli.arguments import common_output_format_handler, set_param_option, default_file_inputs_handler
from lmctl.cli.format import Table, Column
from .tnco_target import TNCOTarget, LmGet, LmCreate, LmUpdate, LmDelete, LmGen, LmCmd


class ScenarioTable(Table):

    columns = [
        Column('id', header='ID'),
        Column('name', header='Name'),
        Column('description', header='Description')
    ]


output_formats = common_output_format_handler(table=ScenarioTable())

exec_file_inputs = default_file_inputs_handler()


class Scenarios(TNCOTarget):
    name = 'scenario'
    plural = 'scenarios'
    display_name = 'Scenario'

    @LmGen()
    def genfile(self, ctx: click.Context, name: str):
        return {
            'name':
            name,
            'projectId':
Пример #4
0
from lmctl.client import TNCOClient, TNCOClientHttpError
from lmctl.cli.arguments import common_output_format_handler
from lmctl.cli.format import Table, Column
from .tnco_target import TNCOTarget, LmGet, LmCreate, LmUpdate, LmDelete, LmGen


class InfrastructureKeyTable(Table):

    columns = [
        Column('name', header='Name'),
        Column('id', header='ID'),
        Column('description', header='Description')
    ]


output_formats = common_output_format_handler(table=InfrastructureKeyTable())


class InfrastructureKeys(TNCOTarget):
    name = 'infrastructurekey'
    plural = 'infrastructurekeys'
    display_name = 'Infrastructure Key'

    @LmGen()
    def genfile(self, ctx: click.Context, name: str):
        return {
            'name': name,
            'description': 'An infrastructure key',
            'privateKey': 'the-private-part',
            'publicKey': 'the-public-part'
        }
Пример #5
0

class ProcessTable(Table):

    columns = [
        Column('startTime', header='Start Time'),
        Column('intentType', header='Intent'),
        Column('status', header='Status'),
        Column('assembly',
               header='Assembly',
               accessor=lambda x: x.get('assemblyName') + ' (' + x.get(
                   'assemblyId') + ')'),
    ]


output_formats = common_output_format_handler(table=ProcessTable())


class Processes(TNCOTarget):
    name = 'process'
    plural = 'processes'
    display_name = 'Assembly Process'

    @LmGet(output_formats=output_formats,
           short_help=f'''Get the status of an {display_name}''',
           help=f'''\
            Get the status of an {display_name}.
            \n\nA single Process can be retrieved by the "ID" argument or retrieve multiple Processes with a combination of filter options: 
            --assembly-id, --assembly-name, --assembly-type, --start-time, --end-time, --status, --intent-type, --limit
            ''')
    @click.argument('ID', required=False)
Пример #6
0
from lmctl.cli.arguments import common_output_format_handler
from lmctl.cli.format import Table, Column
from .tnco_target import TNCOTarget, LmGet, LmCreate, LmDelete, LmGen
from lmctl.utils.certificates import read_certificate_file, fix_newlines_in_cert


class ResourceDriverTable(Table):

    columns = [
        Column('id', header='ID'),
        Column('type', header='Type'),
        Column('baseUri', header='Base URI')
    ]


output_formats = common_output_format_handler(table=ResourceDriverTable())


class ResourceDrivers(TNCOTarget):
    name = 'resourcedriver'
    plural = 'resourcedrivers'
    display_name = 'Resource Driver'

    @LmGen()
    def genfile(self, ctx: click.Context, name: str):
        return {
            'type':
            name,
            'baseUri':
            'https://ansible-lifecycle-driver:8293',
            'certifcate':
Пример #7
0
from lmctl.cli.arguments import common_output_format_handler
from lmctl.cli.format import Table, Column
from .tnco_target import TNCOTarget, LmGet, LmCreate, LmUpdate, LmDelete, LmGen


class DeploymentLocationTable(Table):

    columns = [
        Column('name', header='Name'),
        Column('resourceManager', header='Resource Manager'),
        Column('infrastructureType', header='Infrastructure Type'),
        Column('description', header='Description')
    ]


output_formats = common_output_format_handler(table=DeploymentLocationTable())


class DeploymentLocations(TNCOTarget):
    name = 'deploymentlocation'
    plural = 'deploymentlocations'
    display_name = 'Deployment Location'

    @LmGen()
    def genfile(self, ctx: click.Context, name: str):
        return {
            'name': name,
            'resourceManager': 'brent',
            'infrastructureType': 'Other',
            'infrastructureSpecificProperties': {
                'locationPropertyA': 'valueA'
Пример #8
0
from typing import Dict
from lmctl.client import TNCOClient, TNCOClientHttpError
from lmctl.cli.arguments import common_output_format_handler
from lmctl.cli.format import Table, Column
from .tnco_target import TNCOTarget, LmGet, LmCreate, LmUpdate, LmDelete, LmGen


class ProjectTable(Table):

    columns = [
        Column('name', header='Name'),
        Column('description', header='Description')
    ]


output_formats = common_output_format_handler(table=ProjectTable())


class Projects(TNCOTarget):
    name = 'behaviourproject'
    plural = 'behaviourprojects'
    display_name = 'Behaviour Project'

    @LmGen()
    def genfile(self, ctx: click.Context, name: str):
        return {
            'name': f'assembly::{name}::1.0',
        }

    @LmGet(output_formats=output_formats,
           help=f'''\
Пример #9
0
Файл: env.py Проект: IBM/lmctl
        Column('name', header='Test Name'),
        Column('result', header='Result', accessor=lambda x: 'OK' if x.passed else 'Failed'),
        Column('error', header='Error')
    ]

class EnvironmentTable(Table):
    
    columns = [
        Column('name', header='Name'),
        Column('description', header='Description'),
        Column('tnco', header='TNCO/ALM', accessor=lambda x: x.tnco.address if x.tnco else None),
        Column('auth', header='Auth', accessor=lambda x: x.tnco.auth_mode if x.tnco else None),
        Column('arm', header='Ansible RM', accessor=build_arms_string)
    ]

output_formats = common_output_format_handler(table=EnvironmentTable())

class Environments(Target):
    name = 'env'
    plural = 'envs'
    display_name = 'Environments'

    def get(self):
        @click.command(help=f'Get LMCTL {self.display_name} from active config file')
        @output_formats.option()
        @click.argument('name', required=False)
        @click.option('--active', is_flag=True, default=False, help='Display the active environment (if set) rather than retrieving one by name')
        @click.pass_context
        def _get(ctx: click.Context, output_format: str, name: str = None, active: bool = False):
            ctl = self._get_controller()
            output_formatter = output_formats.resolve_choice(output_format)
Пример #10
0
        Column('name', header='Name'),
        Column('type', header='Type'),
        Column('url', header='URL')
    ]


class ResourceManagerOnboardingReportTable(Table):
    columns = [
        Column('name', header='Name'),
        Column('operation', header='Operation'),
        Column('success', header='Success'),
        Column('reason', header='Failure Reason'),
    ]


output_formats = common_output_format_handler(table=ResourceManagerTable())
onboarding_report_formats = common_output_format_handler(
    table=ResourceManagerOnboardingReportTable())


class ResourceManagers(TNCOTarget):
    name = 'resourcemanager'
    plural = 'resourcemanagers'
    display_name = 'Resource Manager'

    @LmGen()
    def genfile(self, ctx: click.Context, name: str):
        return {
            'name': name,
            'type': name,
            'url': 'https://my-rm.example.com/api/resource-manager'
Пример #11
0
from lmctl.cli.arguments import common_output_format_handler
from lmctl.cli.format import Table, Column
from .tnco_target import TNCOTarget, LmGet, LmCreate, LmUpdate, LmDelete, LmGen


class AssemblyConfigurationTable(Table):

    columns = [
        Column('id', header='ID'),
        Column('name', header='Name'),
        Column('description', header='Description'),
        Column('descriptorName', header='Descriptor Name')
    ]


output_formats = common_output_format_handler(
    table=AssemblyConfigurationTable())


class AssemblyConfigurations(TNCOTarget):
    name = 'assemblyconfig'
    plural = 'assemblyconfigs'
    display_name = 'Assembly Configuration'

    @LmGen()
    def genfile(self, ctx: click.Context, name: str):
        return {
            'name': name,
            'projectId': 'assembly::example::1.0',
            'description':
            'Example Assembly Configuration. projectId determines the descriptor project this config will be added to',
            'descriptorName': 'assembly::example::1.0',
Пример #12
0
from lmctl.client import TNCOClient, TNCOClientHttpError
from lmctl.cli.arguments import common_output_format_handler
from lmctl.cli.format import Table, Column
from .tnco_target import TNCOTarget, LmGet, LmCreate, LmUpdate, LmDelete, LmCmd
#, accessor=lambda x: x.get('scenarioSummary').get('name') if 'scenarioSummary' in x else None),
class ScenarioExecutionTable(Table):
    
    columns = [
        Column('id', header='ID'),
        Column('name', header='Execution Name'),
        Column('scenarioId', header='Scenario'),
        Column('startedAt', header='Started At'),
        Column('status', header='Status')
    ]

output_formats = common_output_format_handler(table=ScenarioExecutionTable())

class ScenarioExecutions(TNCOTarget):
    name = 'scenarioexecution'
    plural = 'scenarioexecutions'
    display_name = 'Scenario Execution'

    @LmCmd(help=f'''\
                Cancel {display_name} by ID
                ''')
    @click.argument('ID')
    def cancel(self, tnco_client: TNCOClient, ctx: click.Context, id: str = None):
        api = tnco_client.behaviour_scenario_execs
        result = api.cancel(id)
        if 'success' in result and result['success'] is False:
            ctl = self._get_controller()