Beispiel #1
0
    def args2body(self, parsed_args):
        args = {'attributes': {}}
        body = {self.resource: args}
        if parsed_args.vim_region_name:
            args.setdefault('placement_attr', {})['region_name'] = \
                parsed_args.vim_region_name

        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format
        if parsed_args.vim_name:
                _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                              'vim',
                                                              parsed_args.
                                                              vim_name)
                parsed_args.vim_id = _id
        if parsed_args.nsd_name:
                _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                              'nsd',
                                                              parsed_args.
                                                              nsd_name)
                parsed_args.nsd_id = _id
        if parsed_args.param_file:
            with open(parsed_args.param_file) as f:
                param_yaml = f.read()
            try:
                args['attributes']['param_values'] = yaml.load(
                    param_yaml, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)
        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'description',
                               'nsd_id', 'vim_id'])
        return body
    def args2body(self, parsed_args):
        args = {'attributes': {}}
        body = {self.resource: args}
        # config arg passed as data overrides config yaml when both args passed
        if parsed_args.config_file:
            with open(parsed_args.config_file) as f:
                config_yaml = f.read()
            args['attributes']['config'] = config_yaml
        if parsed_args.config:
            args['attributes']['config'] = parsed_args.config

        if parsed_args.vnfd_name:
            tacker_client = self.get_client()
            tacker_client.format = parsed_args.request_format

            _id = tackerV10.find_resourceid_by_name_or_id(
                tacker_client, 'vnfd',
                parsed_args.vnfd_name)

            parsed_args.vnfd_id = _id
        if parsed_args.param_file:
            with open(parsed_args.param_file) as f:
                param_yaml = f.read()
            args['attributes']['param_values'] = param_yaml
        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'vnfd_id'])
        return body
    def args2body(self, parsed_args):
        body = {self.resource: {}}

        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format
        if parsed_args.cluster_name:
            _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                          'cluster',
                                                          parsed_args.
                                                          cluster_name)
            parsed_args.cluster_id = _id
        if parsed_args.vnfd_name:
            _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                          'vnfd',
                                                          parsed_args.
                                                          vnfd_name)
            parsed_args.vnfd_id = _id
        parsed_args.role = parsed_args.role.upper()
        if parsed_args.vim_name:
            _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                          'vim',
                                                          parsed_args.
                                                          vim_name)
            parsed_args.vim_id = _id
        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'cluster_id', 'vnfd_id',
                               'role', 'vim_id'])
        return body
Beispiel #4
0
    def args2body(self, parsed_args):
        args = {'attributes': {}}
        body = {self.resource: args}

        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format

        if parsed_args.vnf_mapping:
            _vnf_mapping = dict()
            _vnf_mappings = parsed_args.vnf_mapping.split(",")
            for mapping in _vnf_mappings:
                vnfd_name, vnf = mapping.split(":", 1)
                _vnf_mapping[vnfd_name] = \
                    tackerV10.find_resourceid_by_name_or_id(
                        tacker_client, 'vnf', vnf)

            parsed_args.vnf_mapping = _vnf_mapping

        if parsed_args.vnffgd_name:
            _id = tackerV10.find_resourceid_by_name_or_id(
                tacker_client, 'vnffgd', parsed_args.vnffgd_name)
            parsed_args.vnffgd_id = _id

        if parsed_args.param_file:
            with open(parsed_args.param_file) as f:
                param_yaml = f.read()
            args['attributes']['param_values'] = yaml.load(
                param_yaml, Loader=yaml.SafeLoader)

        tackerV10.update_dict(
            parsed_args, body[self.resource],
            ['tenant_id', 'name', 'vnffgd_id', 'symmetrical', 'vnf_mapping'])
        return body
Beispiel #5
0
    def args2body(self, parsed_args):
        body = {self.resource: {}}

        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format

        if parsed_args.vnf_mapping:
            _vnf_mapping = dict()
            _vnf_mappings = parsed_args.vnf_mapping.split(",")
            for mapping in _vnf_mappings:
                vnfd_name, vnf = mapping.split(":", 1)
                _vnf_mapping[vnfd_name] = \
                    tackerV10.find_resourceid_by_name_or_id(
                        tacker_client, 'vnf', vnf)

            parsed_args.vnf_mapping = _vnf_mapping

        if parsed_args.vnffgd_name:
            _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                          'vnffgd',
                                                          parsed_args.
                                                          vnffgd_name)
            parsed_args.vnffgd_id = _id

        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'vnffgd_id',
                               'symmetrical', 'vnf_mapping'])
        return body
    def args2body(self, parsed_args):
        args = {'attributes': {}}
        body = {self.resource: args}
        # config arg passed as data overrides config yaml when both args passed
        if parsed_args.config_file:
            with open(parsed_args.config_file) as f:
                config_yaml = f.read()
            args['attributes']['config'] = config_yaml
        if parsed_args.config:
            args['attributes']['config'] = parsed_args.config

        if parsed_args.vnfd_name:
            tacker_client = self.get_client()
            tacker_client.format = parsed_args.request_format

            _id = tackerV10.find_resourceid_by_name_or_id(
                tacker_client, 'vnfd', parsed_args.vnfd_name)

            parsed_args.vnfd_id = _id
        if parsed_args.param_file:
            with open(parsed_args.param_file) as f:
                param_yaml = f.read()
            args['attributes']['param_values'] = param_yaml
        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'vnfd_id'])
        return body
Beispiel #7
0
    def args2body(self, parsed_args):
        args = {}
        body = {self.resource: args}

        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format

        if parsed_args.vnf_mapping:
            _vnf_mapping = dict()
            _vnf_mappings = parsed_args.vnf_mapping.split(",")
            for mapping in _vnf_mappings:
                vnfd_name, vnf = mapping.split(":", 1)
                _vnf_mapping[vnfd_name] = \
                    tackerV10.find_resourceid_by_name_or_id(
                        tacker_client, 'vnf', vnf)

            parsed_args.vnf_mapping = _vnf_mapping

        if parsed_args.vnffgd_template:
            with open(parsed_args.vnffgd_template) as f:
                template = f.read()
            try:
                args['vnffgd_template'] = yaml.load(template,
                                                    Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)
            if not args['vnffgd_template']:
                raise exceptions.InvalidInput('The vnffgd template is empty')

        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'vnf_mapping', 'symmetrical'])
        return body
Beispiel #8
0
    def args2body(self, parsed_args):
        args = {}
        body = {self.resource: args}

        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format

        if parsed_args.vnf_mapping:
            _vnf_mapping = dict()
            _vnf_mappings = parsed_args.vnf_mapping.split(",")
            for mapping in _vnf_mappings:
                vnfd_name, vnf = mapping.split(":", 1)
                _vnf_mapping[vnfd_name] = \
                    tackerV10.find_resourceid_by_name_or_id(
                        tacker_client, 'vnf', vnf)

            parsed_args.vnf_mapping = _vnf_mapping

        if parsed_args.vnffgd_template:
            with open(parsed_args.vnffgd_template) as f:
                template = f.read()
            try:
                args['vnffgd_template'] = yaml.load(
                    template, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)
            if not args['vnffgd_template']:
                raise exceptions.InvalidInput('The vnffgd template is empty')

        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'vnf_mapping', 'symmetrical'])
        return body
    def args2body(self, parsed_args):
        body = {
            self.resource: {
                'template_id': parsed_args.device_template_id,
            }
        }
        if parsed_args.attributes:
            try:
                attributes = dict(key_value.split('=', 1)
                                  for key_value in parsed_args.attributes)
            except ValueError:
                msg = (_('invalid argument for --attributes %s') %
                       parsed_args.attributes)
                raise exceptions.TackerCLIError(msg)
            if attributes:
                body[self.resource]['attributes'] = attributes
        if parsed_args.service_context:
            try:
                service_contexts = [dict(
                    (k.replace('-', '_'), v)
                    for k, v in (key_value.split('=', 1)
                                 for key_value in entry_string.split(',')))
                    for entry_string in parsed_args.service_context]
            except ValueError:
                msg = (_('invalid argument for --service-context %s') %
                       parsed_args.service_context)
                raise exceptions.TackerCLIError(msg)

            if service_contexts:
                body[self.resource]['service_contexts'] = service_contexts

        tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
        return body
Beispiel #10
0
    def args2body(self, parsed_args):
        body = {self.resource: {}}

        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format
        if parsed_args.cluster_name:
            _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                          'cluster',
                                                          parsed_args.
                                                          cluster_name)
            parsed_args.cluster_id = _id
        if parsed_args.vnfd_name:
            _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                          'vnfd',
                                                          parsed_args.
                                                          vnfd_name)
            parsed_args.vnfd_id = _id
        parsed_args.role = parsed_args.role.upper()
        if parsed_args.vim_name:
            _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                          'vim',
                                                          parsed_args.
                                                          vim_name)
            parsed_args.vim_id = _id
        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'cluster_id', 'vnfd_id',
                               'role', 'vim_id'])
        return body
Beispiel #11
0
    def args2body(self, parsed_args):
        body = {_VNF: {}}
        body[_VNF]['attributes'] = {}

        config = None
        if parsed_args.config_file:
            with open(parsed_args.config_file) as f:
                config_yaml = f.read()
            try:
                config = yaml.load(
                    config_yaml, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)
        if config:
            body[_VNF]['attributes'] = {'config': config}

        if parsed_args.vim_region_name:
            body[_VNF].setdefault('placement_attr', {})['region_name'] = \
                parsed_args.vim_region_name

        client = self.app.client_manager.tackerclient
        if parsed_args.vim_name:
            _id = tackerV10.find_resourceid_by_name_or_id(client, 'vim',
                                                          parsed_args.vim_name)
            parsed_args.vim_id = _id
        if parsed_args.vnfd_name:
            _id = tackerV10.find_resourceid_by_name_or_id(
                client, 'vnfd',
                parsed_args.vnfd_name
            )
            parsed_args.vnfd_id = _id
        elif parsed_args.vnfd_template:
            with open(parsed_args.vnfd_template) as f:
                template = f.read()
                try:
                    template = yaml.load(
                        template, Loader=yaml.SafeLoader)
                except yaml.YAMLError as e:
                    raise exceptions.InvalidInput(e)
                if not template:
                    raise exceptions.InvalidInput('The vnfd file is empty')
                body[_VNF]['vnfd_template'] = template

        if parsed_args.param_file:
            with open(parsed_args.param_file) as f:
                param_yaml = f.read()
            try:
                param_yaml = yaml.load(
                    param_yaml, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)
            if not param_yaml:
                raise exceptions.InvalidInput('The parameter file is empty')
            body[_VNF]['attributes'] = {'param_values': param_yaml}
        tackerV10.update_dict(parsed_args, body[_VNF],
                              ['tenant_id', 'name', 'description',
                               'vnfd_id', 'vim_id'])
        return body
Beispiel #12
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     if parsed_args.vnffgd_file:
         with open(parsed_args.vnffgd_file) as f:
             vnffgd = yaml.safe_load(f.read())
             body[self.resource]['template'] = {'vnffgd': vnffgd}
     tackerV10.update_dict(parsed_args, body[self.resource],
                           ['tenant_id', 'name', 'description'])
     return body
Beispiel #13
0
    def args2body(self, parsed_args):
        args = {'attributes': {}}
        body = {self.resource: args}
        # config arg passed as data overrides config yaml when both args passed
        config = None
        if parsed_args.config_file:
            with open(parsed_args.config_file) as f:
                config_yaml = f.read()
            try:
                config = yaml.load(
                    config_yaml, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)

        if config:
            args['attributes']['config'] = config
        if parsed_args.vim_region_name:
            args.setdefault('placement_attr', {})['region_name'] = \
                parsed_args.vim_region_name

        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format
        if parsed_args.vim_name:
                _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                              'vim',
                                                              parsed_args.
                                                              vim_name)
                parsed_args.vim_id = _id
        if parsed_args.vnfd_name:
                _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                              'vnfd',
                                                              parsed_args.
                                                              vnfd_name)
                parsed_args.vnfd_id = _id
        elif parsed_args.vnfd_template:
            with open(parsed_args.vnfd_template) as f:
                template = f.read()
            try:
                args['vnfd_template'] = yaml.load(
                    template, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)

        if parsed_args.param_file:
            with open(parsed_args.param_file) as f:
                param_yaml = f.read()
            try:
                args['attributes']['param_values'] = yaml.load(
                    param_yaml, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)
        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'description',
                               'vnfd_id', 'vim_id'])
        return body
Beispiel #14
0
    def args2body(self, parsed_args):
        args = {'attributes': {}}
        body = {self.resource: args}
        # config arg passed as data overrides config yaml when both args passed
        config = None
        if parsed_args.config_file:
            with open(parsed_args.config_file) as f:
                config_yaml = f.read()
            try:
                config = yaml.load(
                    config_yaml, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)

        if config:
            args['attributes']['config'] = config
        if parsed_args.vim_region_name:
            args.setdefault('placement_attr', {})['region_name'] = \
                parsed_args.vim_region_name

        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format
        if parsed_args.vim_name:
                _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                              'vim',
                                                              parsed_args.
                                                              vim_name)
                parsed_args.vim_id = _id
        if parsed_args.vnfd_name:
                _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                              'vnfd',
                                                              parsed_args.
                                                              vnfd_name)
                parsed_args.vnfd_id = _id
        elif parsed_args.vnfd_template:
            with open(parsed_args.vnfd_template) as f:
                template = f.read()
            try:
                args['vnfd_template'] = yaml.load(
                    template, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)

        if parsed_args.param_file:
            with open(parsed_args.param_file) as f:
                param_yaml = f.read()
            try:
                args['attributes']['param_values'] = yaml.load(
                    param_yaml, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)
        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'description',
                               'vnfd_id', 'vim_id'])
        return body
Beispiel #15
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     # config arg passed as data overrides config yaml when both args passed
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             config_yaml = f.read()
         body[self.resource]['attributes'] = {'config': config_yaml}
     if parsed_args.config:
         body[self.resource]['attributes'] = {'config': parsed_args.config}
     tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
     return body
Beispiel #16
0
    def args2body(self, parsed_args):
        body = {self.resource: {}}
        nsd = None
        with open(parsed_args.nsd_file) as f:
            nsd = yaml.safe_load(f.read())
        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'description'])
        if nsd:
            body[self.resource]['attributes'] = {'nsd': nsd}

        return body
Beispiel #17
0
    def args2body(self, parsed_args):
        body = {self.resource: {}}
        nsd = None
        with open(parsed_args.nsd_file) as f:
            nsd = yaml.safe_load(f.read())
        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'description'])
        if nsd:
            body[self.resource]['attributes'] = {'nsd': nsd}

        return body
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     # config arg passed as data overrides config yaml when both args passed
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             config_yaml = f.read()
         body[self.resource]['attributes'] = {'config': config_yaml}
     if parsed_args.config:
         body[self.resource]['attributes'] = {'config': parsed_args.config}
     tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
     return body
Beispiel #19
0
    def args2body(self, parsed_args):
        body = {_VNF: {}}
        body[_VNF]['attributes'] = {}

        config = None
        if parsed_args.config_file:
            with open(parsed_args.config_file) as f:
                config_yaml = f.read()
            try:
                config = yaml.load(config_yaml, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)
        if config:
            body[_VNF]['attributes'] = {'config': config}

        if parsed_args.vim_region_name:
            body[_VNF].setdefault('placement_attr', {})['region_name'] = \
                parsed_args.vim_region_name

        client = self.app.client_manager.tackerclient
        if parsed_args.vim_name:
            _id = tackerV10.find_resourceid_by_name_or_id(
                client, 'vim', parsed_args.vim_name)
            parsed_args.vim_id = _id
        if parsed_args.vnfd_name:
            _id = tackerV10.find_resourceid_by_name_or_id(
                client, 'vnfd', parsed_args.vnfd_name)
            parsed_args.vnfd_id = _id
        elif parsed_args.vnfd_template:
            with open(parsed_args.vnfd_template) as f:
                template = f.read()
                try:
                    template = yaml.load(template, Loader=yaml.SafeLoader)
                except yaml.YAMLError as e:
                    raise exceptions.InvalidInput(e)
                if not template:
                    raise exceptions.InvalidInput('The vnfd file is empty')
                body[_VNF]['vnfd_template'] = template

        if parsed_args.param_file:
            with open(parsed_args.param_file) as f:
                param_yaml = f.read()
            try:
                param_yaml = yaml.load(param_yaml, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)
            if not param_yaml:
                raise exceptions.InvalidInput('The parameter file is empty')
            body[_VNF]['attributes'] = {'param_values': param_yaml}
        tackerV10.update_dict(
            parsed_args, body[_VNF],
            ['tenant_id', 'name', 'description', 'vnfd_id', 'vim_id'])
        return body
    def args2body(self, parsed_args):
        body = {self.resource: {}}
        if parsed_args.vnfd_file:
            with open(parsed_args.vnfd_file) as f:
                vnfd = f.read()
                body[self.resource]['attributes'] = {'vnfd': vnfd}
        if parsed_args.vnfd:
                body[self.resource]['attributes'] = {'vnfd': parsed_args.vnfd}

        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'description'])
        return body
Beispiel #21
0
    def args2body(self, parsed_args):
        body = {self.resource: {}}
        if parsed_args.vnfd_file:
            with open(parsed_args.vnfd_file) as f:
                vnfd = f.read()
                body[self.resource]['attributes'] = {'vnfd': vnfd}
        if parsed_args.vnfd:
            body[self.resource]['attributes'] = {'vnfd': parsed_args.vnfd}

        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'description'])
        return body
Beispiel #22
0
    def args2body(self, parsed_args):
        body = {self.resource: {}}
        vnfd = None
        if parsed_args.vnfd_file:
            with open(parsed_args.vnfd_file) as f:
                vnfd = f.read()
                vnfd = yaml.load(vnfd, Loader=yaml.SafeLoader)
        if vnfd:
            body[self.resource]['attributes'] = {'vnfd': vnfd}

        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'description'])
        return body
Beispiel #23
0
    def args2body(self, parsed_args):
        body = {self.resource: {}}
        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format

        if parsed_args.vnfd_name:
            _id = tackerV10.find_resourceid_by_name_or_id(
                tacker_client, 'vnfd', parsed_args.vnfd_name)
            parsed_args.vnfd_id = _id

        tackerV10.update_dict(
            parsed_args, body[self.resource],
            ['tenant_id', 'name', 'vnfd_id', 'active', 'standby'])
        return body
Beispiel #24
0
    def args2body(self, parsed_args):
        args = {'attributes': {}}
        body = {self.resource: args}
        # config arg passed as data overrides config yaml when both args passed
        config = None
        if parsed_args.config_file:
            with open(parsed_args.config_file) as f:
                config_yaml = f.read()
            config = yaml.load(config_yaml, Loader=yaml.SafeLoader)

        if parsed_args.config:
            # TODO(sridhar_ram): Only file based input supported starting
            #       Ocata, remove all direct inputs in Pike
            utils.deprecate_warning(what="Direct config YAML input",
                                    as_of="O",
                                    remove_in=1)
            config = parsed_args.config
            if isinstance(config, str) or isinstance(config, unicode):
                config_str = parsed_args.config.decode('unicode_escape')
                config = yaml.load(config_str, Loader=yaml.SafeLoader)
        if config:
            args['attributes']['config'] = config
        if parsed_args.vim_region_name:
            args.setdefault('placement_attr', {})['region_name'] = \
                parsed_args.vim_region_name

        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format
        if parsed_args.vim_name:
            _id = tackerV10.find_resourceid_by_name_or_id(
                tacker_client, 'vim', parsed_args.vim_name)
            parsed_args.vim_id = _id
        if parsed_args.vnfd_name:
            _id = tackerV10.find_resourceid_by_name_or_id(
                tacker_client, 'vnfd', parsed_args.vnfd_name)
            parsed_args.vnfd_id = _id
        elif parsed_args.vnfd_template:
            with open(parsed_args.vnfd_template) as f:
                template = f.read()
            args['vnfd_template'] = yaml.load(template, Loader=yaml.SafeLoader)

        if parsed_args.param_file:
            with open(parsed_args.param_file) as f:
                param_yaml = f.read()
            args['attributes']['param_values'] = yaml.load(
                param_yaml, Loader=yaml.SafeLoader)
        tackerV10.update_dict(
            parsed_args, body[self.resource],
            ['tenant_id', 'name', 'description', 'vnfd_id', 'vim_id'])
        return body
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     if parsed_args.attributes:
         try:
             attributes = dict(key_value.split('=', 1)
                               for key_value in parsed_args.attributes)
         except ValueError:
             msg = (_('invalid argument for --attributes %s') %
                    parsed_args.attributes)
             raise exceptions.TackerCLIError(msg)
         if attributes:
             body[self.resource]['attributes'] = attributes
     tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
     return body
 def args2body(self, parsed_args):
     body = {
         self.resource: {
             'service_types': [
                 {'service_type': service_type}
                 for service_type in parsed_args.template_service_type],
             'infra_driver': parsed_args.infra_driver,
             'mgmt_driver': parsed_args.mgmt_driver,
         }
     }
     if parsed_args.attribute:
         body[self.resource]['attributes'] = dict(parsed_args.attribute)
     tackerV10.update_dict(parsed_args, body[self.resource],
                           ['tenant_id', 'name', 'description'])
     return body
Beispiel #27
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     if parsed_args.kwargs:
         try:
             kwargs = dict(
                 key_value.split('=', 1)
                 for key_value in parsed_args.kwargs)
         except ValueError:
             msg = (_('invalid argument for --kwargs %s') %
                    parsed_args.kwargs)
             raise exceptions.TackerCLIError(msg)
         if kwargs:
             body[self.resource]['kwargs'] = kwargs
     tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
     return body
Beispiel #28
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     config_param = None
     # config arg passed as data overrides config yaml when both args passed
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             config_yaml = f.read()
         config_param = yaml.load(config_yaml)
     vim_obj = body[self.resource]
     if config_param is not None:
         vim_utils.args2body_vim(config_param, vim_obj)
     tackerV10.update_dict(
         parsed_args, body[self.resource],
         ['tenant_id', 'name', 'description', 'is_default'])
     return body
Beispiel #29
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     # config arg passed as data overrides config yaml when both args passed
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             config_yaml = f.read()
         config_param = yaml.load(config_yaml)
     if 'auth_url' in config_param:
         raise exceptions.TackerClientException(message='Auth URL cannot '
                                                'be updated',
                                                status_code=404)
     vim_obj = body[self.resource]
     vim_utils.args2body_vim(config_param, vim_obj)
     tackerV10.update_dict(parsed_args, body[self.resource],
                           ['tenant_id', 'is_default'])
     return body
Beispiel #30
0
 def args2body(self, parsed_args):
     body = {_NSD: {}}
     nsd = None
     if not parsed_args.nsd_file:
         raise exceptions.InvalidInput("Invalid input for nsd file")
     with open(parsed_args.nsd_file) as f:
         nsd = f.read()
         try:
             nsd = yaml.load(nsd, Loader=yaml.SafeLoader)
         except yaml.YAMLError as e:
             raise exceptions.InvalidInput(e)
         if not nsd:
             raise exceptions.InvalidInput("nsd file is empty")
         body[_NSD]['attributes'] = {'nsd': nsd}
     tackerV10.update_dict(parsed_args, body[_NSD],
                           ['tenant_id', 'name', 'description'])
     return body
Beispiel #31
0
 def args2body(self, parsed_args):
     body = {_VNFFGD: {}}
     vnffgd = None
     if not parsed_args.vnffgd_file:
         raise exceptions.InvalidInput("Invalid input for vnffgd file")
     with open(parsed_args.vnffgd_file) as f:
         vnffgd = f.read()
         try:
             vnffgd = yaml.load(vnffgd, Loader=yaml.SafeLoader)
         except yaml.YAMLError as e:
             raise exceptions.InvalidInput(e)
         if not vnffgd:
             raise exceptions.InvalidInput("vnffgd file is empty")
         body[_VNFFGD]['template'] = {'vnffgd': vnffgd}
     tackerV10.update_dict(parsed_args, body[_VNFFGD],
                           ['tenant_id', 'name', 'description'])
     return body
Beispiel #32
0
    def args2body(self, parsed_args):
        body = {self.resource: {}}
        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format

        if parsed_args.vnfd_name:
            _id = tackerV10.find_resourceid_by_name_or_id(
                tacker_client, 'vnfd', parsed_args.vnfd_name)
            parsed_args.vnfd_id = _id
        policy_info = None
        with open(parsed_args.policy_file) as f:
            policy_info = yaml.safe_load(f.read())
        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'vnfd_id', 'description'])
        if policy_info:
            body[self.resource]['policy_info'] = policy_info
        return body
Beispiel #33
0
 def args2body(self, parsed_args):
     body = {_VNFD: {}}
     vnfd = None
     if not parsed_args.vnfd_file:
         raise exceptions.InvalidInput("Invalid input for vnfd file")
     with open(parsed_args.vnfd_file) as f:
         vnfd = f.read()
         try:
             vnfd = yaml.load(vnfd, Loader=yaml.SafeLoader)
         except yaml.YAMLError as e:
             raise exceptions.InvalidInput(e)
         if not vnfd:
             raise exceptions.InvalidInput("vnfd file is empty")
         body[_VNFD]['attributes'] = {'vnfd': vnfd}
     tackerV10.update_dict(parsed_args, body[_VNFD],
                           ['tenant_id', 'name', 'description'])
     return body
Beispiel #34
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     vnfd = None
     if not parsed_args.vnfd_file:
         raise exceptions.InvalidInput("Invalid input for vnfd file")
     with open(parsed_args.vnfd_file) as f:
         vnfd = f.read()
         try:
             vnfd = yaml.load(vnfd, Loader=yaml.SafeLoader)
         except yaml.YAMLError as e:
             raise exceptions.InvalidInput(e)
         if not vnfd:
             raise exceptions.InvalidInput("vnfd file is empty")
         body[self.resource]['attributes'] = {'vnfd': vnfd}
     tackerV10.update_dict(parsed_args, body[self.resource],
                           ['tenant_id', 'name', 'description'])
     return body
Beispiel #35
0
 def args2body(self, parsed_args):
     body = {
         self.resource: {
             'service_types': [{
                 'service_type': service_type
             } for service_type in parsed_args.template_service_type],
             'infra_driver':
             parsed_args.infra_driver,
             'mgmt_driver':
             parsed_args.mgmt_driver,
         }
     }
     if parsed_args.attribute:
         body[self.resource]['attributes'] = dict(parsed_args.attribute)
     tackerV10.update_dict(parsed_args, body[self.resource],
                           ['tenant_id', 'name', 'description'])
     return body
Beispiel #36
0
 def args2body(self, parsed_args):
     body = {_NSD: {}}
     nsd = None
     if not parsed_args.nsd_file:
         raise exceptions.InvalidInput("Invalid input for nsd file")
     with open(parsed_args.nsd_file) as f:
         nsd = f.read()
         try:
             nsd = yaml.load(nsd, Loader=yaml.SafeLoader)
         except yaml.YAMLError as e:
             raise exceptions.InvalidInput(e)
         if not nsd:
             raise exceptions.InvalidInput("nsd file is empty")
         body[_NSD]['attributes'] = {'nsd': nsd}
     tackerV10.update_dict(parsed_args, body[_NSD],
                           ['tenant_id', 'name', 'description'])
     return body
Beispiel #37
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     # config arg passed as data overrides config yaml when both args passed
     config = None
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             config_yaml = f.read()
         config = yaml.load(config_yaml, Loader=yaml.SafeLoader)
     if parsed_args.config:
         config = parsed_args.config
         if isinstance(config, str) or isinstance(config, unicode):
             config_str = parsed_args.config.decode('unicode_escape')
             config = yaml.load(config_str, Loader=yaml.SafeLoader)
     if config:
         body[self.resource]['attributes'] = {'config': config}
     tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
     return body
Beispiel #38
0
    def args2body(self, parsed_args):
        body = {_VNFFG: {}}
        body[_VNFFG]['attributes'] = {}

        client = self.app.client_manager.tackerclient
        if parsed_args.vnf_mapping:
            _vnf_mapping = dict()
            _vnf_mappings = parsed_args.vnf_mapping.split(",")
            for mapping in _vnf_mappings:
                vnfd_name, vnf = mapping.split(":", 1)
                _vnf_mapping[vnfd_name] = \
                    tackerV10.find_resourceid_by_name_or_id(
                        client, 'vnf', vnf)
            parsed_args.vnf_mapping = _vnf_mapping

        if parsed_args.vnffgd_name:
            _id = tackerV10.find_resourceid_by_name_or_id(
                client, 'vnffgd', parsed_args.vnffgd_name)
            parsed_args.vnffgd_id = _id
        elif parsed_args.vnffgd_template:
            with open(parsed_args.vnffgd_template) as f:
                template = f.read()
                try:
                    template = yaml.load(template, Loader=yaml.SafeLoader)
                except yaml.YAMLError as e:
                    raise exceptions.InvalidInput(e)
                if not template:
                    raise exceptions.InvalidInput('The vnffgd file is empty')
                body[_VNFFG]['vnffgd_template'] = template

        if parsed_args.param_file:
            with open(parsed_args.param_file) as f:
                param_yaml = f.read()
            try:
                param_yaml = yaml.load(
                    param_yaml, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)
            if not param_yaml:
                raise exceptions.InvalidInput('The parameter file is empty')
            body[_VNFFG]['attributes'] = {'param_values': param_yaml}
        tackerV10.update_dict(parsed_args, body[_VNFFG],
                              ['tenant_id', 'name', 'vnffgd_id',
                               'symmetrical', 'vnf_mapping', 'description'])
        return body
Beispiel #39
0
    def args2body(self, parsed_args):
        body = {_VNFFG: {}}
        body[_VNFFG]['attributes'] = {}

        client = self.app.client_manager.tackerclient
        if parsed_args.vnf_mapping:
            _vnf_mapping = dict()
            _vnf_mappings = parsed_args.vnf_mapping.split(",")
            for mapping in _vnf_mappings:
                vnfd_name, vnf = mapping.split(":", 1)
                _vnf_mapping[vnfd_name] = \
                    tackerV10.find_resourceid_by_name_or_id(
                        client, 'vnf', vnf)
            parsed_args.vnf_mapping = _vnf_mapping

        if parsed_args.vnffgd_name:
            _id = tackerV10.find_resourceid_by_name_or_id(
                client, 'vnffgd', parsed_args.vnffgd_name)
            parsed_args.vnffgd_id = _id
        elif parsed_args.vnffgd_template:
            with open(parsed_args.vnffgd_template) as f:
                template = f.read()
                try:
                    template = yaml.load(template, Loader=yaml.SafeLoader)
                except yaml.YAMLError as e:
                    raise exceptions.InvalidInput(e)
                if not template:
                    raise exceptions.InvalidInput('The vnffgd file is empty')
                body[_VNFFG]['vnffgd_template'] = template

        if parsed_args.param_file:
            with open(parsed_args.param_file) as f:
                param_yaml = f.read()
            try:
                param_yaml = yaml.load(param_yaml, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)
            if not param_yaml:
                raise exceptions.InvalidInput('The parameter file is empty')
            body[_VNFFG]['attributes'] = {'param_values': param_yaml}
        tackerV10.update_dict(parsed_args, body[_VNFFG], [
            'tenant_id', 'name', 'vnffgd_id', 'symmetrical', 'vnf_mapping',
            'description'
        ])
        return body
Beispiel #40
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     if parsed_args.vnffgd_file:
         with open(parsed_args.vnffgd_file) as f:
             vnffgd = yaml.safe_load(f.read())
             body[self.resource]['template'] = {'vnffgd': vnffgd}
     if parsed_args.vnffgd:
         # TODO(sridhar_ram): Only file based input supported starting
         #       Ocata, remove all direct inputs in Pike
         utils.deprecate_warning(what="Direct VNFFGD template input",
                                 as_of="O",
                                 remove_in=1)
         body[self.resource]['template'] = {
             'vnffgd': yaml.safe_load(parsed_args.vnffgd)
         }
     tackerV10.update_dict(parsed_args, body[self.resource],
                           ['tenant_id', 'name', 'description'])
     return body
Beispiel #41
0
    def args2body(self, parsed_args):
        args = {'attributes': {}}
        body = {self.resource: args}
        if parsed_args.vim_region_name:
            args.setdefault('placement_attr', {})['region_name'] = \
                parsed_args.vim_region_name

        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format
        if parsed_args.vim_name:
                _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                              'vim',
                                                              parsed_args.
                                                              vim_name)
                parsed_args.vim_id = _id
        if parsed_args.nsd_name:
                _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                              'nsd',
                                                              parsed_args.
                                                              nsd_name)
                parsed_args.nsd_id = _id
        elif parsed_args.nsd_template:
            with open(parsed_args.nsd_template) as f:
                template = f.read()
            try:
                args['nsd_template'] = yaml.load(
                    template, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)
            if not args['nsd_template']:
                raise exceptions.InvalidInput('The nsd file is empty')

        if parsed_args.param_file:
            with open(parsed_args.param_file) as f:
                param_yaml = f.read()
            try:
                args['attributes']['param_values'] = yaml.load(
                    param_yaml, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)
        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'description',
                               'nsd_id', 'vim_id'])
        return body
    def args2body(self, parsed_args):
        body = {self.resource: {}}
        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format

        if parsed_args.vnfd_name:
            _id = tackerV10.find_resourceid_by_name_or_id(tacker_client,
                                                          'vnfd',
                                                          parsed_args.
                                                          vnfd_name)
            parsed_args.vnfd_id = _id
        policy_info = None
        with open(parsed_args.policy_file) as f:
            policy_info = yaml.safe_load(f.read())
        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'name', 'vnfd_id', 'description'])
        if policy_info:
            body[self.resource]['policy_info'] = policy_info
        return body
Beispiel #43
0
    def args2body(self, parsed_args):
        args = {'attributes': {}}
        body = {self.resource: args}
        # config arg passed as data overrides config yaml when both args passed
        config = None
        if parsed_args.config_file:
            with open(parsed_args.config_file) as f:
                config_yaml = f.read()
            config = yaml.load(config_yaml, Loader=yaml.SafeLoader)
        if parsed_args.config:
            config = parsed_args.config
            if isinstance(config, str):
                config_str = parsed_args.config.decode('unicode_escape')
                config = yaml.load(config_str, Loader=yaml.SafeLoader)
                utils.deprecate_warning(what='yaml as string',
                                        as_of='N',
                                        in_favor_of='yaml as dictionary')

        if config:
            args['attributes']['config'] = config
        if parsed_args.vim_region_name:
            args.setdefault('placement_attr', {})['region_name'] = \
                parsed_args.vim_region_name

        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format
        if parsed_args.vim_name:
            _id = tackerV10.find_resourceid_by_name_or_id(
                tacker_client, 'vim', parsed_args.vim_name)
            parsed_args.vim_id = _id
        if parsed_args.vnfd_name:
            _id = tackerV10.find_resourceid_by_name_or_id(
                tacker_client, 'vnfd', parsed_args.vnfd_name)
            parsed_args.vnfd_id = _id
        if parsed_args.param_file:
            with open(parsed_args.param_file) as f:
                param_yaml = f.read()
            args['attributes']['param_values'] = yaml.load(
                param_yaml, Loader=yaml.SafeLoader)
        tackerV10.update_dict(
            parsed_args, body[self.resource],
            ['tenant_id', 'name', 'description', 'vnfd_id', 'vim_id'])
        return body
Beispiel #44
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     # config arg passed as data overrides config yaml when both args passed
     config = None
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             config_yaml = f.read()
         config = yaml.load(config_yaml, Loader=yaml.SafeLoader)
     if parsed_args.config:
         config = parsed_args.config
         if isinstance(parsed_args.config, str):
             config_str = parsed_args.config.decode('unicode_escape')
             config = yaml.load(config_str, Loader=yaml.SafeLoader)
             utils.deprecate_warning(what='yaml as string',
                                     as_of='N',
                                     in_favor_of='yaml as dictionary')
     if config:
         body[self.resource]['attributes'] = {'config': config}
     tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
     return body
Beispiel #45
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             vim_config = f.read()
             config_param = yaml.load(vim_config, Loader=yaml.SafeLoader)
     vim_obj = body[self.resource]
     try:
         auth_url = config_param.pop('auth_url')
     except KeyError:
         raise exceptions.TackerClientException(message='Auth URL must be '
                                                'specified',
                                                status_code=404)
     vim_obj['auth_url'] = vim_utils.validate_auth_url(auth_url).geturl()
     vim_obj['type'] = config_param.pop('type', 'openstack')
     vim_utils.args2body_vim(config_param, vim_obj)
     tackerV10.update_dict(
         parsed_args, body[self.resource],
         ['tenant_id', 'name', 'description', 'is_default'])
     return body
Beispiel #46
0
 def args2body(self, parsed_args):
     body = {_VIM: {}}
     config_param = None
     # config arg passed as data overrides config yaml when both args passed
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             config_yaml = f.read()
         try:
             config_param = yaml.load(config_yaml)
         except yaml.YAMLError as e:
             raise exceptions.InvalidInput(e)
     vim_obj = body[_VIM]
     if config_param is not None:
         vim_utils.args2body_vim(config_param, vim_obj)
     tackerV10.update_dict(parsed_args, body[_VIM],
                           ['tenant_id', 'name', 'description',
                            'is_default'])
     # type attribute is read-only, it can't be updated, so remove it
     # in update method
     body[_VIM].pop('type', None)
     return body
Beispiel #47
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     config_param = None
     # config arg passed as data overrides config yaml when both args passed
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             config_yaml = f.read()
         try:
             config_param = yaml.load(config_yaml)
         except yaml.YAMLError as e:
             raise exceptions.InvalidInput(e)
     vim_obj = body[self.resource]
     if config_param is not None:
         vim_utils.args2body_vim(config_param, vim_obj)
     tackerV10.update_dict(
         parsed_args, body[self.resource],
         ['tenant_id', 'name', 'description', 'is_default'])
     # type attribute is read-only, it can't be updated, so remove it
     # in update method
     body['vim'].pop('type', None)
     return body
Beispiel #48
0
    def args2body(self, parsed_args):
        body = {self.resource: {}}

        tacker_client = self.get_client()
        tacker_client.format = parsed_args.request_format

        if parsed_args.vnf_names:
            _vnf_id_list = list()
            _vnf_name_list = parsed_args.vnf_names.split(",")
            for vnf_name in _vnf_name_list:
                _vnf_id_list.append(
                    tackerV10.find_resourceid_by_name_or_id(
                        tacker_client, 'vnf', vnf_name))
            parsed_args.vnf_ids = _vnf_id_list

        if parsed_args.vnf_ids:
            parsed_args.vnf_ids = parsed_args.vnf_names.split(",")

        tackerV10.update_dict(parsed_args, body[self.resource],
                              ['tenant_id', 'vnf_ids', 'role'])
        return body
Beispiel #49
0
 def args2body(self, parsed_args):
     body = {_VIM: {}}
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             vim_config = f.read()
             try:
                 config_param = yaml.load(vim_config,
                                          Loader=yaml.SafeLoader)
             except yaml.YAMLError as e:
                 raise exceptions.InvalidInput(e)
     vim_obj = body[_VIM]
     try:
         auth_url = config_param.pop('auth_url')
     except KeyError:
         raise exceptions.TackerClientException(message='Auth URL must be '
                                                        'specified',
                                                status_code=404)
     vim_obj['auth_url'] = vim_utils.validate_auth_url(auth_url).geturl()
     vim_utils.args2body_vim(config_param, vim_obj)
     tackerV10.update_dict(parsed_args, body[_VIM],
                           ['tenant_id', 'name', 'description',
                            'is_default'])
     return body
Beispiel #50
0
 def args2body(self, parsed_args):
     body = {self.resource: {}}
     # config arg passed as data overrides config yaml when both args passed
     config = None
     if parsed_args.config_file:
         with open(parsed_args.config_file) as f:
             config_yaml = f.read()
         try:
             config = yaml.load(config_yaml, Loader=yaml.SafeLoader)
         except yaml.YAMLError as e:
             raise exceptions.InvalidInput(e)
     if parsed_args.config:
         config = parsed_args.config
         if isinstance(config, str) or isinstance(config, unicode):
             config_str = parsed_args.config.decode('unicode_escape')
             try:
                 config = yaml.load(config_str, Loader=yaml.SafeLoader)
             except yaml.YAMLError as e:
                 raise exceptions.InvalidInput(e)
     if config:
         body[self.resource]['attributes'] = {'config': config}
     tackerV10.update_dict(parsed_args, body[self.resource], ['tenant_id'])
     return body
Beispiel #51
0
    def args2body(self, parsed_args):
        body = {_VNF: {}}
        body[_VNF]['attributes'] = {}

        config = None
        if parsed_args.config_file:
            with open(parsed_args.config_file) as f:
                config_yaml = f.read()
            try:
                config = yaml.load(config_yaml, Loader=yaml.SafeLoader)
            except yaml.YAMLError as e:
                raise exceptions.InvalidInput(e)
        if parsed_args.config:
            config = parsed_args.config
            if isinstance(config, str) or isinstance(config, unicode):
                config_str = parsed_args.config.decode('unicode_escape')
                try:
                    config = yaml.load(config_str, Loader=yaml.SafeLoader)
                except yaml.YAMLError as e:
                    raise exceptions.InvalidInput(e)
        if config:
            body[_VNF]['attributes'] = {'config': config}
        tackerV10.update_dict(parsed_args, body[_VNF])
        return body
 def args2body(self, parsed_args):
     body = {
         'port_id': parsed_args.port_id,
     }
     tackerV10.update_dict(parsed_args, body, [])
     return body