1 """
2 ostype - pyvb module that holds all operating system type related abstractions.
3 """
4 from pyvb.constants import *
5 from pyvb.parser import *
6
8 """A parser for parsing command line output related to OS types."""
10 """Constructor. Initialize the found attributes dictionary as well
11 as the attributes we are looking for.
12 @return: A new L{pyvb.ostype.vbOsTypeParser} instance.
13 @rtype: L{pyvb.ostype.vbOsTypeParser}"""
14 self.found_attributes={}
15 self.attributes={'id':VB_RE_ID,\
16 'description':VB_RE_DESCRIPTION}
17
19 """Parse the specified file and return the results.
20 @param file: The file we are parsing.
21 @type file: File/List
22 @return: A list of L{pyvb.ostype.vbOsType} instances.
23 @rtype: List"""
24 ostypes=[]
25 for result in self._parse(file):
26 found_os=vbOsType(id=result['id'],\
27 description=result['description'])
28 ostypes.append(found_os)
29 return ostypes
30
32 """An abstraction representing the OS type of a virtual machine."""
34 """Constructor. Initialize the attributes.
35 @return: A new L{pyvb.ostype.vbOsType} instance.
36 @rtype: L{pyvb.ostype.vbOsType}"""
37 try:
38 self.setID(kw['id'])
39 except KeyError:
40 self.setID('')
41 try:
42 self.setDescription(kw['description'])
43 except KeyError:
44 self.setDescription('')
45
47 """Set the id attribute of this L{pyvb.ostype.vbOsType} instance.
48 @param id: The id attribute.
49 @type id: String
50 @return: None
51 @rtype: None"""
52 self.id=id
53
55 """Set the description attribute of this L{pyvb.ostype.vbOsType}
56 instance.
57 @param description: The description attribute.
58 @type description: String
59 @return: None
60 @rtype: None"""
61 self.description=description
62
64 """Return the id attribute of this L{pyvb.ostype.vbOsType} instance.
65 @return: The id attribute.
66 @rtype: String"""
67 return self.id
68
70 """Return the description attribute of this L{pyvb.ostype.vbOsType}
71 instance.
72 @return: The description attribute.
73 @rtype: String"""
74 return self.description
75