|
@@ 1043-1130 (lines=88) @@
|
| 1040 |
|
|
| 1041 |
|
return etree.tostring(xmlRoot).decode('utf-8') |
| 1042 |
|
|
| 1043 |
|
def modify_credential_command(self, credential_id, kwargs): |
| 1044 |
|
if not credential_id: |
| 1045 |
|
raise ValueError('modify_credential requires ' |
| 1046 |
|
'a credential_id attribute') |
| 1047 |
|
|
| 1048 |
|
xmlRoot = etree.Element('modify_credential', |
| 1049 |
|
credential_id=credential_id) |
| 1050 |
|
|
| 1051 |
|
comment = kwargs.get('comment', '') |
| 1052 |
|
if comment: |
| 1053 |
|
_xmlComment = etree.SubElement(xmlRoot, 'comment') |
| 1054 |
|
_xmlComment.text = comment |
| 1055 |
|
|
| 1056 |
|
name = kwargs.get('name', '') |
| 1057 |
|
if name: |
| 1058 |
|
_xmlName = etree.SubElement(xmlRoot, 'name') |
| 1059 |
|
_xmlName.text = name |
| 1060 |
|
|
| 1061 |
|
allow_insecure = kwargs.get('allow_insecure', '') |
| 1062 |
|
if allow_insecure: |
| 1063 |
|
_xmlAllowinsecure = etree.SubElement(xmlRoot, 'allow_insecure') |
| 1064 |
|
_xmlAllowinsecure.text = allow_insecure |
| 1065 |
|
|
| 1066 |
|
certificate = kwargs.get('certificate', '') |
| 1067 |
|
if certificate: |
| 1068 |
|
_xmlCertificate = etree.SubElement(xmlRoot, 'certificate') |
| 1069 |
|
_xmlCertificate.text = certificate |
| 1070 |
|
|
| 1071 |
|
key = kwargs.get('key', '') |
| 1072 |
|
if key: |
| 1073 |
|
phrase = key['phrase'] |
| 1074 |
|
private = key['private'] |
| 1075 |
|
if not phrase: |
| 1076 |
|
raise ValueError('modify_credential requires a phrase element') |
| 1077 |
|
if not private: |
| 1078 |
|
raise ValueError('modify_credential requires ' |
| 1079 |
|
'a private element') |
| 1080 |
|
_xmlKey = etree.SubElement(xmlRoot, 'key') |
| 1081 |
|
_xmlKeyphrase = etree.SubElement(_xmlKey, 'phrase') |
| 1082 |
|
_xmlKeyphrase.text = phrase |
| 1083 |
|
_xmlKeyprivate = etree.SubElement(_xmlKey, 'private') |
| 1084 |
|
_xmlKeyprivate.text = private |
| 1085 |
|
|
| 1086 |
|
login = kwargs.get('login', '') |
| 1087 |
|
if login: |
| 1088 |
|
_xmlLogin = etree.SubElement(xmlRoot, 'login') |
| 1089 |
|
_xmlLogin.text = login |
| 1090 |
|
|
| 1091 |
|
password = kwargs.get('password', '') |
| 1092 |
|
if password: |
| 1093 |
|
_xmlPass = etree.SubElement(xmlRoot, 'password') |
| 1094 |
|
_xmlPass.text = password |
| 1095 |
|
|
| 1096 |
|
auth_algorithm = kwargs.get('auth_algorithm', '') |
| 1097 |
|
if auth_algorithm: |
| 1098 |
|
if auth_algorithm not in ('md5', 'sha1'): |
| 1099 |
|
raise ValueError('modify_credential requires auth_algorithm ' |
| 1100 |
|
'to be either md5 or sha1') |
| 1101 |
|
_xmlAuthalg = etree.SubElement(xmlRoot, 'auth_algorithm') |
| 1102 |
|
_xmlAuthalg.text = auth_algorithm |
| 1103 |
|
|
| 1104 |
|
community = kwargs.get('community', '') |
| 1105 |
|
if community: |
| 1106 |
|
_xmlCommunity = etree.SubElement(xmlRoot, 'community') |
| 1107 |
|
_xmlCommunity.text = community |
| 1108 |
|
|
| 1109 |
|
privacy = kwargs.get('privacy', '') |
| 1110 |
|
if privacy: |
| 1111 |
|
algorithm = privacy.algorithm |
| 1112 |
|
if algorithm not in ('aes', 'des'): |
| 1113 |
|
raise ValueError('modify_credential requires algorithm ' |
| 1114 |
|
'to be either aes or des') |
| 1115 |
|
p_password = privacy.password |
| 1116 |
|
_xmlPrivacy = etree.SubElement(xmlRoot, 'privacy') |
| 1117 |
|
_xmlAlgorithm = etree.SubElement(_xmlPrivacy, 'algorithm') |
| 1118 |
|
_xmlAlgorithm.text = algorithm |
| 1119 |
|
_xmlPpass = etree.SubElement(_xmlPrivacy, 'password') |
| 1120 |
|
_xmlPpass.text = p_password |
| 1121 |
|
|
| 1122 |
|
cred_type = kwargs.get('type', '') |
| 1123 |
|
if cred_type: |
| 1124 |
|
if cred_type not in ('cc', 'snmp', 'up', 'usk'): |
| 1125 |
|
raise ValueError('modify_credential requires type ' |
| 1126 |
|
'to be either cc, snmp, up or usk') |
| 1127 |
|
_xmlCredtype = etree.SubElement(xmlRoot, 'type') |
| 1128 |
|
_xmlCredtype.text = cred_type |
| 1129 |
|
|
| 1130 |
|
return etree.tostring(xmlRoot).decode('utf-8') |
| 1131 |
|
|
| 1132 |
|
def modify_filter_command(self, filter_id, kwargs): |
| 1133 |
|
if not filter_id: |
|
@@ 185-271 (lines=87) @@
|
| 182 |
|
_xmlName.text = name |
| 183 |
|
return etree.tostring(xmlRoot).decode('utf-8') |
| 184 |
|
|
| 185 |
|
def create_credential_command(self, name, kwargs): |
| 186 |
|
|
| 187 |
|
xmlRoot = etree.Element('create_credential') |
| 188 |
|
_xmlName = etree.SubElement(xmlRoot, 'name') |
| 189 |
|
_xmlName.text = name |
| 190 |
|
|
| 191 |
|
comment = kwargs.get('comment', '') |
| 192 |
|
if comment: |
| 193 |
|
_xmlComment = etree.SubElement(xmlRoot, 'comment') |
| 194 |
|
_xmlComment.text = comment |
| 195 |
|
|
| 196 |
|
copy = kwargs.get('copy', '') |
| 197 |
|
if copy: |
| 198 |
|
_xmlCopy = etree.SubElement(xmlRoot, 'copy') |
| 199 |
|
_xmlCopy.text = copy |
| 200 |
|
|
| 201 |
|
allow_insecure = kwargs.get('allow_insecure', '') |
| 202 |
|
if allow_insecure: |
| 203 |
|
_xmlAllowinsecure = etree.SubElement(xmlRoot, 'allow_insecure') |
| 204 |
|
_xmlAllowinsecure.text = allow_insecure |
| 205 |
|
|
| 206 |
|
certificate = kwargs.get('certificate', '') |
| 207 |
|
if certificate: |
| 208 |
|
_xmlCertificate = etree.SubElement(xmlRoot, 'certificate') |
| 209 |
|
_xmlCertificate.text = certificate |
| 210 |
|
|
| 211 |
|
key = kwargs.get('key', '') |
| 212 |
|
if key: |
| 213 |
|
phrase = key['phrase'] |
| 214 |
|
private = key['private'] |
| 215 |
|
if not phrase: |
| 216 |
|
raise ValueError('create_credential requires a phrase element') |
| 217 |
|
if not private: |
| 218 |
|
raise ValueError('create_credential requires a ' |
| 219 |
|
'private element') |
| 220 |
|
|
| 221 |
|
_xmlKey = etree.SubElement(xmlRoot, 'key') |
| 222 |
|
_xmlKeyphrase = etree.SubElement(_xmlKey, 'phrase') |
| 223 |
|
_xmlKeyphrase.text = phrase |
| 224 |
|
_xmlKeyprivate = etree.SubElement(_xmlKey, 'private') |
| 225 |
|
_xmlKeyprivate.text = private |
| 226 |
|
|
| 227 |
|
login = kwargs.get('login', '') |
| 228 |
|
if login: |
| 229 |
|
_xmlLogin = etree.SubElement(xmlRoot, 'login') |
| 230 |
|
_xmlLogin.text = login |
| 231 |
|
|
| 232 |
|
password = kwargs.get('password', '') |
| 233 |
|
if password: |
| 234 |
|
_xmlPass = etree.SubElement(xmlRoot, 'password') |
| 235 |
|
_xmlPass.text = password |
| 236 |
|
|
| 237 |
|
auth_algorithm = kwargs.get('auth_algorithm', '') |
| 238 |
|
if auth_algorithm: |
| 239 |
|
if auth_algorithm not in ('md5', 'sha1'): |
| 240 |
|
raise ValueError('create_credential requires auth_algorithm ' |
| 241 |
|
'to be either md5 or sha1') |
| 242 |
|
_xmlAuthalg = etree.SubElement(xmlRoot, 'auth_algorithm') |
| 243 |
|
_xmlAuthalg.text = auth_algorithm |
| 244 |
|
|
| 245 |
|
community = kwargs.get('community', '') |
| 246 |
|
if community: |
| 247 |
|
_xmlCommunity = etree.SubElement(xmlRoot, 'community') |
| 248 |
|
_xmlCommunity.text = community |
| 249 |
|
|
| 250 |
|
privacy = kwargs.get('privacy', '') |
| 251 |
|
if privacy: |
| 252 |
|
algorithm = privacy.algorithm |
| 253 |
|
if algorithm not in ('aes', 'des'): |
| 254 |
|
raise ValueError('create_credential requires algorithm ' |
| 255 |
|
'to be either aes or des') |
| 256 |
|
p_password = privacy.password |
| 257 |
|
_xmlPrivacy = etree.SubElement(xmlRoot, 'privacy') |
| 258 |
|
_xmlAlgorithm = etree.SubElement(_xmlPrivacy, 'algorithm') |
| 259 |
|
_xmlAlgorithm.text = algorithm |
| 260 |
|
_xmlPpass = etree.SubElement(_xmlPrivacy, 'password') |
| 261 |
|
_xmlPpass.text = p_password |
| 262 |
|
|
| 263 |
|
cred_type = kwargs.get('type', '') |
| 264 |
|
if cred_type: |
| 265 |
|
if cred_type not in ('cc', 'snmp', 'up', 'usk'): |
| 266 |
|
raise ValueError('create_credential requires type ' |
| 267 |
|
'to be either cc, snmp, up or usk') |
| 268 |
|
_xmlCredtype = etree.SubElement(xmlRoot, 'type') |
| 269 |
|
_xmlCredtype.text = cred_type |
| 270 |
|
|
| 271 |
|
return etree.tostring(xmlRoot).decode('utf-8') |
| 272 |
|
|
| 273 |
|
def create_filter_command(self, name, make_unique, kwargs): |
| 274 |
|
|