You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
227 lines
24 KiB
227 lines
24 KiB
__author__ = "frank"
|
|
|
|
import re
|
|
import splunk.admin as admin
|
|
import cp_aws_bin.utils.app_util as util
|
|
from cgi import escape
|
|
|
|
logger = util.get_logger()
|
|
|
|
ARG_VIEWBOX = "viewbox"
|
|
ARG_OVERVIEW_WIDTH = "overview_width"
|
|
ARG_OVERVIEW_HEIGHT = "overview_height"
|
|
ARG_SVGCONTAINER_HTML = "svgcontainer_html"
|
|
|
|
VPC_ICON = '''
|
|
<g id="vpc" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
<rect fill="#CEAE71" fill-opacity="0.7" x="4" y="4" width="32" height="32" rx="2"></rect>
|
|
<path d="M29,30 L21,30 L21,28 C21,27.447 20.553,27 20,27 C19.447,27 19,27.447 19,28 L19,30 L11.002,30 C10.449,30 10.002,30.447 10.002,31 C10.002,31.553 10.449,32 11.002,32 L29,32 C29.553,32 30,31.553 30,31 C30,30.447 29.553,30 29,30 M27,24 L13,24 C11.346,24 10,22.654 10,21 C10,20.201 10.314,19.453 10.891,18.883 C11.453,18.313 12.201,18 13.08,18 L14.287,18 L14.062,16.815 C14.021,16.592 14,16.325 14,16 C14,12.691 16.691,10 20,10 C23.309,10 26,12.691 26,16 C26,16.325 25.98,16.592 25.937,16.815 L25.793,18 L27,18 C28.654,18 30,19.346 30,21 C30,22.654 28.654,24 27,24 M27.999,16.111 C28,16.074 28,16.037 28,16 C28,11.589 24.411,8 20,8 C15.589,8 12,11.589 12,16 C12,16.033 12,16.066 12.001,16.1 C11.046,16.294 10.172,16.765 9.478,17.469 C8.523,18.408 8,19.662 8,21 C8,23.757 10.243,26 13,26 L27,26 C29.757,26 32,23.757 32,21 C32,18.604 30.306,16.596 27.999,16.111" fill="#FFFFFF"></path>
|
|
</g>
|
|
'''
|
|
|
|
I_RUNNING_ICON = '''
|
|
<g id="i-running">
|
|
<circle fill="#FD9805" fill-opacity="0.7" cx="23" cy="23" r="19"/>
|
|
<g transform="translate(-448.000000, -188.000000)">
|
|
<g transform="translate(400.000000, 145.000000)">
|
|
<g transform="translate(48.000000, 43.000000)">
|
|
<path fill="#FFFFFF" d="M29.364,13v1.636H14.636v14.727H13V13H29.364z M31.182,18.455H18.455v12.727h12.727V18.455z M33,33H16.636V16.636H33V33z"/>
|
|
</g>
|
|
</g>
|
|
</g>
|
|
</g>
|
|
'''
|
|
|
|
I_STOPPED_ICON = '''
|
|
<g id="i-stopped">
|
|
<circle fill="#DCDCDC" fill-opacity="0.7" cx="23" cy="23" r="19"/>
|
|
<g transform="translate(-448.000000, -188.000000)">
|
|
<g transform="translate(400.000000, 145.000000)">
|
|
<g transform="translate(48.000000, 43.000000)">
|
|
<path fill="#FFFFFF" d="M29.364,13v1.636H14.636v14.727H13V13H29.364z M31.182,18.455H18.455v12.727h12.727V18.455z M33,33H16.636V16.636H33V33z"/>
|
|
</g>
|
|
</g>
|
|
</g>
|
|
</g>
|
|
'''
|
|
|
|
SUBNET_ICON = '''
|
|
<g id="subnet" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
<path d="M20,4 L35.5884573,13 L35.5884573,31 L20,40 L4.41154273,31 L4.41154273,13 L20,4 L20,4 Z" fill="#CEAE71" fill-opacity="0.7"></path>
|
|
<path d="M20.988,27 L18.988,27 L18.988,29 L20.988,29 L20.988,27 L20.988,27 Z M23.988,30 L15.988,30 L15.988,26 L23.988,26 L23.988,30 L23.988,30 Z M18.988,21.031 C18.988,20.481 19.436,20.031 19.988,20.031 C20.54,20.031 20.988,20.481 20.988,21.031 L20.988,24 L18.988,24 L18.988,21.031 L18.988,21.031 Z M23.988,24 L22.988,24 L22.988,21.031 C22.988,19.377 21.643,18.031 19.988,18.031 C18.334,18.031 16.988,19.377 16.988,21.031 L16.988,24 L15.988,24 C14.885,24 14,24.896 14,26 L14,30 C14,31.104 14.885,32 15.988,32 L23.988,32 C25.091,32 25.988,31.104 25.988,30 L25.988,26 C25.988,24.896 25.091,24 23.988,24 L23.988,24 L23.988,24 Z M27.999,18.111 C28,18.074 28,18.037 28,18 C28,13.589 24.411,10 20,10 C15.589,10 12,13.589 12,18 C12,18.033 12,18.066 12.001,18.1 C11.046,18.294 10.172,18.765 9.477,19.469 C8.523,20.408 8,21.662 8,23 C8,25.414 9.709,27.434 11.988,27.898 L11.988,25.815 C10.826,25.401 10,24.302 10,23 C10,22.201 10.313,21.453 10.891,20.883 C11.453,20.313 12.201,20 13.08,20 L14.287,20 L14.062,18.815 C14.02,18.592 14,18.325 14,18 C14,14.691 16.691,12 20,12 C23.309,12 26,14.691 26,18 C26,18.325 25.979,18.592 25.937,18.815 L25.793,20 L27,20 C28.654,20 30,21.346 30,23 C30,24.302 29.162,25.401 28,25.816 L28,27.898 C30.279,27.434 32,25.414 32,23 C32,20.604 30.306,18.596 27.999,18.111 L27.999,18.111 L27.999,18.111 Z" fill="#FFFFFF"></path>
|
|
</g>
|
|
'''
|
|
|
|
VOL_ICON = '''
|
|
<g id="vol" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
<rect fill="#B43030" fill-opacity="0.7" x="4" y="4" width="32" height="32" rx="4"></rect>
|
|
<path d="M14,30 L14,28 L19,28 L19,26 L14,26 L14,10 L26,10 L26,26 L21,26 L21,28 L26,28 L26,30 L14,30 L14,30 Z M26,8 L14,8 C12.897,8 12,8.897 12,10 L12,30 C12,31.103 12.897,32 14,32 L26,32 C27.102,32 28,31.103 28,30 L28,10 C28,8.897 27.102,8 26,8 L26,8 L26,8 Z" fill="#FFFFFF" transform="translate(20.000000, 20.000000) rotate(180.000000) translate(-20.000000, -20.000000) "></path>
|
|
</g>
|
|
'''
|
|
|
|
SG_ICON = '''
|
|
<g id="sg" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
<rect fill="#8B572A" fill-opacity="0.7" x="4" y="4" width="32" height="32" rx="29"></rect>
|
|
<g transform="translate(12.000000, 10.000000)" fill="#FFFFFF">
|
|
<path d="M9,12 L7,12 L7,15 L9,15 L9,12 L9,12 Z M14,17.031 L2,17.031 L2,10.031 L14,10.031 L14,17.031 L14,17.031 Z M6.00285878,3.99791312 C6.00285878,2.89449617 6.89109599,2 8.0040023,2 C9.1092033,2 10.0051458,2.89826062 10.0051458,3.99791312 L10.0051458,8 L6.00285878,8 L6.00285878,3.99791312 L6.00285878,3.99791312 Z M11.995996,7.72245966 L11.995996,3.89670263 C11.995996,1.76541191 10.2008675,0.031 7.991992,0.031 C5.78445112,0.031 3.98798799,1.76541191 3.98798799,3.89670263 L3.98798799,7.72245966 L2.65331999,7.72245966 C1.18118118,7.72245966 0,8.87701618 0,10.2995947 L0,16.4538649 C0,17.8764435 1.18118118,19.031 2.65331999,19.031 L13.330664,19.031 C14.8028028,19.031 16,17.8764435 16,16.4538649 L16,10.2995947 C16,8.87701618 14.8028028,7.72245966 13.330664,7.72245966 L11.995996,7.72245966 L11.995996,7.72245966 Z"></path>
|
|
</g>
|
|
</g>
|
|
'''
|
|
|
|
ENI_ICON = '''
|
|
<g id="eni" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
<rect fill="#FF9947" fill-opacity="0.7" transform="translate(27.213203, 27.213203) rotate(-45.000000) translate(-27.213203, -27.213203) " x="12.2132034" y="12.2132034" width="30" height="30" rx="4"></rect>
|
|
<path d="M30.0057176,22 L28.004574,22 L28.004574,26 L30.0057176,26 L30.0057176,22 L30.0057176,22 Z M26.0034305,22 L24.002287,22 L24.002287,26 L26.0034305,26 L26.0034305,22 L26.0034305,22 Z M32.0068611,29 L29.0051458,29 L29.0051458,31 L24.9988565,31 L24.9988565,29 L22.0011435,29 L22.0011435,22 L20,22 L20,31 L23.0017153,31 L23.0017153,33 L31.002287,33 L31.002287,31 L34,31 L34,22 L32.0068611,22 L32.0068611,29 L32.0068611,29 Z" fill="#FFFFFF"></path>
|
|
</g>
|
|
'''
|
|
|
|
ACL_ICON = '''
|
|
<g id="acl" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
<rect fill="#CEAE71" fill-opacity="0.7" x="4" y="4" width="36" height="36" rx="40"></rect>
|
|
<g transform="translate(8.750000, 6.471154)" fill="#FFFFFF">
|
|
<path d="M17.8648076,16.1836154 C20.3497884,14.6358462 22.0192308,11.905327 22.0192308,8.76923076 C22.0192308,3.93409616 18.0851346,0 13.25,0 C8.41486538,0 4.48076924,3.93409616 4.48076924,8.76923076 C4.48076924,11.9009424 6.14253846,14.641327 8.61984616,16.1923846 C4.24948076,17.804827 0.94786538,21.6216346 0.08738462,26.3076924 L2.3224423,26.3076924 C3.43723076,21.2982692 7.90953846,17.5384616 13.25,17.5384616 C18.5904616,17.5384616 23.0627692,21.2982692 24.1775576,26.3076924 L26.4126154,26.3076924 C25.5499424,21.6161538 22.2439424,17.7927692 17.8648076,16.1836154 L17.8648076,16.1836154 L17.8648076,16.1836154 Z M6.67307692,8.76923076 C6.67307692,5.1420577 9.6228269,2.1923077 13.25,2.1923077 C16.877173,2.1923077 19.826923,5.1420577 19.826923,8.76923076 C19.826923,12.3964038 16.877173,15.3461538 13.25,15.3461538 C9.6228269,15.3461538 6.67307692,12.3964038 6.67307692,8.76923076 L6.67307692,8.76923076 L6.67307692,8.76923076 Z"></path>
|
|
<path d="M17.8757692,22.255577 L16.3258076,20.7056154 L12.473923,24.4906346 L10.10075,22.526327 L8.65163462,24.1716538 L12.5703846,27.4951924"></path>
|
|
</g>
|
|
</g>
|
|
'''
|
|
|
|
RTB_ICON = '''
|
|
<g id="rtb" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
<rect fill="#CEAE71" fill-opacity="0.7" transform="translate(26.013203, 26.013203) rotate(-45.000000) translate(-26.013203, -26.013203) " x="11.0132034" y="11.0132034" width="30" height="30" rx="4"></rect>
|
|
<path d="M35,33 L17,33 C16.447,33 16,32.551 16,32 C16,31.449 16.447,31 17,31 L35,31 C35.552,31 36,31.449 36,32 C36,32.551 35.552,33 35,33 M35,27 L17,27 C16.447,27 16,26.551 16,26 C16,25.449 16.447,25 17,25 L35,25 C35.552,25 36,25.449 36,26 C36,26.551 35.552,27 35,27 M17,19 L35,19 C35.552,19 36,19.449 36,20 C36,20.551 35.552,21 35,21 L17,21 C16.447,21 16,20.551 16,20 C16,19.449 16.447,19 17,19" fill="#FFFFFF"></path>
|
|
</g>
|
|
'''
|
|
|
|
IGW_ICON = '''
|
|
<g id="igw" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
<path d="M19,3 L34.5884573,12 L34.5884573,30 L19,39 L3.41154273,30 L3.41154273,12 L19,3 Z" fill="#CEAE71" fill-opacity="0.7"></path>
|
|
<path d="M18,17 L18,20.898 C16.044,20.5 14.5,18.956 14.102,17 L18,17 L18,17 Z M18,11.102 L18,14 L20,14 L20,11.102 C21.956,11.5 23.5,13.044 23.898,15 L14.102,15 C14.5,13.044 16.044,11.5 18,11.102 L18,11.102 L18,11.102 Z M20,20.898 L20,17 L23.898,17 C23.5,18.956 21.956,20.5 20,20.898 L20,20.898 L20,20.898 Z M19,23 C22.859,23 26,19.859 26,16 C26,12.141 22.859,9 19,9 C15.141,9 12,12.141 12,16 C12,19.859 15.141,23 19,23 L19,23 L19,23 Z M19,30 C17.897,30 17,29.104 17,28 C17,26.896 17.897,26 19,26 C20.102,26 21,26.896 21,28 C21,29.104 20.102,30 19,30 L19,30 L19,30 Z M30,27 L22.857,27 C22.41,25.279 20.859,24 19,24 C17.141,24 15.59,25.279 15.143,27 L8,27 C7.447,27 7,27.447 7,28 C7,28.553 7.447,29 8,29 L15.143,29 C15.59,30.721 17.141,32 19,32 C20.859,32 22.41,30.721 22.857,29 L30,29 C30.553,29 31,28.553 31,28 C31,27.447 30.553,27 30,27 L30,27 L30,27 Z" fill="#FFFFFF"></path>
|
|
</g>
|
|
'''
|
|
|
|
CLOUD_ICON = '''
|
|
<g id="cloud">
|
|
<path fill-opacity="0.6" fill="#FF9947" d="M42.184,23.327c0.01-0.296,0.015-0.567,0.015-0.78c0-3.561-1.387-6.91-3.905-9.428
|
|
c-2.518-2.518-5.867-3.905-9.428-3.905c-2.76,0-5.474,0.939-7.849,2.716c-1.621,1.213-2.984,2.759-3.966,4.476
|
|
c-1.077-0.56-2.27-0.853-3.505-0.853c-1.979,0-3.881,0.918-5.356,2.584c-0.983,1.111-1.684,2.465-2.025,3.871
|
|
c-1.671,0.661-3.157,1.793-4.236,3.239C0.666,26.938,0,28.948,0,31.061c0,5.362,4.363,9.725,9.725,9.725v-0.023h31.549v0.013
|
|
c4.811,0,8.726-3.914,8.726-8.726C50,27.563,46.551,23.812,42.184,23.327z M41.621,38.746v-0.004H9.126
|
|
c-3.969-0.307-7.106-3.635-7.106-7.681c0-3.339,2.109-6.308,5.263-7.36c0.01-0.003,0.02-0.008,0.029-0.013
|
|
c0.313-0.088,0.558-0.349,0.614-0.684c0.447-2.697,2.792-5.428,5.619-5.428c1.16,0,2.267,0.351,3.211,1.014
|
|
c0.094,0.087,0.206,0.157,0.334,0.205l0,0c0.494,0.183,1.044-0.046,1.266-0.523c1.916-4.125,6.197-7.035,10.509-7.035
|
|
c6.238,0,11.313,5.075,11.313,11.313c0,0.426-0.022,1.088-0.062,1.668c-0.035,0.519,0.329,0.981,0.842,1.066l0,0
|
|
c0.09,0.015,0.179,0.017,0.265,0.009v0.003c3.697,0,6.756,3.059,6.756,6.756C47.98,35.631,45.158,38.565,41.621,38.746z"/>
|
|
</g>
|
|
'''
|
|
|
|
USER_ICON = '''
|
|
<g id="user" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
<rect x="0.5" y="0.5" width="30" height="30" rx="8"></rect>
|
|
<rect fill="#FF9947" fill-opacity="0.7" x="3" y="2.69999999" width="25" height="25" rx="8"></rect>
|
|
<g transform="translate(7.000000, 5.000000)" stroke="#FFFFFF" stroke-width="1.0781">
|
|
<ellipse cx="8.58514286" cy="5.39083333" rx="4.96028571" ry="4.8225"></ellipse>
|
|
<path d="M8.58514286,10.19 C4.08,10.19 0.428571429,13.7408333 0.428571429,18.12"></path>
|
|
<path d="M16.6307804,10.3132855 C12.1256376,10.3132855 8.47420901,13.8641188 8.47420901,18.2432855" transform="translate(12.552495, 14.278286) rotate(90.000000) translate(-12.552495, -14.278286) "></path>
|
|
</g>
|
|
</g>
|
|
'''
|
|
|
|
GROUP_ICON = '''
|
|
<g id="group" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
<rect x="0.400000095" y="0.399999976" width="28" height="28" rx="8"></rect>
|
|
<rect fill="#CEAE71" fill-opacity="0.7" x="2" y="2" width="25" height="25" rx="8"></rect>
|
|
<g transform="translate(4.000000, 5.000000)" stroke="#FFFFFF" stroke-width="1.0781">
|
|
<ellipse cx="11.4381667" cy="5.1039" rx="4.33583333" ry="4.257"></ellipse>
|
|
<path d="M16.5678333,11.4786 C15.27075,10.1601 13.4520833,9.3402 11.4381667,9.3402"></path>
|
|
<path d="M11.4381667,9.3402 C7.50016667,9.3402 4.30741667,12.4749 4.30741667,16.3413"></path>
|
|
<path d="M21.54075,13.5999 C21.54075,13.4406 21.4151667,13.3092 21.2538333,13.2984 L20.7368333,13.2633 C20.636,13.1823 20.5626667,13.1238 20.4618333,13.0437 C20.4141667,12.9006 20.3555,12.7611 20.2849167,12.627 C20.29775,12.4992 20.3069167,12.4074 20.31975,12.2796 L20.6598333,11.8935 C20.7661667,11.7738 20.7588333,11.5929 20.64425,11.4813 L20.2656667,11.1105 C20.1510833,10.998 19.96775,10.9926 19.8458333,11.097 L19.4535,11.4318 C19.3545,11.5164 19.21425,11.5263 19.0978333,11.466 C19.0309167,11.4318 18.9630833,11.3994 18.8915833,11.3706 C18.821,11.3418 18.7495,11.3175 18.678,11.2959 C18.5524167,11.2581 18.4598333,11.1537 18.4506667,11.025 L18.4130833,10.5156 C18.4011667,10.3572 18.2673333,10.2348 18.1050833,10.2348 L17.56975,10.2357 C17.4075,10.2357 17.2736667,10.359 17.2626667,10.5174 L17.2113333,11.2383 C17.2104167,11.2383 17.2104167,11.2392 17.2104167,11.2392 C16.9904167,11.2905 16.77775,11.3679 16.577,11.4696 C16.4468333,11.457 16.3533333,11.448 16.2231667,11.4345 L15.83175,11.1015 C15.7098333,10.9971 15.5255833,11.0043 15.4119167,11.1168 L15.03425,11.4885 C14.9196667,11.601 14.9141667,11.781 15.0195833,11.9007 L15.356,12.2805 C15.4394167,12.375 15.4559167,12.5091 15.3954167,12.6198 C15.3569167,12.6909 15.32025,12.7647 15.2881667,12.8412 C15.2588333,12.9096 15.2340833,12.9789 15.2120833,13.0491 C15.1735833,13.1724 15.06725,13.2633 14.9361667,13.2723 L14.4283333,13.3074 C14.267,13.3191 14.1414167,13.4505 14.1423333,13.6098 L14.14325,14.1345 C14.14325,14.2929 14.2688333,14.4252 14.4301667,14.436 L15.1525,14.4846 C15.1525,14.4846 15.1534167,14.4855 15.1543333,14.4855 C15.2065833,14.7051 15.2863333,14.9175 15.39175,15.1173 C15.3789167,15.2451 15.36975,15.3369 15.3569167,15.4647 L15.026,15.8391 C14.9196667,15.9588 14.9260833,16.1397 15.0415833,16.2513 L15.4201667,16.6221 C15.53475,16.7346 15.7180833,16.74 15.84,16.6356 L16.2185833,16.3116 C16.3175833,16.227 16.45875,16.2171 16.57425,16.2774 C16.643,16.3125 16.7135833,16.3458 16.786,16.3755 C16.8593333,16.4052 16.9335833,16.4304 17.0078333,16.4529 C17.1334167,16.4907 17.226,16.5951 17.2360833,16.7238 L17.2718333,17.2161 C17.28375,17.3745 17.4175833,17.4978 17.5798333,17.4969 L18.11425,17.496 C18.2765,17.496 18.4103333,17.3727 18.4213333,17.2134 L18.4708333,16.506 C18.47175,16.506 18.47175,16.5051 18.47175,16.5051 C18.766,16.4358 19.0465,16.3206 19.30225,16.164 L19.3031667,16.164 L19.8513333,16.6302 C19.9741667,16.7346 20.1575,16.7274 20.2711667,16.6149 L20.6488333,16.2432 C20.7634167,16.1307 20.7689167,15.9498 20.6625833,15.8301 L20.3270833,15.4521 C20.2409167,15.3549 20.2308333,15.2172 20.2913333,15.1029 C20.32525,15.0381 20.3573333,14.9724 20.3866667,14.904 C20.41875,14.8275 20.44625,14.751 20.4691667,14.6736 C20.5058333,14.5539 20.614,14.4693 20.7405,14.4603 L21.2529167,14.4243 C21.41425,14.4126 21.5389167,14.2812 21.5389167,14.1219 L21.54075,13.5999 L21.54075,13.5999 Z M17.8429167,15.381 C16.9913333,15.381 16.3010833,14.7033 16.3010833,13.8681 C16.3010833,13.0329 16.9913333,12.3543 17.8429167,12.3543 C18.6945,12.3543 19.3838333,13.032 19.3838333,13.8681 C19.3838333,14.7042 18.6935833,15.381 17.8429167,15.381 L17.8429167,15.381 L17.8429167,15.381 Z"></path>
|
|
<path d="M7.36908333,5.4594 C7.03083333,5.3685 6.6715,5.3199 6.29841667,5.3199 C4.33675,5.3199 2.74725,6.6762 2.74725,8.3484 C2.74725,10.0206 4.33766667,11.3769 6.29841667,11.3769"></path>
|
|
<path d="M0.458333333,16.3413 C0.458333333,16.0992 0.4785,15.8598 0.517916667,15.6267 C0.869916667,13.536 2.74541667,11.8638 5.15441667,11.4561 C5.52383333,11.3931 5.90608333,11.3607 6.2975,11.3607"></path>
|
|
</g>
|
|
</g>
|
|
'''
|
|
|
|
POLICY_ICON = '''
|
|
<g id="policy" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
<circle cx="17" cy="17" r="17"></circle>
|
|
<circle fill="#B43030" fill-opacity="0.7" cx="17" cy="16.5" r="13.5"></circle>
|
|
<g transform="translate(8.500000, 5.000000)">
|
|
<g>
|
|
<path d="M8.5,1.28604 C10.4533,1.28604 12.0428,2.85684 12.0428,4.78716 L12.0428,8.0346 L4.9572,8.0346 L4.9572,4.788 C4.9572,2.85684 6.5467,1.28604 8.5,1.28604 L8.5,1.28604 Z M8.5,0.2562 C5.96785,0.2562 3.91425,2.2848 3.91425,4.788 L3.91425,9.06528 L13.0849,9.06528 L13.0849,4.788 C13.08575,2.2848 11.03215,0.2562 8.5,0.2562 L8.5,0.2562 L8.5,0.2562 Z" fill="#FFFFFF"></path>
|
|
<path d="M14.11255,9.06528 C14.77385,9.06528 15.3153,9.60036 15.3153,10.25388 L15.3153,17.9676 C15.3153,18.62112 14.77385,19.1562 14.11255,19.1562 L2.88745,19.1562 C2.22615,19.1562 1.6847,18.62112 1.6847,17.9676 L1.6847,10.25388 C1.6847,9.60036 2.22615,9.06528 2.88745,9.06528 L14.11255,9.06528 L14.11255,9.06528 Z M14.11255,8.0346 L2.88745,8.0346 C1.64985,8.0346 0.6426,9.03 0.6426,10.25304 L0.6426,17.96676 C0.6426,19.1898 1.64985,20.1852 2.88745,20.1852 L14.1134,20.1852 C15.351,20.1852 16.35825,19.1898 16.35825,17.96676 L16.35825,10.25304 C16.35825,9.03 15.351,8.0346 14.11255,8.0346 L14.11255,8.0346 L14.11255,8.0346 Z" fill="#FFFFFF"></path>
|
|
<path d="M10.25865,11.97336 C10.25865,11.01324 9.47155,10.2354 8.5,10.2354 C7.52845,10.2354 6.74135,11.01408 6.74135,11.97336 C6.74135,12.6168 7.0958,13.17624 7.6211,13.47696 L7.6211,16.89828 C7.6211,17.37792 8.01465,17.76768 8.50085,17.76768 C8.9862,17.76768 9.3806,17.37876 9.3806,16.89828 L9.3806,13.47696 C9.90505,13.17624 10.25865,12.61596 10.25865,11.97336 L10.25865,11.97336 Z" stroke="#FFFFFF" stroke-width="1.2263"></path>
|
|
</g>
|
|
</g>
|
|
</g>
|
|
'''
|
|
|
|
ELB_ICON = '''
|
|
<g id="elb" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
<rect fill="#CEAE71" fill-opacity="0.7" x="3" y="3" width="36" height="36" rx="6"></rect>
|
|
<path d="M31.5694004,26.2308558 L31.5694004,23.9970323 L21.7008821,23.9970323 L21.7008821,26.2308558 L23.8485896,26.2308558 C24.4795112,26.2308558 24.9961873,26.7210689 24.9961873,27.3030271 L24.9961873,27.3333975 L24.9961873,32.613407 C24.9961873,33.2024295 24.4795113,33.684099 23.8485896,33.684099 L23.8160589,33.684099 L18.1680315,33.684099 C17.5371098,33.684099 17.0120909,33.2024295 17.0120909,32.613407 L17.0120909,32.5823423 L17.0120909,27.3030271 C17.0120909,26.7210689 17.5371098,26.2308558 18.1680315,26.2308558 L18.1922516,26.2308558 L20.3074284,26.2308558 L20.3074284,23.9970323 L10.6847339,23.9970323 L10.6847339,26.2308558 L12.8324414,26.2308558 C13.4558285,26.2308558 13.980039,26.7210689 13.980039,27.3030271 L13.980039,27.3333975 L13.980039,32.613407 C13.980039,33.2024295 13.4558285,33.684099 12.8324414,33.684099 L12.7999106,33.684099 L7.14357269,33.684099 C6.50508428,33.684099 5.98840828,33.2024295 5.98840828,32.613407 L5.98840828,32.5823423 L5.98840825,27.3030271 C5.98840825,26.7210689 6.50508425,26.2308558 7.14357266,26.2308558 L7.17691182,26.2308558 L9.29205625,26.2308558 L9.29205625,23.3543333 L9.29205625,23.3465747 C9.29205625,22.9870811 9.60297375,22.6961171 9.97972882,22.6961171 L20.3074284,22.6961171 L20.3074284,18.181707 L16.3403604,18.181707 C15.701872,18.181707 15.1927628,17.6915543 15.1927628,17.0947732 L15.1927628,17.0721615 L15.1927628,8.38659301 C15.1927628,7.78981188 15.701872,7.315901 16.3403604,7.315901 L16.3728911,7.315901 L25.6679501,7.31590103 C26.3071823,7.31590103 26.8238906,7.78981191 26.8238906,8.38659304 L26.8238906,8.41765777 L26.8238906,17.0947732 C26.8238906,17.6915543 26.3072146,18.181707 25.6679501,18.181707 L25.6354517,18.181707 L21.7008821,18.181707 L21.7008821,22.6961171 L32.2578167,22.6961171 L32.2744701,22.6961171 C32.6511928,22.6961171 32.9537998,22.9870811 32.9537998,23.3465747 L32.9537998,26.2308558 L34.8647702,26.2308558 C35.4956595,26.2308558 36.0115917,26.7210689 36.0115917,27.3030271 L36.0115917,27.3333975 L36.0115917,32.613407 C36.0115917,33.2024295 35.4956595,33.684099 34.8647702,33.684099 L34.831431,33.684099 L29.1841474,33.684099 C28.5365723,33.684099 28.0282068,33.2024295 28.0282068,32.613407 L28.0282068,32.5823423 L28.0282069,27.3030271 C28.0282069,26.7210689 28.5365724,26.2308558 29.1841474,26.2308558 L29.2083676,26.2308558 L31.5694004,26.2308558 L31.5694004,26.2308558 Z M33.708765,28.3892665 L33.708765,28.3892665 L30.3400879,28.3892665 L30.3400879,31.5342318 L33.708765,31.5342318 L33.708765,28.3892665 L33.708765,28.3892665 Z M11.6689664,28.3892665 L11.6689664,28.3892665 L8.30782372,28.3892665 L8.30782372,31.5342318 L11.6689341,31.5342318 L11.6689341,28.3892665 L11.6689664,28.3892665 L11.6689664,28.3892665 Z M22.6843062,28.3892665 L22.6843062,28.3892665 L19.323972,28.3892665 L19.323972,31.5342318 L22.6843386,31.5342318 L22.6843386,28.3892665 L22.6843062,28.3892665 L22.6843062,28.3892665 Z M24.5210963,9.47352684 L24.5210963,9.47352684 L17.5045791,9.47352684 L17.5045791,16.0233869 L24.5210963,16.0233869 L24.5210963,9.47352684 L24.5210963,9.47352684 Z" fill="#FFFFFF"></path>
|
|
</g>
|
|
'''
|
|
|
|
|
|
class TopologyExportHandler(admin.MConfigHandler):
|
|
def __init__(self, scriptMode, ctxInfo):
|
|
admin.MConfigHandler.__init__(self, scriptMode, ctxInfo)
|
|
self.shouldAutoList = False
|
|
|
|
def setup(self):
|
|
for arg in [ARG_VIEWBOX, ARG_OVERVIEW_WIDTH, ARG_OVERVIEW_HEIGHT, ARG_SVGCONTAINER_HTML]:
|
|
self.supportedArgs.addOptArg(arg)
|
|
|
|
def handleCreate(self, confInfo):
|
|
svg_container_html = self.callerArgs[ARG_SVGCONTAINER_HTML][0]
|
|
overview_width = self.callerArgs[ARG_OVERVIEW_WIDTH][0]
|
|
overview_height = self.callerArgs[ARG_OVERVIEW_HEIGHT][0]
|
|
viewbox = self.callerArgs[ARG_VIEWBOX][0]
|
|
|
|
index = svg_container_html.find("<g id=\"vpc_layer\">")
|
|
if index == -1:
|
|
index_1 = svg_container_html.find("<line")
|
|
index_2 = svg_container_html.find("<text")
|
|
index_3 = svg_container_html.find("<image")
|
|
if index_1 == -1 and index_2 == -1 and index_3 == -1:
|
|
return
|
|
if index_1 == -1:
|
|
index_1 = 9999
|
|
if index_2 == -1:
|
|
index_2 = 9999
|
|
if index_3 == -1:
|
|
index_3 = 9999
|
|
index = min(index_1, index_2, index_3)
|
|
|
|
defs = "".join(
|
|
[VPC_ICON, I_RUNNING_ICON, I_STOPPED_ICON, SUBNET_ICON, VOL_ICON, SG_ICON, ENI_ICON, ACL_ICON, RTB_ICON,
|
|
IGW_ICON, CLOUD_ICON, USER_ICON, GROUP_ICON, POLICY_ICON, ELB_ICON])
|
|
svg = "<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='" + escape(overview_width) + "' height='" + escape(overview_height) + "' viewBox='" + escape(viewbox) + "' preserveAspectRatio='xMinYMin meet'><defs>" + defs + "</defs><g>" + svg_container_html[index:len(svg_container_html) - 14] + "</g></svg>"
|
|
start_index = svg.find("<image ", 0)
|
|
target_svg = svg[0:start_index]
|
|
image_type_pattern = re.compile("type=\"(\S*)\"")
|
|
image_x_pattern = re.compile("x=\"(\S*)\"")
|
|
image_y_pattern = re.compile("y=\"(\S*)\"")
|
|
|
|
while start_index < len(svg):
|
|
if svg[start_index:start_index + 7] == "<image ":
|
|
end_index = svg.find("</image>", start_index)
|
|
image_svg = svg[start_index:end_index + 8]
|
|
|
|
type_res = image_type_pattern.search(image_svg)
|
|
x_res = image_x_pattern.search(image_svg)
|
|
y_res = image_y_pattern.search(image_svg)
|
|
|
|
if type_res and x_res and y_res:
|
|
target_svg += '<use xlink:href="#' + type_res.groups()[0] + '" x="' + x_res.groups()[0] + '" y="' + \
|
|
y_res.groups()[0] + '" width="36" height="36"/>'
|
|
start_index = end_index + 8
|
|
else:
|
|
target_svg += svg[start_index]
|
|
start_index += 1
|
|
confInfo["export_topology"].append("svg", target_svg)
|
|
return
|
|
|
|
|
|
admin.init(TopologyExportHandler, admin.CONTEXT_APP_ONLY)
|