Esempio n. 1
0
    def create(self):
        """Create an assembly."""
        self.parser.add_argument('name',
                                 help="Assembly name")
        self.parser.add_argument('plan_uri',
                                 help="Tenant/project-wide unique "
                                 "plan (uri/uuid or name)")
        self.parser.add_argument('--description',
                                 help="Assembly description")
        args = self.parser.parse_args()
        name = args.name
        plan_uri = args.plan_uri
        if '/' not in plan_uri:
            # might be a plan uuid/name
            # let's try and be helpful and get the real plan_uri.
            plan = self.client.plans.find(name_or_id=args.plan_uri)
            plan_uri = plan.uri
            print('Note: using plan_uri=%s' % plan_uri)

        assembly = self.client.assemblies.create(name=name,
                                                 description=args.description,
                                                 plan_uri=plan_uri)
        fields = ['uuid', 'name', 'description', 'status', 'application_uri',
                  'trigger_uri']
        data = dict([(f, getattr(assembly, f, ''))
                     for f in fields])
        cliutils.print_dict(data, wrap=72)
Esempio n. 2
0
    def create(self):
        """Create a pipeline."""
        self.parser.add_argument('plan_uri',
                                 help="Tenant/project-wide unique "
                                 "plan (uri/uuid or name)")
        self.parser.add_argument('workbook_name',
                                 help="Workbook name")
        self.parser.add_argument('name',
                                 help="Pipeline name")
        args = self.parser.parse_args()
        plan_uri = args.plan_uri
        if '/' not in plan_uri:
            # might be a plan uuid/name
            # let's try and be helpful and get the real plan_uri.
            plan = self.client.plans.find(name_or_id=args.plan_uri)
            plan_uri = plan.uri
            print('Note: using plan_uri=%s' % plan_uri)

        pipeline = self.client.pipelines.create(
            name=args.name,
            plan_uri=plan_uri,
            workbook_name=args.workbook_name)
        fields = ['uuid', 'name', 'description',
                  'trigger_uri']
        data = dict([(f, getattr(pipeline, f, ''))
                     for f in fields])
        cliutils.print_dict(data, wrap=72)
Esempio n. 3
0
 def show(self):
     """Show an application's resource."""
     self.parser.add_argument("plan_uuid", help="Plan uuid or name")
     args = self.parser.parse_args()
     response = self.client.plans.find(name_or_id=args.plan_uuid)
     fields = ["uuid", "name", "description", "uri"]
     data = dict([(f, getattr(response, f, "")) for f in fields])
     cliutils.print_dict(data, wrap=72)
Esempio n. 4
0
 def show(self):
     """Get a language pack."""
     self.parser.add_argument("lp_id", help="Language pack id")
     args = self.parser.parse_args()
     response = self.client.languagepacks.get(lp_id=args.lp_id)
     fields = ["uuid", "name", "description", "compiler_versions", "os_platform"]
     data = dict([(f, getattr(response, f, "")) for f in fields])
     cliutils.print_dict(data, wrap=72)
Esempio n. 5
0
 def show(self):
     """Show an assembly's resource."""
     self.parser.add_argument("assembly_uuid", help="Assembly uuid or name")
     args = self.parser.parse_args()
     response = self.client.assemblies.find(name_or_id=args.assembly_uuid)
     fields = ["uuid", "name", "description", "status", "application_uri", "trigger_uri"]
     data = dict([(f, getattr(response, f, "")) for f in fields])
     cliutils.print_dict(data, wrap=72)
Esempio n. 6
0
 def show(self):
     """Show a component's resource."""
     self.parser.add_argument('component_uuid',
                              help="Component uuid or name")
     args = self.parser.parse_args()
     response = self.client.components.find(name_or_id=args.component_uuid)
     fields = ['uuid', 'name', 'description', 'uri', 'assembly_uuid']
     data = dict([(f, getattr(response, f, ''))
                  for f in fields])
     cliutils.print_dict(data, wrap=72)
Esempio n. 7
0
 def show(self):
     """Show a pipeline's resource."""
     self.parser.add_argument('pipeline_uuid',
                              help="Pipeline uuid or name")
     args = self.parser.parse_args()
     response = self.client.pipelines.find(name_or_id=args.pipeline_uuid)
     fields = ['uuid', 'name', 'description',
               'trigger_uri', 'workbook_name', 'last_execution']
     data = dict([(f, getattr(response, f, ''))
                  for f in fields])
     cliutils.print_dict(data, wrap=72)
Esempio n. 8
0
 def show(self):
     """Get a language pack."""
     self.parser.add_argument('lp_id',
                              help="Language pack id")
     args = self.parser.parse_args()
     response = self.client.languagepacks.get(lp_id=args.lp_id)
     fields = ['uuid', 'name', 'description', 'compiler_versions',
               'os_platform']
     data = dict([(f, getattr(response, f, ''))
                  for f in fields])
     cliutils.print_dict(data, wrap=72)
Esempio n. 9
0
 def show(self):
     """Show an assembly's resource."""
     self.parser.add_argument('assembly_uuid',
                              help="Assembly uuid or name")
     args = self.parser.parse_args()
     response = self.client.assemblies.find(name_or_id=args.assembly_uuid)
     fields = ['uuid', 'name', 'description', 'status', 'application_uri',
               'trigger_uri']
     data = dict([(f, getattr(response, f, ''))
                  for f in fields])
     cliutils.print_dict(data, wrap=72)
Esempio n. 10
0
 def show(self):
     """Show an application's resource."""
     self.parser.add_argument('plan_uuid',
                              help="Plan uuid or name")
     args = self.parser.parse_args()
     response = self.client.plans.find(name_or_id=args.plan_uuid)
     fields = ['uuid', 'name', 'description', 'uri', 'artifacts']
     data = dict([(f, getattr(response, f, ''))
                  for f in fields])
     artifacts = copy.deepcopy(data['artifacts'])
     del data['artifacts']
     cliutils.print_dict(data, wrap=72)
     self._show_public_keys(artifacts)
Esempio n. 11
0
 def build(self):
     """Build a custom language pack."""
     self.parser.add_argument('name',
                              help="Language pack name.")
     self.parser.add_argument('git_url',
                              help=("Github url of custom "
                                    "language pack repository."))
     args = self.parser.parse_args()
     response = self.client.images.create(name=args.name,
                                          source_uri=args.git_url)
     fields = ['uuid', 'name']
     data = dict([(f, getattr(response, f, ''))
                  for f in fields])
     cliutils.print_dict(data, wrap=72)
Esempio n. 12
0
    def create(self):
        """Create a language pack."""
        self.parser.add_argument("lp_file", help="Language pack file.")
        args = self.parser.parse_args()
        with open(args.lp_file) as lang_pack_file:
            try:
                data = json.load(lang_pack_file)
            except ValueError as exc:
                print("Error in language pack file: %s", str(exc))
                sys.exit(1)

        json_data = json.dumps(data)
        languagepack = self.client.languagepacks.create(json_data)
        fields = ["uuid", "name", "description", "compiler_versions", "os_platform"]
        data = dict([(f, getattr(languagepack, f, "")) for f in fields])
        cliutils.print_dict(data, wrap=72)
Esempio n. 13
0
 def _print_dict(self, obj, fields, dict_property="Property", wrap=0):
     fields = self._sanitized_fields(fields)
     try:
         # datsun180b: I have no idea why, but following a PATCH
         # app resources need to have this evaluated once or else
         # the subset assignment below fails.
         obj.attrs
     except TypeError:
         pass
     except AttributeError:
         pass
     subset = dict([(f, getattr(obj, f, '')) for f in fields])
     if self.json_output:
         print(json.dumps(subset, indent=2, sort_keys=True))
     else:
         cliutils.print_dict(subset, dict_property, wrap)
Esempio n. 14
0
    def create(self):
        """Create an application."""
        self.parser.add_argument('plan_file',
                                 help="Plan file")
        args = self.parser.parse_args()
        with open(args.plan_file) as definition_file:
            definition = definition_file.read()

        plan = self.client.plans.create(definition)
        fields = ['uuid', 'name', 'description', 'uri', 'artifacts']
        data = dict([(f, getattr(plan, f, ''))
                     for f in fields])
        artifacts = copy.deepcopy(data['artifacts'])
        del data['artifacts']
        cliutils.print_dict(data, wrap=72)
        self._show_public_keys(artifacts)
Esempio n. 15
0
    def create(self):
        """Create an assembly."""
        self.parser.add_argument("plan_uri", help="Tenant/project-wide unique " "plan (uri/uuid or name)")
        self.parser.add_argument("--assembly", help="Assembly name")
        args = self.parser.parse_args()
        plan_uri = args.plan_uri
        if "/" not in plan_uri:
            # might be a plan uuid/name
            # let's try and be helpful and get the real plan_uri.
            plan = self.client.plans.find(name_or_id=args.plan_uri)
            plan_uri = plan.uri
            print("Note: using plan_uri=%s" % plan_uri)

        assembly = self.client.assemblies.create(name=args.assembly, plan_uri=plan_uri)
        fields = ["uuid", "name", "description", "status", "application_uri", "trigger_uri"]
        data = dict([(f, getattr(assembly, f, "")) for f in fields])
        cliutils.print_dict(data, wrap=72)
Esempio n. 16
0
def create_assembly(client, app_name, plan_uri):
    cmd = ['solum', 'assembly', 'create', app_name, plan_uri]
    print(' '.join(cmd))
    assembly = client.assemblies.create(name=app_name, plan_uri=plan_uri)

    fields = ['uuid', 'name', 'description', 'status', 'application_uri',
              'trigger_uri']
    data = dict([(f, getattr(assembly, f, ''))
                 for f in fields])
    cliutils.print_dict(data, wrap=72)

    trigger_uri = data['trigger_uri']
    if trigger_uri is None:
        print('Error in trigger uri')
        exit(1)

    return trigger_uri
Esempio n. 17
0
    def create(self):
        """Create a language pack."""
        self.parser.add_argument('lp_file',
                                 help="Language pack file.")
        args = self.parser.parse_args()
        with open(args.lp_file) as lang_pack_file:
            try:
                data = json.load(lang_pack_file)
            except ValueError as exc:
                print("Error in language pack file: %s", str(exc))
                sys.exit(1)

        languagepack = self.client.languagepacks.create(**data)
        fields = ['uuid', 'name', 'description', 'compiler_versions',
                  'os_platform']
        data = dict([(f, getattr(languagepack, f, ''))
                     for f in fields])
        cliutils.print_dict(data, wrap=72)
Esempio n. 18
0
    def create(self):
        """Create an application."""
        self.parser.add_argument("plan_file", help="Plan file")
        args = self.parser.parse_args()
        with open(args.plan_file) as definition_file:
            definition = definition_file.read()

        # Convert yaml to json until we add yaml support in API layer.
        try:
            data = yaml.load(definition)
        except yaml.YAMLError as exc:
            print("Error in plan file: %s", str(exc))
            sys.exit(1)

        json_data = json.dumps(data)
        plan = self.client.plans.create(json_data)

        fields = ["uuid", "name", "description", "uri"]
        data = dict([(f, getattr(plan, f, "")) for f in fields])
        cliutils.print_dict(data, wrap=72)
Esempio n. 19
0
 def build(self):
     """Build a custom language pack."""
     self.parser.add_argument('name',
                              help="Language pack name.")
     self.parser.add_argument('git_url',
                              help=("Github url of custom "
                                    "language pack repository."))
     self.parser.add_argument('lp_metadata',
                              help="Language pack file.")
     args = self.parser.parse_args()
     with open(args.lp_metadata) as lang_pack_metadata:
         try:
             lp_metadata = json.dumps(json.load(lang_pack_metadata))
         except ValueError as exc:
             print("Error in language pack file: %s", str(exc))
             sys.exit(1)
     response = self.client.images.create(name=args.name,
                                          source_uri=args.git_url,
                                          lp_metadata=lp_metadata)
     fields = ['uuid', 'name']
     data = dict([(f, getattr(response, f, ''))
                  for f in fields])
     cliutils.print_dict(data, wrap=72)
Esempio n. 20
0
def create_plan(client, plan_file):
    cmd = ['solum', 'app', 'create', plan_file]
    print(' '.join(cmd))
    with open(plan_file) as definition_file:
        definition = definition_file.read()

    plan = client.plans.create(definition)
    fields = ['uuid', 'name', 'description', 'uri']
    data = dict([(f, getattr(plan, f, ''))
                 for f in fields])
    cliutils.print_dict(data, wrap=72)

    if data['uri'] is None:
        print('Error: no uri found in plan creation')
        exit(1)

    # get public keys in the case of private repos
    artifacts = getattr(plan, 'artifacts', [])
    for arti in artifacts:
        content = getattr(arti, 'content', {})
        if 'public_key' in content and 'href' in content:
            CREDENTIALS[content['href']]['pub_key'] = content['public_key']

    return data['uri']