Skip to content

Commit

Permalink
* Updated object info
Browse files Browse the repository at this point in the history
* Added certificate to register REST as param
  • Loading branch information
dkmstr committed Sep 29, 2023
1 parent 72ac4e5 commit 219acc1
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
1 change: 1 addition & 0 deletions server/src/uds/REST/methods/servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def post(self) -> typing.MutableMapping[str, typing.Any]:
os_type=typing.cast(str, self._params.get('os', types.os.KnownOS.UNKNOWN.os_name())).lower(),
mac=mac,
data=data,
certificate=self._params.get('certificate', ''),
)
except Exception as e:
return rest_result('error', error=str(e))
Expand Down
54 changes: 29 additions & 25 deletions server/src/uds/core/util/objtype.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,41 +42,45 @@

logger = logging.getLogger(__name__)

class ObjTypeInfo(typing.NamedTuple):
type: int
model: typing.Type['Model']


class ObjectType(enum.Enum):
PROVIDER = (1, models.Provider)
SERVICE = (2, models.Service)
OSMANAGER = (3, models.OSManager)
TRANSPORT = (4, models.Transport)
NETWORK = (5, models.Network)
POOL = (6, models.ServicePool)
USER_SERVICE = (7, models.UserService)
AUTHENTICATOR = (8, models.Authenticator)
USER = (9, models.User)
GROUP = (10, models.Group)
STATS_COUNTER = (11, models.StatsCounters)
STATS_EVENTS = (12, models.StatsEvents)
CALENDAR = (13, models.Calendar)
CALENDAR_RULE = (14, models.CalendarRule)
PROVIDER = ObjTypeInfo(1, models.Provider)
SERVICE = ObjTypeInfo(2, models.Service)
OSMANAGER = ObjTypeInfo(3, models.OSManager)
TRANSPORT = ObjTypeInfo(4, models.Transport)
NETWORK = ObjTypeInfo(5, models.Network)
POOL = ObjTypeInfo(6, models.ServicePool)
USER_SERVICE = ObjTypeInfo(7, models.UserService)
AUTHENTICATOR = ObjTypeInfo(8, models.Authenticator)
USER = ObjTypeInfo(9, models.User)
GROUP = ObjTypeInfo(10, models.Group)
STATS_COUNTER = ObjTypeInfo(11, models.StatsCounters)
STATS_EVENTS = ObjTypeInfo(12, models.StatsEvents)
CALENDAR = ObjTypeInfo(13, models.Calendar)
CALENDAR_RULE = ObjTypeInfo(14, models.CalendarRule)
# PROXY_TYPE = (15, models.Proxy) has been removed
METAPOOL = (16, models.MetaPool)
ACCOUNT = (17, models.Account)
REGISTERED_SERVER = (19, models.Server)
ACCOUNT_USAGE = (20, models.AccountUsage)
IMAGE = (21, models.Image)
LOG = (22, models.Log)
NOTIFICATION = (23, models.Notification)
TICKET_STORE = (24, models.TicketStore)
REGISTERED_SERVER_GROUP = (26, models.ServerGroup)
METAPOOL = ObjTypeInfo(16, models.MetaPool)
ACCOUNT = ObjTypeInfo(17, models.Account)
REGISTERED_SERVER = ObjTypeInfo(19, models.Server)
ACCOUNT_USAGE = ObjTypeInfo(20, models.AccountUsage)
IMAGE = ObjTypeInfo(21, models.Image)
LOG = ObjTypeInfo(22, models.Log)
NOTIFICATION = ObjTypeInfo(23, models.Notification)
TICKET_STORE = ObjTypeInfo(24, models.TicketStore)
REGISTERED_SERVER_GROUP = ObjTypeInfo(26, models.ServerGroup)

@property
def model(self) -> typing.Type['Model']:
return self.value[1]
return self.value.model

@property
def type(self) -> int:
"""Returns the integer value of this object type"""
return self.value[0]
return self.value.type

@staticmethod
def from_model(model: 'Model') -> 'ObjectType':
Expand Down
1 change: 1 addition & 0 deletions server/src/uds/models/servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class Server(UUIDModel, TaggingMixin, properties.PropertiesMixin):
# mac address of registered server, if any. Important for VDI actor servers mainly, informative for others
mac = models.CharField(max_length=32, default=MAC_UNKNOWN, db_index=True)
# certificate of server, if any. VDI Actors will have it's certificate on a property of the userService
# In fact CA of the certificate, but self signed will be created most times, so it will be the certificate itself
certificate = models.TextField(default='', blank=True)

# Log level, so we can filter messages for this server
Expand Down

0 comments on commit 219acc1

Please sign in to comment.