示例#1
0
 def fields(self):
     return Fields(
         self,
         name=Field(kind=str, help="path to the destination file"),
         from_file=Field(kind=str,
                         default=None,
                         help="path to a source file"),
         from_url=Field(kind=str, default=None,
                        help="url to a source file"),
         from_template=Field(kind=str,
                             default=None,
                             help="path to a source Jinja2 template"),
         from_content=Field(
             kind=str,
             default=None,
             help="use this string as source data instead of a file"),
         owner=Field(kind=str, default=None, help="owner name"),
         group=Field(kind=str, default=None, help="group name"),
         mode=Field(kind=int,
                    default=None,
                    help="file mode, in hex/octal (not a string)"),
         absent=Field(kind=bool,
                      default=False,
                      help="if true, delete the file/directory"),
         overwrite=Field(kind=bool,
                         default=True,
                         help="replace existing files"),
     )
示例#2
0
文件: policy.py 项目: xinity/opsmop
 def fields(self):
     return Fields(
         self,
         name = Field(kind=str, default=None),
         variables = Field(kind=dict, loader=self.set_variables),
         roles = Field(kind=list, of=Role, loader=self.set_roles)
     )
示例#3
0
文件: role.py 项目: toshok/opsmop
 def fields(self):
     return Fields(
         self,
         name = Field(kind=str, default=None),
         variables = Field(kind=dict, loader=self.set_variables),
         resources = Field(kind=list, of=Resource, loader=self.set_resources),
         handlers  = Field(kind=dict, of=Resource, loader=self.set_handlers),
     )
示例#4
0
 def fields(self):
     return Fields(
         self,
         name=Field(kind=str),
         started=Field(kind=bool, default=True),
         enabled=Field(kind=bool, default=True),
         restarted=Field(kind=bool, default=False),
     )
示例#5
0
文件: shell.py 项目: xinity/opsmop
 def fields(self):
     return Fields(
         self,
         cmd=Field(kind=str,
                   default=None,
                   help="execute this shell code in the default shell"),
         timeout=Field(kind=int,
                       default=99999,
                       help="max time to allow this command to run"))
示例#6
0
 def fields(self):
     return Fields(
         self,
         name = Field(kind=str, help="the name of the package to install"),
         version = Field(kind=str, default=None, help="what version to install"),
         latest = Field(kind=bool, default=False, help="if true, upgrade the package regardless of version"),
         absent = Field(kind=bool, default=False, help="if true, remove the package"),
         update_cache = Field(kind=bool, default=False, help="if true, update the package cache")
     )
示例#7
0
文件: group.py 项目: xinity/opsmop
 def fields(self):
     return Fields(
         self,
         name=Field(kind=str, help="the name of the group"),
         gid=Field(kind=int,
                   default=None,
                   help="if set, use this group ID (on creation)"),
         system=Field(
             kind=bool,
             default=False,
             help="if True, specifies a system group (on creation)"),
         absent=Field(kind=bool,
                      default=False,
                      help="if True, remove this group"))
示例#8
0
    def common_field_spec(self, resource):

        from opsmop.core.field import Field
        from opsmop.core.resource import Resource

        # if adding a new field here be sure to add it to COMMON_FIELDS above

        return dict(
            when=Field(default=None,
                       lazy=True,
                       help="attaches a condition to this resource"),
            method=Field(kind=str,
                         default=None,
                         help="selects a non-default provider by name"),
            ignore_errors=Field(
                kind=bool,
                default=False,
                help="proceeds in the event of most error conditions"),
            changed_when=Field(
                default=None,
                help=
                "accepts a lambda to determine if a state change should be recorded, whose parameter is the provider result"
            ),
            failed_when=Field(
                default=None,
                help=
                "similar to ignore_errors but accepts a lambda function whose parameter is the provider result"
            ),
            variables=Field(kind=dict,
                            loader=resource.set_variables,
                            help=None),
            extra_variables=Field(kind=dict, empty=True, help=None),
            auto_dispatch=Field(kind=bool, default=True, help=None))
示例#9
0
文件: fields.py 项目: pkropf/opsmop
    def common_field_spec(self, resource):

        from opsmop.core.field import Field
        from opsmop.core.resource import Resource

        return dict(
            when            = Field(default=None, help="attaches a condition to this resource"),
            signals         = Field(kind=list, of=Resource, default=None, help="signals a handler event by name"),
            handles         = Field(kind=str, default=None, help=None),
            method          = Field(kind=str, default=None, help="selects a non-default provider by name"),
            register        = Field(kind=str, default=None, help="saves the resource result into a named variable"),
            ignore_errors   = Field(kind=bool, default=False, help="proceeds in the event of most error conditions"),
            variables       = Field(kind=dict, loader=resource.set_variables, help=None),
            extra_variables = Field(kind=dict, empty=True, help=None),
        )
示例#10
0
 def fields(self):
     return Fields(
         self,
         name = Field(kind=str, help="path to the destination file"),
         owner = Field(kind=str, default=None, help="owner name"),
         group = Field(kind=str, default=None, help="group name"),
         mode = Field(kind=int, default=None, help="file mode, in hex/octal (not a string)"),
         absent = Field(kind=bool, default=False, help="if true, delete the file/directory"),
         recursive = Field(kind=bool, default=False, help="if true, owner, group, and mode become recursive and always run if set")
     )
示例#11
0
文件: user.py 项目: xinity/opsmop
 def fields(self):
     return Fields(
         self,
         name=Field(kind=str, help="the name of the user account"),
         group=Field(
             kind=str,
             default=None,
             help="if set, assign the user's primary group (on creation)"),
         home=Field(
             kind=str,
             default=None,
             help=
             "if set, override the user's home directory location (on creation)"
         ),
         uid=Field(
             kind=int,
             default=None,
             help="if set, use a specific UID for the account (on creation)"
         ),
         system=Field(
             kind=bool,
             default=False,
             help="if true, specifies a system account (on creation)"),
         groups=Field(
             kind=list,
             default=None,
             of=str,
             help=
             "if set, assign these groups in addition to the primary groups (on creation)"
         ),
         shell=Field(kind=str,
                     default=None,
                     help="if set, assign the user's shell (on creation)"),
         absent=Field(kind=bool,
                      default=False,
                      help="if True, remove this user account"))
示例#12
0
 def fields(self):
     return Fields(self,
                   evals=Field(kind=dict),
                   variable_names=Field(kind=list))
示例#13
0
 def fields(self):
     return Fields(
         self,
         items = Field(kind=list, of=Resource),
     )
示例#14
0
文件: stop.py 项目: pkropf/opsmop
 def fields(self):
     return Fields(
         self,
         msg = Field(kind=str, allow_none=False, help="string to print")
     )
示例#15
0
 def fields(self):
     return Fields(self, variables=Field(kind=dict))
示例#16
0
    def common_field_spec(self, resource):

        from opsmop.core.field import Field
        from opsmop.core.resource import Resource

        # if adding a new field here be sure to add it to COMMON_FIELDS above

        return dict(
            when=Field(default=None,
                       lazy=True,
                       help="attaches a condition to this resource"),
            signals=Field(kind=list,
                          of=Resource,
                          default=None,
                          help="signals a handler event by name"),
            handles=Field(kind=str, default=None, help=None),
            method=Field(kind=str,
                         default=None,
                         help="selects a non-default provider by name"),
            register=Field(
                kind=str,
                default=None,
                help="saves the resource result into a named variable"),
            ignore_errors=Field(
                kind=bool,
                default=False,
                help="proceeds in the event of most error conditions"),
            variables=Field(kind=dict,
                            loader=resource.set_variables,
                            help=None),
            extra_variables=Field(kind=dict, empty=True, help=None),
            tags=Field(kind=list,
                       of=str,
                       default=None,
                       help="allows applying part of the policy"),
            failed_when=Field(
                default=None,
                lazy=True,
                help="if set, specify terms of resource application failure"),
            changed_when=Field(
                default=None,
                lazy=True,
                help="if set, only signal handlers if this is true"))