39 -name - this arg is required by the AbstractCheckpoint |
39 -name - this arg is required by the AbstractCheckpoint |
40 and is not used by the checkpoint. |
40 and is not used by the checkpoint. |
41 ''' |
41 ''' |
42 super(InitializeSMF, self).__init__(name) |
42 super(InitializeSMF, self).__init__(name) |
43 |
43 |
|
44 # The smf repository source and destination |
|
45 self.source_db = None |
|
46 self.destination_db = None |
|
47 |
|
48 # The dictionary of smf profile links to set up |
|
49 self.sys_profile_dict = None |
|
50 |
|
51 def _execute(self, dry_run=False): |
|
52 ''' |
|
53 Parameters: |
|
54 - the dry_run keyword paramater. The default value is False. |
|
55 If set to True, the log message describes the checkpoint tasks. |
|
56 |
|
57 Returns: |
|
58 - Nothing |
|
59 On failure, errors raised are managed by the engine. |
|
60 ''' |
|
61 self.logger.debug("Copying %s to %s", self.source_db, |
|
62 self.destination_db) |
|
63 if not dry_run: |
|
64 # copy the source data base to the destination data base |
|
65 shutil.copy2(self.source_db, self.destination_db) |
|
66 |
|
67 self.logger.debug("ICT current task: " |
|
68 "Creating symlinks to system profile") |
|
69 if not dry_run: |
|
70 for key, value in self.sys_profile_dict.items(): |
|
71 if os.path.exists(value): |
|
72 os.unlink(value) |
|
73 self.logger.debug("Creating a symlink between %s and %s", |
|
74 key, value) |
|
75 os.symlink(key, value) |
|
76 |
44 def execute(self, dry_run=False): |
77 def execute(self, dry_run=False): |
45 ''' |
78 ''' |
46 The AbstractCheckpoint class requires this method |
79 The AbstractCheckpoint class requires this method |
47 in sub-classes. |
80 in sub-classes. |
48 |
81 |
56 |
89 |
57 Returns: |
90 Returns: |
58 - Nothing |
91 - Nothing |
59 On failure, errors raised are managed by the engine. |
92 On failure, errors raised are managed by the engine. |
60 ''' |
93 ''' |
61 # The smf source and destination |
|
62 source_db = None |
|
63 destination_db = None |
|
64 |
|
65 self.logger.debug('ICT current task: Setting up the SMF repository') |
94 self.logger.debug('ICT current task: Setting up the SMF repository') |
66 |
95 |
67 # parse_doc populates variables necessary to execute the checkpoint |
96 # parse_doc populates variables necessary to execute the checkpoint |
68 self.parse_doc() |
97 self.parse_doc() |
69 |
98 |
70 # Set up the smf source and destination |
99 # Set up the smf source and destination |
71 source_db = os.path.join(self.target_dir, ICT.GLOBAL_DB) |
100 self.source_db = os.path.join(self.target_dir, ICT.GLOBAL_DB) |
72 destination_db = os.path.join(self.target_dir, ICT.REPO_DB) |
101 self.destination_db = os.path.join(self.target_dir, ICT.REPO_DB) |
73 |
102 |
74 sys_profile_dict = { |
103 self.sys_profile_dict = { |
75 ICT.GEN_LTD_NET_XML: |
104 ICT.GEN_LTD_NET_XML: |
76 os.path.join(self.target_dir, ICT.GENERIC_XML), |
105 os.path.join(self.target_dir, ICT.GENERIC_XML), |
77 ICT.NS_DNS_XML: |
106 ICT.NS_DNS_XML: |
78 os.path.join(self.target_dir, ICT.NAME_SVC_XML), |
107 os.path.join(self.target_dir, ICT.NAME_SVC_XML), |
79 ICT.INETD_XML: |
108 ICT.INETD_XML: |
|
109 os.path.join(self.target_dir, ICT.INETD_SVCS_XML)} |
|
110 |
|
111 self._execute(dry_run=dry_run) |
|
112 |
|
113 class InitializeSMFZone(InitializeSMF): |
|
114 '''ICT checkpoint sets up an smf repository and corrects |
|
115 the smf system profile. |
|
116 ''' |
|
117 def __init__(self, name): |
|
118 '''Initializes the class |
|
119 Parameters: |
|
120 -name - this arg is required by the AbstractCheckpoint |
|
121 and is not used by the checkpoint. |
|
122 ''' |
|
123 super(InitializeSMFZone, self).__init__(name) |
|
124 |
|
125 def execute(self, dry_run=False): |
|
126 ''' |
|
127 The AbstractCheckpoint class requires this method |
|
128 in sub-classes. |
|
129 |
|
130 Initializing SMF for a zone involves two sub-tasks: |
|
131 - Copy /lib/svc/seed/nonglobal.db to /etc/svc/repository.db |
|
132 - Create symlinks to the correct system profile files |
|
133 |
|
134 Parameters: |
|
135 - the dry_run keyword paramater. The default value is False. |
|
136 If set to True, the log message describes the checkpoint tasks. |
|
137 |
|
138 Returns: |
|
139 - Nothing |
|
140 On failure, errors raised are managed by the engine. |
|
141 ''' |
|
142 self.logger.debug('ICT current task: Setting up the SMF repository') |
|
143 |
|
144 # parse_doc populates variables necessary to execute the checkpoint |
|
145 self.parse_doc() |
|
146 |
|
147 # Set up the smf source and destination |
|
148 self.source_db = os.path.join(self.target_dir, ICT.ZONE_DB) |
|
149 self.destination_db = os.path.join(self.target_dir, ICT.REPO_DB) |
|
150 |
|
151 self.sys_profile_dict = { |
|
152 ICT.GEN_LTD_NET_XML: |
|
153 os.path.join(self.target_dir, ICT.GENERIC_XML), |
|
154 ICT.NS_FILES_XML: |
|
155 os.path.join(self.target_dir, ICT.NAME_SVC_XML), |
|
156 ICT.INETD_XML: |
80 os.path.join(self.target_dir, ICT.INETD_SVCS_XML), |
157 os.path.join(self.target_dir, ICT.INETD_SVCS_XML), |
81 os.path.basename(ICT.SC_PROFILE): |
158 ICT.PLATFORM_NONE_XML: |
82 os.path.join(self.target_dir, ICT.PROFILE_SITE)} |
159 os.path.join(self.target_dir, ICT.PLATFORM_XML)} |
83 |
160 |
84 self.logger.debug("Copying %s to %s", source_db, destination_db) |
161 self._execute(dry_run=dry_run) |
85 if not dry_run: |
|
86 # copy the source data base to the destination data base |
|
87 shutil.copy2(source_db, destination_db) |
|
88 |
|
89 self.logger.debug("ICT current task: " |
|
90 "Creating symlinks to system profile") |
|
91 if not dry_run: |
|
92 for key, value in sys_profile_dict.items(): |
|
93 if os.path.exists(value): |
|
94 os.unlink(value) |
|
95 self.logger.debug("Creating a symlink between %s and %s", |
|
96 key, value) |
|
97 os.symlink(key, value) |
|