diff --git a/nailgun/entities.py b/nailgun/entities.py index 5bdb2683..e81b4601 100644 --- a/nailgun/entities.py +++ b/nailgun/entities.py @@ -1105,6 +1105,56 @@ def __init__(self, server_config=None, **kwargs): self._fields['provider_friendly_name'].default = 'Libvirt' +class OVirtComputeResource(AbstractComputeResource): + # pylint: disable=too-many-ancestors + """A representation for compute resources with Ovirt provider + """ + def __init__(self, server_config=None, **kwargs): + self._fields = { + 'password': entity_fields.StringField(), + 'user': entity_fields.StringField(), + } + super(OVirtComputeResource, self).__init__(server_config, **kwargs) + self._fields['provider'].default = 'Ovirt' + self._fields['provider'].required = True + self._fields['provider_friendly_name'].default = 'OVirt' + + def read(self, entity=None, attrs=None, ignore=None, params=None): + """Make sure, ``password`` is in the ignore list for read + """ + if ignore is None: + ignore = set() + ignore.add('password') + return super(OVirtComputeResource, self).read( + entity, attrs, ignore, params) + + +class VMWareComputeResource(AbstractComputeResource): + # pylint: disable=too-many-ancestors + """A representation for compute resources with Vmware provider + """ + def __init__(self, server_config=None, **kwargs): + self._fields = { + 'datacenter': entity_fields.StringField(), + 'password': entity_fields.StringField(), + 'set_console_password': entity_fields.BooleanField(), + 'user': entity_fields.StringField(), + } + super(VMWareComputeResource, self).__init__(server_config, **kwargs) + self._fields['provider'].default = 'Vmware' + self._fields['provider'].required = True + self._fields['provider_friendly_name'].default = 'VMware' + + def read(self, entity=None, attrs=None, ignore=None, params=None): + """Make sure, ``password`` is in the ignore list for read + """ + if ignore is None: + ignore = set() + ignore.add('password') + return super(VMWareComputeResource, self).read( + entity, attrs, ignore, params) + + class ConfigGroup( Entity, EntityCreateMixin, diff --git a/tests/test_entities.py b/tests/test_entities.py index 2ae1fde9..e8c1c3b2 100644 --- a/tests/test_entities.py +++ b/tests/test_entities.py @@ -136,6 +136,7 @@ def test_init_succeeds(self): # entities.OSDefaultTemplate, # see below entities.OperatingSystem, entities.Organization, + entities.OVirtComputeResource, entities.PackageGroupContentViewFilter, entities.PartitionTable, entities.Permission, @@ -165,6 +166,7 @@ def test_init_succeeds(self): entities.TemplateKind, entities.User, entities.UserGroup, + entities.VMWareComputeResource, ) ] entities_.extend([ @@ -1143,6 +1145,7 @@ def test_ignore_arg_v1(self): for entity, ignored_attrs in ( (entities.Errata, {'content_view_version', 'environment', 'repository'}), + (entities.OVirtComputeResource, {'password'}), (entities.SmartProxy, {'download_policy'}), (entities.SmartClassParameters, {'hidden_value'}), (entities.SmartVariable, {'hidden_value'}), @@ -1151,6 +1154,7 @@ def test_ignore_arg_v1(self): (entities.Subscription, {'organization'}), (entities.Repository, {'organization'}), (entities.User, {'password'}), + (entities.VMWareComputeResource, {'password'}), ): with self.subTest(entity): with mock.patch.object(EntityReadMixin, 'read') as read: