From 82dc945a0c938f962f95a3f939dcf349e85d095e Mon Sep 17 00:00:00 2001 From: itsikkes Date: Sun, 29 May 2016 11:45:07 +0300 Subject: [PATCH] start of buildup for creating a job --- monkey_business/cc/admin/ui/css/vis.css | 810 ------------------ monkey_business/cc/admin/ui/css/vis.min.css | 1 - monkey_business/cc/admin/ui/index.html | 24 +- .../cc/admin/ui/js/monkeysb-admin.js | 43 +- monkey_business/cc/connectors/demo.py | 36 + monkey_business/cc/main.py | 45 +- 6 files changed, 117 insertions(+), 842 deletions(-) delete mode 100644 monkey_business/cc/admin/ui/css/vis.css delete mode 100644 monkey_business/cc/admin/ui/css/vis.min.css create mode 100644 monkey_business/cc/connectors/demo.py diff --git a/monkey_business/cc/admin/ui/css/vis.css b/monkey_business/cc/admin/ui/css/vis.css deleted file mode 100644 index 5f0f38ea4..000000000 --- a/monkey_business/cc/admin/ui/css/vis.css +++ /dev/null @@ -1,810 +0,0 @@ -.vis .overlay { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; - - /* Must be displayed above for example selected Timeline items */ - z-index: 10; -} - -.vis-active { - box-shadow: 0 0 10px #86d5f8; -} - -/* override some bootstrap styles screwing up the timelines css */ - -.vis [class*="span"] { - min-height: 0; - width: auto; -} - -.vis.timeline { -} - - -.vis.timeline.root { - position: relative; - border: 1px solid #bfbfbf; - - overflow: hidden; - padding: 0; - margin: 0; - - box-sizing: border-box; -} - -.vis.timeline .vispanel { - position: absolute; - - padding: 0; - margin: 0; - - box-sizing: border-box; -} - -.vis.timeline .vispanel.center, -.vis.timeline .vispanel.left, -.vis.timeline .vispanel.right, -.vis.timeline .vispanel.top, -.vis.timeline .vispanel.bottom { - border: 1px #bfbfbf; -} - -.vis.timeline .vispanel.center, -.vis.timeline .vispanel.left, -.vis.timeline .vispanel.right { - border-top-style: solid; - border-bottom-style: solid; - overflow: hidden; -} - -.vis.timeline .vispanel.center, -.vis.timeline .vispanel.top, -.vis.timeline .vispanel.bottom { - border-left-style: solid; - border-right-style: solid; -} - -.vis.timeline .background { - overflow: hidden; -} - -.vis.timeline .vispanel > .content { - position: relative; -} - -.vis.timeline .vispanel .shadow { - position: absolute; - width: 100%; - height: 1px; - box-shadow: 0 0 10px rgba(0,0,0,0.8); - /* TODO: find a nice way to ensure shadows are drawn on top of items - z-index: 1; - */ -} - -.vis.timeline .vispanel .shadow.top { - top: -1px; - left: 0; -} - -.vis.timeline .vispanel .shadow.bottom { - bottom: -1px; - left: 0; -} - -.vis.timeline .labelset { - position: relative; - - overflow: hidden; - - box-sizing: border-box; -} - -.vis.timeline .labelset .vlabel { - position: relative; - left: 0; - top: 0; - width: 100%; - color: #4d4d4d; - - box-sizing: border-box; -} - -.vis.timeline .labelset .vlabel { - border-bottom: 1px solid #bfbfbf; -} - -.vis.timeline .labelset .vlabel:last-child { - border-bottom: none; -} - -.vis.timeline .labelset .vlabel .inner { - display: inline-block; - padding: 5px; -} - -.vis.timeline .labelset .vlabel .inner.hidden { - padding: 0; -} - - -.vis.timeline .itemset { - position: relative; - padding: 0; - margin: 0; - - box-sizing: border-box; -} - -.vis.timeline .itemset .background, -.vis.timeline .itemset .foreground { - position: absolute; - width: 100%; - height: 100%; - overflow: visible; -} - -.vis.timeline .axis { - position: absolute; - width: 100%; - height: 0; - left: 0; - z-index: 1; -} - -.vis.timeline .foreground .group { - position: relative; - box-sizing: border-box; - border-bottom: 1px solid #bfbfbf; -} - -.vis.timeline .foreground .group:last-child { - border-bottom: none; -} - - -.vis.timeline .item { - position: absolute; - color: #1A1A1A; - border-color: #97B0F8; - border-width: 1px; - background-color: #D5DDF6; - display: inline-block; - padding: 5px; -} - -.vis.timeline .item.selected { - border-color: #FFC200; - background-color: #FFF785; - - /* z-index must be higher than the z-index of custom time bar and current time bar */ - z-index: 2; -} - -.vis.timeline .editable .item.selected { - cursor: move; -} - -.vis.timeline .item.point.selected { - background-color: #FFF785; -} - -.vis.timeline .item.box { - text-align: center; - border-style: solid; - border-radius: 2px; -} - -.vis.timeline .item.point { - background: none; -} - -.vis.timeline .item.dot { - position: absolute; - padding: 0; - border-width: 4px; - border-style: solid; - border-radius: 4px; -} - -.vis.timeline .item.range { - border-style: solid; - border-radius: 2px; - box-sizing: border-box; -} - -.vis.timeline .item.background { - overflow: hidden; - border: none; - background-color: rgba(213, 221, 246, 0.4); - box-sizing: border-box; - padding: 0; - margin: 0; -} - -.vis.timeline .item.range .content { - position: relative; - display: inline-block; - max-width: 100%; - overflow: hidden; -} - -.vis.timeline .item.background .content { - position: absolute; - display: inline-block; - overflow: hidden; - max-width: 100%; - margin: 5px; -} - -.vis.timeline .item.line { - padding: 0; - position: absolute; - width: 0; - border-left-width: 1px; - border-left-style: solid; -} - -.vis.timeline .item .content { - white-space: nowrap; - overflow: hidden; -} - -.vis.timeline .item .delete { - background: url('img/timeline/delete.png') no-repeat top center; - position: absolute; - width: 24px; - height: 24px; - top: 0; - right: -24px; - cursor: pointer; -} - -.vis.timeline .item.range .drag-left { - position: absolute; - width: 24px; - max-width: 20%; - height: 100%; - top: 0; - left: -4px; - - cursor: w-resize; -} - -.vis.timeline .item.range .drag-right { - position: absolute; - width: 24px; - max-width: 20%; - height: 100%; - top: 0; - right: -4px; - - cursor: e-resize; -} - -.vis.timeline .timeaxis { - position: relative; - overflow: hidden; -} - -.vis.timeline .timeaxis.foreground { - top: 0; - left: 0; - width: 100%; -} - -.vis.timeline .timeaxis.background { - position: absolute; - top: 0; - left: 0; - width: 100%; - height: 100%; -} - -.vis.timeline .timeaxis .text { - position: absolute; - color: #4d4d4d; - padding: 3px; - white-space: nowrap; -} - -.vis.timeline .timeaxis .text.measure { - position: absolute; - padding-left: 0; - padding-right: 0; - margin-left: 0; - margin-right: 0; - visibility: hidden; -} - -.vis.timeline .timeaxis .grid.vertical { - position: absolute; - border-left: 1px solid; -} - -.vis.timeline .timeaxis .grid.minor { - border-color: #e5e5e5; -} - -.vis.timeline .timeaxis .grid.major { - border-color: #bfbfbf; -} - -.vis.timeline .currenttime { - background-color: #FF7F6E; - width: 2px; - z-index: 1; -} -.vis.timeline .customtime { - background-color: #6E94FF; - width: 2px; - cursor: move; - z-index: 1; -} -.vis.timeline.root { - /* - -webkit-transition: height .4s ease-in-out; - transition: height .4s ease-in-out; - */ -} - -.vis.timeline .vispanel { - /* - -webkit-transition: height .4s ease-in-out, top .4s ease-in-out; - transition: height .4s ease-in-out, top .4s ease-in-out; - */ -} - -.vis.timeline .axis { - /* - -webkit-transition: top .4s ease-in-out; - transition: top .4s ease-in-out; - */ -} - -/* TODO: get animation working nicely - -.vis.timeline .item { - -webkit-transition: top .4s ease-in-out; - transition: top .4s ease-in-out; -} - -.vis.timeline .item.line { - -webkit-transition: height .4s ease-in-out, top .4s ease-in-out; - transition: height .4s ease-in-out, top .4s ease-in-out; -} -/**/ - -.vis.timeline .vispanel.background.horizontal .grid.horizontal { - position: absolute; - width: 100%; - height: 0; - border-bottom: 1px solid; -} - -.vis.timeline .vispanel.background.horizontal .grid.minor { - border-color: #e5e5e5; -} - -.vis.timeline .vispanel.background.horizontal .grid.major { - border-color: #bfbfbf; -} - - -.vis.timeline .dataaxis .yAxis.major { - width: 100%; - position: absolute; - color: #4d4d4d; - white-space: nowrap; -} - -.vis.timeline .dataaxis .yAxis.major.measure{ - padding: 0px 0px 0px 0px; - margin: 0px 0px 0px 0px; - border: 0px; - visibility: hidden; - width: auto; -} - - -.vis.timeline .dataaxis .yAxis.minor{ - position: absolute; - width: 100%; - color: #bebebe; - white-space: nowrap; -} - -.vis.timeline .dataaxis .yAxis.minor.measure{ - padding: 0px 0px 0px 0px; - margin: 0px 0px 0px 0px; - border: 0px; - visibility: hidden; - width: auto; -} - -.vis.timeline .dataaxis .yAxis.title{ - position: absolute; - color: #4d4d4d; - white-space: nowrap; - bottom: 20px; - text-align: center; -} - -.vis.timeline .dataaxis .yAxis.title.measure{ - padding: 0px 0px 0px 0px; - margin: 0px 0px 0px 0px; - visibility: hidden; - width: auto; -} - -.vis.timeline .dataaxis .yAxis.title.left { - bottom: 0px; - -webkit-transform-origin: left top; - -moz-transform-origin: left top; - -ms-transform-origin: left top; - -o-transform-origin: left top; - transform-origin: left bottom; - -webkit-transform: rotate(-90deg); - -moz-transform: rotate(-90deg); - -ms-transform: rotate(-90deg); - -o-transform: rotate(-90deg); - transform: rotate(-90deg); -} - -.vis.timeline .dataaxis .yAxis.title.right { - bottom: 0px; - -webkit-transform-origin: right bottom; - -moz-transform-origin: right bottom; - -ms-transform-origin: right bottom; - -o-transform-origin: right bottom; - transform-origin: right bottom; - -webkit-transform: rotate(90deg); - -moz-transform: rotate(90deg); - -ms-transform: rotate(90deg); - -o-transform: rotate(90deg); - transform: rotate(90deg); -} - -.vis.timeline .legend { - background-color: rgba(247, 252, 255, 0.65); - padding: 5px; - border-color: #b3b3b3; - border-style:solid; - border-width: 1px; - box-shadow: 2px 2px 10px rgba(154, 154, 154, 0.55); -} - -.vis.timeline .legendText { - /*font-size: 10px;*/ - white-space: nowrap; - display: inline-block -} -.vis.timeline .graphGroup0 { - fill:#4f81bd; - fill-opacity:0; - stroke-width:2px; - stroke: #4f81bd; -} - -.vis.timeline .graphGroup1 { - fill:#f79646; - fill-opacity:0; - stroke-width:2px; - stroke: #f79646; -} - -.vis.timeline .graphGroup2 { - fill: #8c51cf; - fill-opacity:0; - stroke-width:2px; - stroke: #8c51cf; -} - -.vis.timeline .graphGroup3 { - fill: #75c841; - fill-opacity:0; - stroke-width:2px; - stroke: #75c841; -} - -.vis.timeline .graphGroup4 { - fill: #ff0100; - fill-opacity:0; - stroke-width:2px; - stroke: #ff0100; -} - -.vis.timeline .graphGroup5 { - fill: #37d8e6; - fill-opacity:0; - stroke-width:2px; - stroke: #37d8e6; -} - -.vis.timeline .graphGroup6 { - fill: #042662; - fill-opacity:0; - stroke-width:2px; - stroke: #042662; -} - -.vis.timeline .graphGroup7 { - fill:#00ff26; - fill-opacity:0; - stroke-width:2px; - stroke: #00ff26; -} - -.vis.timeline .graphGroup8 { - fill:#ff00ff; - fill-opacity:0; - stroke-width:2px; - stroke: #ff00ff; -} - -.vis.timeline .graphGroup9 { - fill: #8f3938; - fill-opacity:0; - stroke-width:2px; - stroke: #8f3938; -} - -.vis.timeline .fill { - fill-opacity:0.1; - stroke: none; -} - - -.vis.timeline .bar { - fill-opacity:0.5; - stroke-width:1px; -} - -.vis.timeline .point { - stroke-width:2px; - fill-opacity:1.0; -} - - -.vis.timeline .legendBackground { - stroke-width:1px; - fill-opacity:0.9; - fill: #ffffff; - stroke: #c2c2c2; -} - - -.vis.timeline .outline { - stroke-width:1px; - fill-opacity:1; - fill: #ffffff; - stroke: #e5e5e5; -} - -.vis.timeline .iconFill { - fill-opacity:0.3; - stroke: none; -} - - - -div.network-manipulationDiv { - border-width: 0; - border-bottom: 1px; - border-style:solid; - border-color: #d6d9d8; - background: #ffffff; /* Old browsers */ - background: -moz-linear-gradient(top, #ffffff 0%, #fcfcfc 48%, #fafafa 50%, #fcfcfc 100%); /* FF3.6+ */ - background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(48%,#fcfcfc), color-stop(50%,#fafafa), color-stop(100%,#fcfcfc)); /* Chrome,Safari4+ */ - background: -webkit-linear-gradient(top, #ffffff 0%,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%); /* Chrome10+,Safari5.1+ */ - background: -o-linear-gradient(top, #ffffff 0%,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%); /* Opera 11.10+ */ - background: -ms-linear-gradient(top, #ffffff 0%,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%); /* IE10+ */ - background: linear-gradient(to bottom, #ffffff 0%,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%); /* W3C */ - filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#fcfcfc',GradientType=0 ); /* IE6-9 */ - - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 30px; -} - -div.network-manipulation-editMode { - position:absolute; - left: 0; - top: 15px; - height: 30px; -} - -div.network-manipulation-closeDiv { - position:absolute; - right: 0; - top: 0; - width: 30px; - height: 30px; - - background-position: 20px 3px; - background-repeat: no-repeat; - background-image: url("img/network/cross.png"); - cursor: pointer; - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -div.network-manipulation-closeDiv:hover { - opacity: 0.6; -} - -div.network-manipulationUI { - position:relative; - top:-7px; - font-family: verdana; - font-size: 12px; - -moz-border-radius: 15px; - border-radius: 15px; - display:inline-block; - background-position: 0px 0px; - background-repeat:no-repeat; - height:24px; - margin: 0px 0px 0px 10px; - vertical-align:middle; - cursor: pointer; - padding: 0px 8px 0px 8px; - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -div.network-manipulationUI:hover { - box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.20); -} - -div.network-manipulationUI:active { - box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.50); -} - -div.network-manipulationUI.back { - background-image: url("img/network/backIcon.png"); -} - -div.network-manipulationUI.none:hover { - box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.0); - cursor: default; -} -div.network-manipulationUI.none:active { - box-shadow: 1px 1px 8px rgba(0, 0, 0, 0.0); -} -div.network-manipulationUI.none { - padding: 0; -} -div.network-manipulationUI.notification{ - margin: 2px; - font-weight: bold; -} - -div.network-manipulationUI.add { - background-image: url("img/network/addNodeIcon.png"); -} - -div.network-manipulationUI.edit { - background-image: url("img/network/editIcon.png"); -} - -div.network-manipulationUI.edit.editmode { - background-color: #fcfcfc; - border-style:solid; - border-width:1px; - border-color: #cccccc; -} - -div.network-manipulationUI.connect { - background-image: url("img/network/connectIcon.png"); -} - -div.network-manipulationUI.delete { - background-image: url("img/network/deleteIcon.png"); -} -/* top right bottom left */ -div.network-manipulationLabel { - margin: 0px 0px 0px 23px; - line-height: 25px; -} -div.network-seperatorLine { - display:inline-block; - width:1px; - height:20px; - background-color: #bdbdbd; - margin: 5px 7px 0px 15px; -} - -div.network-navigation_wrapper { - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; -} -div.network-navigation { - width:34px; - height:34px; - -moz-border-radius: 17px; - border-radius: 17px; - position:absolute; - display:inline-block; - background-position: 2px 2px; - background-repeat:no-repeat; - cursor: pointer; - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -div.network-navigation:hover { - box-shadow: 0px 0px 3px 3px rgba(56, 207, 21, 0.30); -} - -div.network-navigation:active { - box-shadow: 0px 0px 1px 3px rgba(56, 207, 21, 0.95); -} - -div.network-navigation.up { - background-image: url("img/network/upArrow.png"); - bottom:50px; - left:55px; -} -div.network-navigation.down { - background-image: url("img/network/downArrow.png"); - bottom:10px; - left:55px; -} -div.network-navigation.left { - background-image: url("img/network/leftArrow.png"); - bottom:10px; - left:15px; -} -div.network-navigation.right { - background-image: url("img/network/rightArrow.png"); - bottom:10px; - left:95px; -} -div.network-navigation.zoomIn { - background-image: url("img/network/plus.png"); - bottom:10px; - right:15px; -} -div.network-navigation.zoomOut { - background-image: url("img/network/minus.png"); - bottom:10px; - right:55px; -} -div.network-navigation.zoomExtends { - background-image: url("img/network/zoomExtends.png"); - bottom:50px; - right:15px; -} -div.network-tooltip { - position: absolute; - visibility: hidden; - padding: 5px; - white-space: nowrap; - - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; - border: 1px solid; - - box-shadow: 3px 3px 10px rgba(128, 128, 128, 0.5); -} \ No newline at end of file diff --git a/monkey_business/cc/admin/ui/css/vis.min.css b/monkey_business/cc/admin/ui/css/vis.min.css deleted file mode 100644 index 529a6b069..000000000 --- a/monkey_business/cc/admin/ui/css/vis.min.css +++ /dev/null @@ -1 +0,0 @@ -.vis-background,.vis-labelset,.vis-timeline{overflow:hidden}.vis .overlay{position:absolute;top:0;left:0;width:100%;height:100%;z-index:10}.vis-active{box-shadow:0 0 10px #86d5f8}.vis [class*=span]{min-height:0;width:auto}div.vis-configuration{position:relative;display:block;float:left;font-size:9pt}div.vis-configuration-wrapper{display:block;width:700px}div.vis-configuration.vis-config-option-container{display:block;width:495px;background-color:#fff;border:2px solid #f7f8fa;border-radius:4px;margin-top:20px;left:10px;padding-left:5px}div.vis-configuration.vis-config-button{display:block;width:495px;height:25px;vertical-align:middle;line-height:25px;background-color:#f7f8fa;border:2px solid #ceced0;border-radius:4px;margin-top:20px;left:10px;padding-left:5px;cursor:pointer;margin-bottom:30px}div.vis-configuration.vis-config-button.hover{background-color:#4588e6;border:2px solid #214373;color:#fff}div.vis-configuration.vis-config-item{display:block;float:left;width:495px;height:25px;vertical-align:middle;line-height:25px}div.vis-configuration.vis-config-item.vis-config-s2{left:10px;background-color:#f7f8fa;padding-left:5px;border-radius:3px}div.vis-configuration.vis-config-item.vis-config-s3{left:20px;background-color:#e4e9f0;padding-left:5px;border-radius:3px}div.vis-configuration.vis-config-item.vis-config-s4{left:30px;background-color:#cfd8e6;padding-left:5px;border-radius:3px}div.vis-configuration.vis-config-header{font-size:18px;font-weight:700}div.vis-configuration.vis-config-label{width:90pt;height:25px;line-height:25px}div.vis-configuration.vis-config-label.vis-config-s3{width:110px}div.vis-configuration.vis-config-label.vis-config-s4{width:75pt}div.vis-configuration.vis-config-colorBlock{top:1px;width:30px;height:19px;border:1px solid #444;border-radius:2px;padding:0;margin:0;cursor:pointer}input.vis-configuration.vis-config-checkbox{left:-5px}input.vis-configuration.vis-config-rangeinput{position:relative;top:-5px;width:60px;height:13px;padding:1px;margin:0;pointer-events:none}.vis-panel,.vis-timeline{padding:0;box-sizing:border-box}input.vis-configuration.vis-config-range{-webkit-appearance:none;border:0 solid #fff;background-color:transparent;width:300px;height:20px}input.vis-configuration.vis-config-range::-webkit-slider-runnable-track{width:300px;height:5px;background:#dedede;background:-moz-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#dedede),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-o-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:linear-gradient(to bottom,#dedede 0,#c8c8c8 99%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#dedede', endColorstr='#c8c8c8', GradientType=0 );border:1px solid #999;box-shadow:#aaa 0 0 3px 0;border-radius:3px}input.vis-configuration.vis-config-range::-webkit-slider-thumb{-webkit-appearance:none;border:1px solid #14334b;height:17px;width:17px;border-radius:50%;background:#3876c2;background:-moz-linear-gradient(top,#3876c2 0,#385380 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#3876c2),color-stop(100%,#385380));background:-webkit-linear-gradient(top,#3876c2 0,#385380 100%);background:-o-linear-gradient(top,#3876c2 0,#385380 100%);background:-ms-linear-gradient(top,#3876c2 0,#385380 100%);background:linear-gradient(to bottom,#3876c2 0,#385380 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#3876c2', endColorstr='#385380', GradientType=0 );box-shadow:#111927 0 0 1px 0;margin-top:-7px}input.vis-configuration.vis-config-range:focus{outline:0}input.vis-configuration.vis-config-range:focus::-webkit-slider-runnable-track{background:#9d9d9d;background:-moz-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#9d9d9d),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:-o-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#9d9d9d 0,#c8c8c8 99%);background:linear-gradient(to bottom,#9d9d9d 0,#c8c8c8 99%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#9d9d9d', endColorstr='#c8c8c8', GradientType=0 )}input.vis-configuration.vis-config-range::-moz-range-track{width:300px;height:10px;background:#dedede;background:-moz-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#dedede),color-stop(99%,#c8c8c8));background:-webkit-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-o-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:-ms-linear-gradient(top,#dedede 0,#c8c8c8 99%);background:linear-gradient(to bottom,#dedede 0,#c8c8c8 99%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#dedede', endColorstr='#c8c8c8', GradientType=0 );border:1px solid #999;box-shadow:#aaa 0 0 3px 0;border-radius:3px}input.vis-configuration.vis-config-range::-moz-range-thumb{border:none;height:1pc;width:1pc;border-radius:50%;background:#385380}input.vis-configuration.vis-config-range:-moz-focusring{outline:#fff solid 1px;outline-offset:-1px}input.vis-configuration.vis-config-range::-ms-track{width:300px;height:5px;background:0 0;border-color:transparent;border-width:6px 0;color:transparent}input.vis-configuration.vis-config-range::-ms-fill-lower{background:#777;border-radius:10px}input.vis-configuration.vis-config-range::-ms-fill-upper{background:#ddd;border-radius:10px}input.vis-configuration.vis-config-range::-ms-thumb{border:none;height:1pc;width:1pc;border-radius:50%;background:#385380}input.vis-configuration.vis-config-range:focus::-ms-fill-lower{background:#888}input.vis-configuration.vis-config-range:focus::-ms-fill-upper{background:#ccc}.vis-configuration-popup{position:absolute;background:rgba(57,76,89,.85);border:2px solid #f2faff;line-height:30px;height:30px;width:150px;text-align:center;color:#fff;font-size:14px;border-radius:4px;-webkit-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;transition:opacity .3s ease-in-out}.vis-configuration-popup:after,.vis-configuration-popup:before{left:100%;top:50%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}.vis-configuration-popup:after{border-color:rgba(136,183,213,0);border-left-color:rgba(57,76,89,.85);border-width:8px;margin-top:-8px}.vis-configuration-popup:before{border-color:rgba(194,225,245,0);border-left-color:#f2faff;border-width:9pt;margin-top:-9pt}.vis-timeline{position:relative;border:1px solid #bfbfbf;margin:0}.vis-panel{position:absolute;margin:0}.vis-panel.vis-bottom,.vis-panel.vis-center,.vis-panel.vis-left,.vis-panel.vis-right,.vis-panel.vis-top{border:1px #bfbfbf}.vis-panel.vis-center,.vis-panel.vis-left,.vis-panel.vis-right{border-top-style:solid;border-bottom-style:solid;overflow:hidden}.vis-panel.vis-bottom,.vis-panel.vis-center,.vis-panel.vis-top{border-left-style:solid;border-right-style:solid}.vis-panel>.vis-content{position:relative}.vis-panel .vis-shadow{position:absolute;width:100%;height:1px;box-shadow:0 0 10px rgba(0,0,0,.8)}.vis-itemset,.vis-labelset,.vis-labelset .vis-label{position:relative;box-sizing:border-box}.vis-panel .vis-shadow.vis-top{top:-1px;left:0}.vis-panel .vis-shadow.vis-bottom{bottom:-1px;left:0}.vis-labelset .vis-label{left:0;top:0;width:100%;color:#4d4d4d;border-bottom:1px solid #bfbfbf}.vis-labelset .vis-label.draggable{cursor:pointer}.vis-labelset .vis-label:last-child{border-bottom:none}.vis-labelset .vis-label .vis-inner{display:inline-block;padding:5px}.vis-labelset .vis-label .vis-inner.vis-hidden{padding:0}.vis-itemset{padding:0;margin:0}.vis-itemset .vis-background,.vis-itemset .vis-foreground{position:absolute;width:100%;height:100%;overflow:visible}.vis-axis{position:absolute;width:100%;height:0;left:0;z-index:1}.vis-foreground .vis-group{position:relative;box-sizing:border-box;border-bottom:1px solid #bfbfbf}.vis-foreground .vis-group:last-child{border-bottom:none}.vis-overlay{position:absolute;top:0;left:0;width:100%;height:100%;z-index:10}.vis-item{position:absolute;color:#1A1A1A;border-color:#97B0F8;border-width:1px;background-color:#D5DDF6;display:inline-block}.vis-item.vis-point.vis-selected,.vis-item.vis-selected{background-color:#FFF785}.vis-item.vis-selected{border-color:#FFC200;z-index:2}.vis-editable.vis-selected{cursor:move}.vis-item.vis-box{text-align:center;border-style:solid;border-radius:2px}.vis-item.vis-point{background:0 0}.vis-item.vis-dot{position:absolute;padding:0;border-width:4px;border-style:solid;border-radius:4px}.vis-item.vis-range{border-style:solid;border-radius:2px;box-sizing:border-box}.vis-item.vis-background{border:none;background-color:rgba(213,221,246,.4);box-sizing:border-box;padding:0;margin:0}.vis-item .vis-item-overflow{position:relative;width:100%;height:100%;padding:0;margin:0;overflow:hidden}.vis-item.vis-range .vis-item-content{position:relative;display:inline-block}.vis-item.vis-background .vis-item-content{position:absolute;display:inline-block}.vis-item.vis-line{padding:0;position:absolute;width:0;border-left-width:1px;border-left-style:solid}.vis-item .vis-item-content{white-space:nowrap;box-sizing:border-box;padding:5px}.vis-item .vis-delete{background:url(img/timeline/delete.png) center no-repeat;position:absolute;width:24px;height:24px;top:-4px;right:-24px;cursor:pointer}.vis-item.vis-range .vis-drag-left{position:absolute;width:24px;max-width:20%;min-width:2px;height:100%;top:0;left:-4px;cursor:w-resize}.vis-item.vis-range .vis-drag-right{position:absolute;width:24px;max-width:20%;min-width:2px;height:100%;top:0;right:-4px;cursor:e-resize}.vis-time-axis{position:relative;overflow:hidden}.vis-time-axis.vis-foreground{top:0;left:0;width:100%}.vis-time-axis.vis-background{position:absolute;top:0;left:0;width:100%;height:100%}.vis-time-axis .vis-text{position:absolute;color:#4d4d4d;padding:3px;overflow:hidden;box-sizing:border-box;white-space:nowrap}.vis-time-axis .vis-text.vis-measure{position:absolute;padding-left:0;padding-right:0;margin-left:0;margin-right:0;visibility:hidden}.vis-time-axis .vis-grid.vis-vertical{position:absolute;border-left:1px solid}.vis-time-axis .vis-grid.vis-minor{border-color:#e5e5e5}.vis-time-axis .vis-grid.vis-major{border-color:#bfbfbf}.vis-current-time{background-color:#FF7F6E;width:2px;z-index:1}.vis-custom-time{background-color:#6E94FF;width:2px;cursor:move;z-index:1}.vis-panel.vis-background.vis-horizontal .vis-grid.vis-horizontal{position:absolute;width:100%;height:0;border-bottom:1px solid}.vis-panel.vis-background.vis-horizontal .vis-grid.vis-minor{border-color:#e5e5e5}.vis-panel.vis-background.vis-horizontal .vis-grid.vis-major{border-color:#bfbfbf}.vis-data-axis .vis-y-axis.vis-major{width:100%;position:absolute;color:#4d4d4d;white-space:nowrap}.vis-data-axis .vis-y-axis.vis-major.vis-measure{padding:0;margin:0;border:0;visibility:hidden;width:auto}.vis-data-axis .vis-y-axis.vis-minor{position:absolute;width:100%;color:#bebebe;white-space:nowrap}.vis-data-axis .vis-y-axis.vis-minor.vis-measure{padding:0;margin:0;border:0;visibility:hidden;width:auto}.vis-data-axis .vis-y-axis.vis-title{position:absolute;color:#4d4d4d;white-space:nowrap;bottom:20px;text-align:center}.vis-data-axis .vis-y-axis.vis-title.vis-measure{padding:0;margin:0;visibility:hidden;width:auto}.vis-data-axis .vis-y-axis.vis-title.vis-left{bottom:0;-webkit-transform-origin:left top;-moz-transform-origin:left top;-ms-transform-origin:left top;-o-transform-origin:left top;transform-origin:left bottom;-webkit-transform:rotate(-90deg);-moz-transform:rotate(-90deg);-ms-transform:rotate(-90deg);-o-transform:rotate(-90deg);transform:rotate(-90deg)}.vis-data-axis .vis-y-axis.vis-title.vis-right{bottom:0;-webkit-transform-origin:right bottom;-moz-transform-origin:right bottom;-ms-transform-origin:right bottom;-o-transform-origin:right bottom;transform-origin:right bottom;-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-ms-transform:rotate(90deg);-o-transform:rotate(90deg);transform:rotate(90deg)}.vis-legend{background-color:rgba(247,252,255,.65);padding:5px;border:1px solid #b3b3b3;box-shadow:2px 2px 10px rgba(154,154,154,.55)}.vis-legend-text{white-space:nowrap;display:inline-block}.vis-graph-group0{fill:#4f81bd;fill-opacity:0;stroke-width:2px;stroke:#4f81bd}.vis-graph-group1{fill:#f79646;fill-opacity:0;stroke-width:2px;stroke:#f79646}.vis-graph-group2{fill:#8c51cf;fill-opacity:0;stroke-width:2px;stroke:#8c51cf}.vis-graph-group3{fill:#75c841;fill-opacity:0;stroke-width:2px;stroke:#75c841}.vis-graph-group4{fill:#ff0100;fill-opacity:0;stroke-width:2px;stroke:#ff0100}.vis-graph-group5{fill:#37d8e6;fill-opacity:0;stroke-width:2px;stroke:#37d8e6}.vis-graph-group6{fill:#042662;fill-opacity:0;stroke-width:2px;stroke:#042662}.vis-graph-group7{fill:#00ff26;fill-opacity:0;stroke-width:2px;stroke:#00ff26}.vis-graph-group8{fill:#f0f;fill-opacity:0;stroke-width:2px;stroke:#f0f}.vis-graph-group9{fill:#8f3938;fill-opacity:0;stroke-width:2px;stroke:#8f3938}.vis-timeline .vis-fill{fill-opacity:.1;stroke:none}.vis-timeline .vis-bar{fill-opacity:.5;stroke-width:1px}.vis-timeline .vis-point{stroke-width:2px;fill-opacity:1}.vis-timeline .vis-legend-background{stroke-width:1px;fill-opacity:.9;fill:#fff;stroke:#c2c2c2}.vis-timeline .vis-outline{stroke-width:1px;fill-opacity:1;fill:#fff;stroke:#e5e5e5}.vis-timeline .vis-icon-fill{fill-opacity:.3;stroke:none}div.vis-network div.vis-manipulation{border-width:0;border-bottom:1px;border-style:solid;border-color:#d6d9d8;background:#fff;background:-moz-linear-gradient(top,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#fff),color-stop(48%,#fcfcfc),color-stop(50%,#fafafa),color-stop(100%,#fcfcfc));background:-webkit-linear-gradient(top,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);background:-o-linear-gradient(top,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);background:-ms-linear-gradient(top,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);background:linear-gradient(to bottom,#fff 0,#fcfcfc 48%,#fafafa 50%,#fcfcfc 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#fcfcfc', GradientType=0 );position:absolute;left:0;top:0;width:100%;height:30px}div.vis-network div.vis-edit-mode{position:absolute;left:0;top:15px;height:30px}div.vis-network div.vis-close{position:absolute;right:0;top:0;width:30px;height:30px;background-position:20px 3px;background-repeat:no-repeat;background-image:url(img/network/cross.png);cursor:pointer;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}div.vis-network div.vis-close:hover{opacity:.6}div.vis-network div.vis-edit-mode div.vis-button,div.vis-network div.vis-manipulation div.vis-button{position:relative;top:-7px;font-family:verdana;font-size:9pt;-moz-border-radius:15px;border-radius:15px;display:inline-block;background-position:0 0;background-repeat:no-repeat;height:24px;margin:0 0 0 10px;vertical-align:middle;cursor:pointer;padding:0 8px;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}div.vis-network div.vis-manipulation div.vis-button:hover{box-shadow:1px 1px 8px rgba(0,0,0,.2)}div.vis-network div.vis-manipulation div.vis-button:active{box-shadow:1px 1px 8px rgba(0,0,0,.5)}div.vis-network div.vis-manipulation div.vis-button.vis-back{background-image:url(img/network/backIcon.png)}div.vis-network div.vis-manipulation div.vis-button.vis-none:hover{box-shadow:1px 1px 8px transparent;cursor:default}div.vis-network div.vis-manipulation div.vis-button.vis-none:active{box-shadow:1px 1px 8px transparent}div.vis-network div.vis-manipulation div.vis-button.vis-none{padding:0}div.vis-network div.vis-manipulation div.notification{margin:2px;font-weight:700}div.vis-network div.vis-manipulation div.vis-button.vis-add{background-image:url(img/network/addNodeIcon.png)}div.vis-network div.vis-edit-mode div.vis-button.vis-edit,div.vis-network div.vis-manipulation div.vis-button.vis-edit{background-image:url(img/network/editIcon.png)}div.vis-network div.vis-edit-mode div.vis-button.vis-edit.vis-edit-mode{background-color:#fcfcfc;border:1px solid #ccc}div.vis-network div.vis-manipulation div.vis-button.vis-connect{background-image:url(img/network/connectIcon.png)}div.vis-network div.vis-manipulation div.vis-button.vis-delete{background-image:url(img/network/deleteIcon.png)}div.vis-network div.vis-edit-mode div.vis-label,div.vis-network div.vis-manipulation div.vis-label{margin:0 0 0 23px;line-height:25px}div.vis-network div.vis-manipulation div.vis-separator-line{display:inline-block;width:1px;height:20px;background-color:#bdbdbd;margin:5px 7px 0 15px}div.vis-network-tooltip{position:absolute;visibility:hidden;padding:5px;white-space:nowrap;font-family:verdana;font-size:14px;font-color:#000;background-color:#f5f4ed;-moz-border-radius:3px;-webkit-border-radius:3px;border-radius:3px;border:1px solid #808074;box-shadow:3px 3px 10px rgba(0,0,0,.2);pointer-events:none}div.vis-network div.vis-navigation div.vis-button{width:34px;height:34px;-moz-border-radius:17px;border-radius:17px;position:absolute;display:inline-block;background-position:2px 2px;background-repeat:no-repeat;cursor:pointer;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}div.vis-network div.vis-navigation div.vis-button:hover{box-shadow:0 0 3px 3px rgba(56,207,21,.3)}div.vis-network div.vis-navigation div.vis-button:active{box-shadow:0 0 1px 3px rgba(56,207,21,.95)}div.vis-network div.vis-navigation div.vis-button.vis-up{background-image:url(img/network/upArrow.png);bottom:50px;left:55px}div.vis-network div.vis-navigation div.vis-button.vis-down{background-image:url(img/network/downArrow.png);bottom:10px;left:55px}div.vis-network div.vis-navigation div.vis-button.vis-left{background-image:url(img/network/leftArrow.png);bottom:10px;left:15px}div.vis-network div.vis-navigation div.vis-button.vis-right{background-image:url(img/network/rightArrow.png);bottom:10px;left:95px}div.vis-network div.vis-navigation div.vis-button.vis-zoomIn{background-image:url(img/network/plus.png);bottom:10px;right:15px}div.vis-network div.vis-navigation div.vis-button.vis-zoomOut{background-image:url(img/network/minus.png);bottom:10px;right:55px}div.vis-network div.vis-navigation div.vis-button.vis-zoomExtends{background-image:url(img/network/zoomExtends.png);bottom:50px;right:15px}div.vis-color-picker{position:absolute;margin-top:-140px;margin-left:30px;width:293px;height:425px;padding:10px;border-radius:15px;background-color:#fff;display:none;box-shadow:rgba(0,0,0,.5) 0 0 10px 0}div.vis-color-picker div.vis-arrow{position:absolute;top:147px;left:5px}div.vis-color-picker div.vis-arrow:after,div.vis-color-picker div.vis-arrow:before{right:100%;top:50%;border:solid transparent;content:" ";height:0;width:0;position:absolute;pointer-events:none}div.vis-color-picker div.vis-arrow:after{border-color:rgba(255,255,255,0);border-right-color:#fff;border-width:30px;margin-top:-30px}div.vis-color-picker div.vis-color{position:absolute;width:289px;height:289px;cursor:pointer}div.vis-color-picker div.vis-brightness{position:absolute;top:313px}div.vis-color-picker div.vis-opacity{position:absolute;top:350px}div.vis-color-picker div.vis-selector{position:absolute;top:137px;left:137px;width:15px;height:15px;border-radius:15px;border:1px solid #fff;background:#4c4c4c;background:-moz-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0,#4c4c4c),color-stop(12%,#595959),color-stop(25%,#666),color-stop(39%,#474747),color-stop(50%,#2c2c2c),color-stop(51%,#000),color-stop(60%,#111),color-stop(76%,#2b2b2b),color-stop(91%,#1c1c1c),color-stop(100%,#131313));background:-webkit-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-o-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:-ms-linear-gradient(top,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);background:linear-gradient(to bottom,#4c4c4c 0,#595959 12%,#666 25%,#474747 39%,#2c2c2c 50%,#000 51%,#111 60%,#2b2b2b 76%,#1c1c1c 91%,#131313 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#4c4c4c', endColorstr='#131313', GradientType=0 )}div.vis-color-picker div.vis-initial-color,div.vis-color-picker div.vis-new-color{width:140px;height:20px;top:380px;font-size:10px;color:rgba(0,0,0,.4);line-height:20px;position:absolute;vertical-align:middle}div.vis-color-picker div.vis-new-color{border:1px solid rgba(0,0,0,.1);border-radius:5px;left:159px;text-align:right;padding-right:2px}div.vis-color-picker div.vis-initial-color{border:1px solid rgba(0,0,0,.1);border-radius:5px;left:10px;text-align:left;padding-left:2px}div.vis-color-picker div.vis-label{position:absolute;width:300px;left:10px}div.vis-color-picker div.vis-label.vis-brightness{top:300px}div.vis-color-picker div.vis-label.vis-opacity{top:338px}div.vis-color-picker div.vis-button{position:absolute;width:68px;height:25px;border-radius:10px;vertical-align:middle;text-align:center;line-height:25px;top:410px;border:2px solid #d9d9d9;background-color:#f7f7f7;cursor:pointer}div.vis-color-picker div.vis-button.vis-cancel{left:5px}div.vis-color-picker div.vis-button.vis-load{left:82px}div.vis-color-picker div.vis-button.vis-apply{left:159px}div.vis-color-picker div.vis-button.vis-save{left:236px}div.vis-color-picker input.vis-range{width:290px;height:20px} \ No newline at end of file diff --git a/monkey_business/cc/admin/ui/index.html b/monkey_business/cc/admin/ui/index.html index 85424a042..44fb98e56 100644 --- a/monkey_business/cc/admin/ui/index.html +++ b/monkey_business/cc/admin/ui/index.html @@ -17,7 +17,6 @@ - @@ -68,14 +67,24 @@ Options
- + + + +
+
+
+
@@ -115,8 +124,7 @@ Update --> - +
diff --git a/monkey_business/cc/admin/ui/js/monkeysb-admin.js b/monkey_business/cc/admin/ui/js/monkeysb-admin.js index 8ac85184c..c67fdd13f 100644 --- a/monkey_business/cc/admin/ui/js/monkeysb-admin.js +++ b/monkey_business/cc/admin/ui/js/monkeysb-admin.js @@ -96,26 +96,6 @@ function initAdmin() { startval: $, }); - - jobCfg = new JSONEditor(document.getElementById('job-config'),{ - schema: { - type: "object", - title: "Job", - properties: { - vlan: { - title: "Vlan", - type: "integer", - }, - }, - options: { - "collapsed": true - }, - }, - disable_edit_json: false, - }); - - - window.setTimeout(updateJobs, 10000); loadVcenterConfig(); updateJobs(); @@ -173,6 +153,29 @@ function updateVcenterConfig() { } function createNewJob() { + elem = document.getElementById('job-config'); + elem.innerHTML = "" + jobCfg = new JSONEditor(elem,{ + schema: { + type: "object", + title: "Job", + properties: { + vlan: { + title: "Vlan", + type: "integer", + $ref: "/info?type=vlans" + }, + }, + options: { + "collapsed": true + }, + }, + ajax: true, + disable_edit_json: false, + }); +} + +function configSched() { } diff --git a/monkey_business/cc/connectors/demo.py b/monkey_business/cc/connectors/demo.py new file mode 100644 index 000000000..d37a66c2e --- /dev/null +++ b/monkey_business/cc/connectors/demo.py @@ -0,0 +1,36 @@ +from connectors import NetControllerConnector + +demo_state = { + 501: ["Machine A", "Machine B"], + 502: ["Machine C",], + 503: ["Machine D",], + 514: ["Machine E", "Machine F"], +} + + +class DemoConnector(NetControllerConnector): + def __init__(self): + self._conn = None + self._properties = { + "address": "127.0.0.1", + "port": 0, + "username": "", + "password": "", + } + + def connect(self): + self._conn = object() + + def is_connected(self): + return not self._conn == None + + def disconnect(self): + self._conn = None + + def get_vlans_list(self): + return demo_state.keys() + + def get_entities_on_vlan(self, vlanid): + if (demo_state.has_key(vlanid)): + return demo_state[vlanid] + return [] diff --git a/monkey_business/cc/main.py b/monkey_business/cc/main.py index b3eef0387..96896e10f 100644 --- a/monkey_business/cc/main.py +++ b/monkey_business/cc/main.py @@ -8,6 +8,7 @@ import json from datetime import datetime import dateutil.parser from connectors.vcenter import VCenterConnector +from connectors.demo import DemoConnector MONGO_URL = os.environ.get('MONGO_URL') if not MONGO_URL: @@ -17,6 +18,10 @@ app = Flask(__name__) app.config['MONGO_URI'] = MONGO_URL mongo = PyMongo(app) +available_connectors=[VCenterConnector, DemoConnector] + +active_connectors = {} + class Root(restful.Resource): def get(self): return { @@ -66,7 +71,7 @@ class Connector(restful.Resource): type = request.args.get('type') if (type == 'vcenter'): vcenter = VCenterConnector() - properties = mongo.db.connector.find_one({"type": 'vcenter'}) + properties = mongo.db.connector.find_one({"type": 'VCenterConnector'}) if properties: vcenter.load_properties(properties) ret = vcenter.get_properties() @@ -79,14 +84,24 @@ class Connector(restful.Resource): if (settings_json.get("type") == 'vcenter'): # preserve password - properties = mongo.db.connector.find_one({"type": 'vcenter'}) + properties = mongo.db.connector.find_one({"type": 'VCenterConnector'}) if properties and (not settings_json.has_key("password") or not settings_json["password"]): settings_json["password"] = properties.get("password") - return mongo.db.connector.update({"type": 'vcenter'}, + return mongo.db.connector.update({"type": 'VCenterConnector'}, {"$set": settings_json}, upsert=True) +class Info(restful.Resource): + def get(self, **kw): + type = request.args.get('type') + if type == "vlans": + update_connectors() + vlans = set() + for con in active_connectors: + vlans.update(active_connectors[con].get_vlans_list()) + return {"enum": list(vlans)} + def normalize_obj(obj): if obj.has_key('_id') and not obj.has_key('id'): @@ -113,6 +128,29 @@ def output_json(obj, code, headers=None): resp.headers.extend(headers or {}) return resp + +def refresh_connector_config(name): + properties = mongo.db.connector.find_one({"type": name}) + if properties: + active_connectors[name].load_properties(properties) + + +def update_connectors(): + for con in available_connectors: + if con.__name__ not in active_connectors: + active_connectors[con.__name__] = con() + + if not active_connectors[con.__name__ ].is_connected(): + refresh_connector_config(con.__name__) + try: + active_connectors[con.__name__].connect() + app.logger.info("Trying to activate connector: %s" % con.__name__) + except Exception, e: + active_connectors.pop(con.__name__) + app.logger.info("Error activating connector: %s, reason: %s" % (con.__name__, e)) + + + @app.route('/admin/') def send_admin(path): return send_from_directory('admin/ui', path) @@ -124,6 +162,7 @@ api.representations = DEFAULT_REPRESENTATIONS api.add_resource(Root, '/api') api.add_resource(Job, '/job') api.add_resource(Connector, '/connector') +api.add_resource(Info, '/info') if __name__ == '__main__': app.run(host='0.0.0.0', debug=True, ssl_context=('server.crt', 'server.key'))