Verified Commit 05710893 authored by Aleksey Shirokih's avatar Aleksey Shirokih
Browse files

Merge branch 'master' of code.getnoc.com:noc/noc

parents ebbf12f2 a0919563
......@@ -92,6 +92,14 @@ services:
condition: service_started
nsqd:
condition: service_started
telnetd:
condition: service_started
sshd:
condition: service_started
dropbear:
condition: service_started
snmpd:
condition: service_started
command: >
sh -c "set -xe
&& /usr/bin/python ./scripts/deploy/install-packages requirements/collections.json
......@@ -116,6 +124,14 @@ services:
condition: service_started
nsqd:
condition: service_started
telnetd:
condition: service_started
sshd:
condition: service_started
dropbear:
condition: service_started
snmpd:
condition: service_started
command: >
sh -c "
for i in services/*; do
......@@ -164,3 +180,19 @@ services:
redis:
image: redis:5-alpine
sshd:
image: "registry.getnoc.com/infrastructure/tests/testsshd:master"
command: /usr/sbin/sshd -D -e -4
dropbear:
image: "registry.getnoc.com/infrastructure/tests/testdropbear:master"
command: /usr/sbin/dropbear -F -E
telnetd:
image: "registry.getnoc.com/infrastructure/tests/testtelnetd:master"
command: /usr/sbin/telnetd -F
snmpd:
image: "registry.getnoc.com/infrastructure/tests/testsnmpd:master"
command: "/usr/sbin/snmpd -f -Lo: -d -a udp:161"
......@@ -11,7 +11,7 @@ check labels:
stage: lint
image: registry.getnoc.com/infrastructure/noc-lint:master
script:
- FLIST=$(git --no-pager diff --name-only $CI_COMMIT_SHA $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA))
- FLIST=$(git --no-pager diff --name-only $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) $CI_COMMIT_SHA)
- python ./scripts/check-labels.py $FLIST
only:
- merge_requests
......@@ -23,7 +23,7 @@ flake8:
image: registry.getnoc.com/infrastructure/noc-lint:master
script:
- set -x
- FLIST=$(git --no-pager diff --name-only $CI_COMMIT_SHA $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) | egrep ".py$" | grep -v ".docker/"|| true)
- FLIST=$(git --no-pager diff --name-only $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) $CI_COMMIT_SHA | egrep ".py$" | grep -v ".docker/"|| true)
- >
if [ ! -z "$FLIST" ];
then
......@@ -42,7 +42,7 @@ black:
image: registry.getnoc.com/infrastructure/black:master
script:
- set -x
- FLIST=$(git --no-pager diff --name-only $CI_COMMIT_SHA $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) | egrep ".py$" | grep -v ".docker/"|| true)
- FLIST=$(git --no-pager diff --diff-filter=d --name-only $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) $CI_COMMIT_SHA | egrep ".py$" | grep -v ".docker/"|| true)
- >
if [ ! -z "$FLIST" ];
then
......@@ -63,7 +63,7 @@ xenon:
image: registry.getnoc.com/infrastructure/noc-lint:master
script:
- set -x
- FLIST=$(git --no-pager diff --name-only $CI_COMMIT_SHA $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) | egrep ".py$" | grep -v ".docker/"|| true)
- FLIST=$(git --no-pager diff --name-only $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) $CI_COMMIT_SHA | egrep ".py$" | grep -v ".docker/"|| true)
- x=0
- >
if [ ! -z "$FLIST" ];
......@@ -85,7 +85,7 @@ pylint:
image: registry.getnoc.com/infrastructure/noc-lint:master
script:
- set -x
- FLIST=$(git --no-pager diff --name-only $CI_COMMIT_SHA $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) | egrep ".py$" | grep -v ".docker/"|| true)
- FLIST=$(git --no-pager diff --name-only $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) $CI_COMMIT_SHA | egrep ".py$" | grep -v ".docker/"|| true)
- >
if [ ! -z "$FLIST" ];
then
......@@ -99,12 +99,31 @@ pylint:
tags:
- docker
pylint3k:
stage: lint
image: registry.getnoc.com/infrastructure/noc-lint:master
script:
- set -x
- FLIST=$(git --no-pager diff --name-only $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) $CI_COMMIT_SHA | egrep ".py$" | grep -v ".docker/"|| true)
- >
if [ ! -z "$FLIST" ];
then
pylint --py3k "$FLIST";
else
echo "No files to lint"
true;
fi
only:
- merge_requests
tags:
- docker
bandit:
stage: lint
image: registry.getnoc.com/infrastructure/noc-lint:master
script:
- set -x
- FLIST=$(git --no-pager diff --name-only $CI_COMMIT_SHA $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) | egrep ".py$" | grep -v ".docker/"|| true)
- FLIST=$(git --no-pager diff --name-only $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) $CI_COMMIT_SHA | egrep ".py$" | grep -v ".docker/"|| true)
- >
if [ ! -z "$FLIST" ];
then
......@@ -119,11 +138,23 @@ bandit:
- docker
allow_failure: true
caniusepython3:
stage: lint
image: registry.getnoc.com/infrastructure/noc-lint:master
script:
- caniusepython3 -r requirements/*.txt
only:
- merge_requests
tags:
- docker
allow_failure: true
when: manual
futurize:
stage: lint
image: registry.getnoc.com/infrastructure/noc-lint:master
script:
- FLIST=$(git --no-pager diff --name-only $CI_COMMIT_SHA $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) | egrep ".py$" | grep -v ".docker/"|| true)
- FLIST=$(git --no-pager diff --name-only $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) $CI_COMMIT_SHA | egrep ".py$" | grep -v ".docker/"|| true)
- /bin/future.sh "$FLIST"
only:
- merge_requests
......@@ -134,7 +165,7 @@ futurize stage2:
stage: lint
image: registry.getnoc.com/infrastructure/noc-lint:master
script:
- FLIST=$(git --no-pager diff --name-only $CI_COMMIT_SHA $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) | egrep ".py$" | grep -v ".docker/"|| true)
- FLIST=$(git --no-pager diff --name-only $(git merge-base origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_COMMIT_SHA) $CI_COMMIT_SHA | egrep ".py$" | grep -v ".docker/"|| true)
- /bin/future2.sh "$FLIST"
only:
- merge_requests
......@@ -181,6 +212,7 @@ Test code:
before_script:
- DOCKER_COMPOSE_PROJECT=${CI_COMMIT_REF_SLUG}-${CI_JOB_ID}
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- >
docker-compose
-f .docker/docker-compose.yml
......@@ -214,6 +246,7 @@ Test python 3:
before_script:
- DOCKER_COMPOSE_PROJECT=${CI_COMMIT_REF_SLUG}-${CI_JOB_ID}
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
# see docker/docker-compose.yml for complete list of migrations
- >
docker-compose
......
......@@ -217,19 +217,19 @@ class Permission(NOCModel):
# @todo: add implied permissions
p = Permission(name=name, implied=get_implied(name))
p.save()
print ("+ %s" % name)
print("+ %s" % name)
created_perms[name] = p
# Check implied permissions match
for name in old_perms.intersection(new_perms):
implied = get_implied(name)
p = Permission.objects.get(name=name)
if p.implied != implied:
print ("~ %s" % name)
print("~ %s" % name)
p.implied = implied
p.save()
# Deleted permissions
for name in old_perms - new_perms:
print ("- %s" % name)
print("- %s" % name)
Permission.objects.get(name=name).delete()
# Diverge created permissions
for name in created_perms:
......@@ -240,7 +240,7 @@ class Permission(NOCModel):
op = Permission.get_by_name(op_name)
if not op:
continue
print (": %s -> (%s, %s)" % (op_name, op_name, name))
print(": %s -> (%s, %s)" % (op_name, op_name, name))
# Migrate users
dp = created_perms[name]
for u in op.users.all():
......
......@@ -39,4 +39,4 @@ class UserContact(NOCModel):
params = models.CharField("Params", max_length=256)
def __str__(self):
return u"%s %s %s" % (self.user.username, self.time_pattern.name, self.notification_method)
return "%s %s %s" % (self.user.username, self.time_pattern.name, self.notification_method)
......@@ -22,9 +22,9 @@ class BaseFact(object):
self.managed_object = None
def dump(self):
print ("- %s:" % self.__class__.__name__)
print("- %s:" % self.__class__.__name__)
for a in self.iter_attrs():
print (" %s: %s" % (a, getattr(self, a)))
print(" %s: %s" % (a, getattr(self, a)))
@property
def cls(self):
......
......@@ -30,9 +30,9 @@ class Error(BaseFact):
def __str__(self):
if self.obj:
return u"Error %s: %s" % (self.type, self.obj)
return "Error %s: %s" % (self.type, self.obj)
else:
return u"Error %s" % self.type
return "Error %s" % self.type
@property
def obj(self):
......
......@@ -67,7 +67,7 @@ class Interface(BaseFact):
self.aggregated_interface = aggregated_interface
def __str__(self):
return u"Interface %s" % self.name
return "Interface %s" % self.name
@property
def description(self):
......
......@@ -26,7 +26,7 @@ class NTPServer(BaseFact):
self.ip = ip
def __str__(self):
return u"NTPServer %s" % self.ip
return "NTPServer %s" % self.ip
@property
def ip(self):
......
......@@ -29,7 +29,7 @@ class Service(BaseFact):
self.port = port
def __str__(self):
return u"Service %s" % self.name
return "Service %s" % self.name
@property
def name(self):
......
......@@ -56,9 +56,9 @@ class StaticRoute(BaseFact):
def __str__(self):
if self.vrf:
return u"StaticRoute %s:%s" % (self.vrf, self.prefix)
return "StaticRoute %s:%s" % (self.vrf, self.prefix)
else:
return u"StaticRoute %s" % self.prefix
return "StaticRoute %s" % self.prefix
@property
def prefix(self):
......
......@@ -112,7 +112,7 @@ class SubInterface(BaseFact):
self.traffic_control_unicast = traffic_control_unicast
def __str__(self):
return u"SubInterface %s" % self.name
return "SubInterface %s" % self.name
@property
def description(self):
......
......@@ -26,7 +26,7 @@ class SyslogHost(BaseFact):
self.ip = ip
def __str__(self):
return u"SyslogHost %s" % self.ip
return "SyslogHost %s" % self.ip
@property
def ip(self):
......
......@@ -28,7 +28,7 @@ class User(BaseFact):
self.groups = groups
def __str__(self):
return u"User %s" % self.name
return "User %s" % self.name
@property
def name(self):
......
......@@ -27,9 +27,9 @@ class VLAN(BaseFact):
self.name = name
def __str__(self):
r = u"VLAN %d" % self.id
r = "VLAN %d" % self.id
if self.name and self.name != str(self.id):
r += u" (%s)" % self.name
r += " (%s)" % self.name
return r
@property
......
......@@ -27,7 +27,7 @@ class VRF(BaseFact):
self.rd = rd
def __str__(self):
return u"VRF %s" % self.name
return "VRF %s" % self.name
@property
def name(self):
......
......@@ -42,4 +42,4 @@ class ObjectNotify(NOCModel):
)
def __str__(self):
return u"(%s, %s, %s)" % (self.type, self.administrative_domain, self.notification_group)
return "(%s, %s, %s)" % (self.type, self.administrative_domain, self.notification_group)
......@@ -46,4 +46,4 @@ class ValidationPolicySettings(Document):
policies = ListField(EmbeddedDocumentField(ValidationPolicyItem))
def __str__(self):
return u"%s: %s" % (self.model_id, self.object_id)
return "%s: %s" % (self.model_id, self.object_id)
......@@ -43,7 +43,7 @@ class SelectorItem(EmbeddedDocument):
action = StringField(choices=ACTIONS)
def __str__(self):
return u"%s: %s" % (self.action, self.selector.name)
return "%s: %s" % (self.action, self.selector.name)
@six.python_2_unicode_compatible
......@@ -52,7 +52,7 @@ class ObjectItem(EmbeddedDocument):
action = StringField(choices=ACTIONS)
def __str__(self):
return u"%s: %s" % (self.action, self.object.name)
return "%s: %s" % (self.action, self.object.name)
@six.python_2_unicode_compatible
......
......@@ -2,7 +2,7 @@
# ---------------------------------------------------------------------
# Config parsing basevalidator
# ---------------------------------------------------------------------
# Copyright (C) 2007-2018 The NOC Project
# Copyright (C) 2007-2019 The NOC Project
# See LICENSE for details
# ---------------------------------------------------------------------
......@@ -10,7 +10,7 @@
from __future__ import absolute_import
import logging
# Django modules
# Third-party modules
from django.template import Template, Context
# NOC modules
......
......@@ -332,5 +332,5 @@ MIB = {
"AIRESPACE-SWITCHING-MIB::stpInstanceTopologyChangeTrap": "1.3.6.1.4.1.14179.1.50.11",
"AIRESPACE-SWITCHING-MIB::powerSupplyStatusChangeTrap": "1.3.6.1.4.1.14179.1.50.12",
"AIRESPACE-SWITCHING-MIB::bsnSwitchingGroups": "1.3.6.1.4.1.14179.1.51",
"AIRESPACE-SWITCHING-MIB::bsnSwitchingCompliances": "1.3.6.1.4.1.14179.1.52"
"AIRESPACE-SWITCHING-MIB::bsnSwitchingCompliances": "1.3.6.1.4.1.14179.1.52",
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment