Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def upgrade():
op.add_column('container_secret',
sa.Column('created_at', sa.DateTime(), nullable=False))
op.add_column('container_secret',
sa.Column('deleted', sa.Boolean(), nullable=False))
op.add_column('container_secret',
sa.Column('deleted_at', sa.DateTime(), nullable=True))
op.add_column('container_secret',
sa.Column('id', sa.String(length=36), nullable=False))
op.add_column('container_secret',
sa.Column('status', sa.String(length=20), nullable=False))
op.add_column('container_secret',
sa.Column('updated_at', sa.DateTime(), nullable=False))
op.create_primary_key('pk_container_secret', 'container_secret', ['id'])
op.create_unique_constraint(
'_container_secret_name_uc',
'container_secret',
['container_id', 'secret_id', 'name']
)
ondelete='cascade'),
nullable=False)
coupon_id = Column(Unicode, ForeignKey('coupons.id', ondelete='cascade'))
start_dt = Column(DateTime, nullable=False)
end_dt = Column(DateTime, nullable=False)
original_end_dt = Column(DateTime)
due_dt = Column(DateTime, nullable=False)
includes_trial = Column(Boolean)
amount_base_cents = Column(Integer, nullable=False)
amount_after_coupon_cents = Column(Integer, nullable=False)
amount_paid_cents = Column(Integer, nullable=False)
remaining_balance_cents = Column(Integer, nullable=False)
quantity = Column(
Integer, CheckConstraint('quantity >= 0'), nullable=False)
prorated = Column(Boolean)
charge_at_period_end = Column(Boolean)
charge_attempts = Column(Integer, default=0)
transaction = relationship('ChargeTransaction', backref='invoice',
cascade='delete', uselist=False)
subscription = relationship('ChargeSubscription',
backref=backref('invoices',
cascade='delete,delete-orphan',
lazy='dynamic'))
@classmethod
def create(cls, subscription, coupon, start_dt, end_dt, due_dt,
amount_base_cents, amount_after_coupon_cents, amount_paid_cents,
remaining_balance_cents, quantity, charge_at_period_end,
includes_trial=False):
invoice = cls(
def upgrade():
context = op.get_context()
op.create_table(
'router_extra_attributes',
sa.Column('router_id', sa.String(length=36), nullable=False),
sa.Column('distributed', sa.Boolean(), nullable=False,
server_default=sa.sql.false()),
sa.ForeignKeyConstraint(
['router_id'], ['routers.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('router_id')
)
if context.bind.dialect.name == 'ibm_db_sa':
# NOTE(mriedem): DB2 stores booleans as 0 and 1.
op.execute("INSERT INTO router_extra_attributes "
"SELECT id as router_id, "
"0 as distributed from routers")
else:
op.execute("INSERT INTO router_extra_attributes "
"SELECT id as router_id, "
from prkng.database import db, metadata
from sqlalchemy import Boolean, Column, Integer, String, Table
from sqlalchemy.dialects.postgresql import JSONB
from geoalchemy2 import Geometry
lots_table = Table(
'parking_lots',
metadata,
Column('id', Integer, primary_key=True),
Column('active', Boolean, default=True),
Column('partner_id', String, nullable=True),
Column('partner_name', String, nullable=True),
Column('city', String),
Column('name', String),
Column('operator', String, nullable=True),
Column('capacity', Integer, nullable=True),
Column('available', Integer, nullable=True),
Column('address', String),
Column('description', String),
Column('geom', Geometry('POINT', 3857)),
Column('geojson', JSONB),
Column('agenda', JSONB),
Column('attrs', JSONB),
Column('street_view', JSONB)
)
# TODO: instead of doing this, make a new column which is already the sum of both, and make an index on that column
Index('ix_pq_concrete_with_initial', ConcreteCurrentReservation.initialization_in_accounting, ConcreteCurrentReservation.timestamp_before, ConcreteCurrentReservation.time)
Index('ix_pq_concrete_without_initial', ConcreteCurrentReservation.initialization_in_accounting, ConcreteCurrentReservation.timestamp_after, ConcreteCurrentReservation.time)
class WaitingReservation(Base):
__tablename__ = SUFFIX + 'WaitingReservations'
__table_args__ = (UniqueConstraint('reservation_id','resource_type_id'), TABLE_KWARGS)
id = Column(Integer, primary_key=True)
resource_type_id = Column(Integer, ForeignKey('ResourceTypes.id'), index = True)
reservation_id = Column(String(RESERVATION_ID_SIZE), ForeignKey('Reservations.id'), index = True)
reservation = relation(Reservation, backref=backref('pq_waiting_reservations', order_by=id))
time = Column(Integer)
priority = Column(Integer)
initialization_in_accounting = Column(Boolean)
resource_type = relation(ResourceType, backref=backref('pq_waiting_reservations', order_by=id))
def __init__(self, resource_type, reservation_id, time, priority, initialization_in_accounting):
self.resource_type = resource_type
self.reservation_id = reservation_id
self.time = time
self.priority = priority
self.initialization_in_accounting = initialization_in_accounting
def __repr__(self):
return SUFFIX + "WaitingReservation(%r, %r, %r, %r, %r)" % (
self.resource_type,
self.reservation_id,
self.time,
self.priority,
def upgrade():
op.create_table('reminders',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('event_id', sa.Integer(), nullable=False),
sa.Column('creator_id', sa.Integer(), nullable=False, index=True),
sa.Column('created_dt', UTCDateTime, nullable=False),
sa.Column('scheduled_dt', UTCDateTime, nullable=False),
sa.Column('is_sent', sa.Boolean(), nullable=False),
sa.Column('event_start_delta', sa.Interval(), nullable=True),
sa.Column('recipients', postgresql.ARRAY(sa.String()), nullable=False),
sa.Column('send_to_participants', sa.Boolean(), nullable=False),
sa.Column('include_summary', sa.Boolean(), nullable=False),
sa.Column('reply_to_address', sa.String(), nullable=False),
sa.Column('message', sa.String(), nullable=False),
sa.ForeignKeyConstraint(['creator_id'], ['users.users.id']),
sa.PrimaryKeyConstraint('id'),
schema='events')
op.create_index(None, 'reminders', ['scheduled_dt'], schema='events', postgresql_where=sa.text('not is_sent'))
def upgrade():
### commands auto generated by Alembic - please adjust! ###
op.create_table('tax',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('country', sa.String(), nullable=True),
sa.Column('tax_name', sa.String(), nullable=False),
sa.Column('tax_rate', sa.Float(), nullable=False),
sa.Column('tax_id', sa.String(), nullable=False),
sa.Column('send_invoice', sa.Boolean(), nullable=True),
sa.Column('registered_company', sa.String(), nullable=True),
sa.Column('address', sa.String(), nullable=True),
sa.Column('city', sa.String(), nullable=True),
sa.Column('state', sa.String(), nullable=True),
sa.Column('zip', sa.Integer(), nullable=True),
sa.Column('invoice_footer', sa.String(), nullable=True),
sa.Column('tax_include_in_price', sa.Boolean(), nullable=True),
sa.Column('event_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['event_id'], ['events.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
class User(AbstractBase, UserMixin):
__tablename__ = type = "user"
id = db.Column(Integer, primary_key=True)
name = db.Column(db.SmallString, unique=True)
is_admin = db.Column(Boolean)
email = db.Column(db.SmallString)
password = db.Column(db.SmallString)
authentication = db.Column(db.SmallString)
groups = db.Column(db.List)
menu = db.Column(db.List)
pages = db.Column(db.List)
upper_menu = db.Column(db.List)
get_requests = db.Column(db.List)
post_requests = db.Column(db.List)
small_menu = db.Column(Boolean, default=False, info={"dont_track_changes": True})
theme = db.Column(
db.SmallString, default="default", info={"dont_track_changes": True}
)
groups = relationship(
"Group", secondary=db.user_group_table, back_populates="users"
)
access = relationship(
"Access", secondary=db.access_user_table, back_populates="users"
)
is_admin = db.Column(Boolean, default=False)
def add_access(self, model, instance):
for group in self.groups:
access = db.fetch("access", name=f"{group.name}: {model}", allow_none=True)
if not access:
access = db.factory("access", name=f"{group.name}: {model}")
from sqlalchemy import Boolean, Float, ForeignKey, Integer
from traceback import format_exc
from eNMS.database import db
from eNMS.forms.fields import BooleanField, HiddenField, StringField
from eNMS.forms.automation import NetmikoForm
from eNMS.models.automation import ConnectionService
class NetmikoValidationService(ConnectionService):
__tablename__ = "netmiko_validation_service"
pretty_name = "Netmiko Validation"
parent_type = "connection_service"
id = db.Column(Integer, ForeignKey("connection_service.id"), primary_key=True)
enable_mode = db.Column(Boolean, default=True)
config_mode = db.Column(Boolean, default=False)
command = db.Column(db.LargeString)
driver = db.Column(db.SmallString)
use_device_driver = db.Column(Boolean, default=True)
fast_cli = db.Column(Boolean, default=False)
timeout = db.Column(Float, default=10.0)
delay_factor = db.Column(Float, default=1.0)
global_delay_factor = db.Column(Float, default=1.0)
expect_string = db.Column(db.SmallString)
auto_find_prompt = db.Column(Boolean, default=True)
strip_prompt = db.Column(Boolean, default=True)
strip_command = db.Column(Boolean, default=True)
use_genie = db.Column(Boolean, default=False)
jump_on_connect = db.Column(Boolean, default=False)
jump_command = db.Column(db.SmallString)
jump_username = db.Column(db.SmallString)
LOG = logging.getLogger(__name__)
DEVICE_OWNER_ROUTER_INTF = l3_constants.DEVICE_OWNER_ROUTER_INTF
DEVICE_OWNER_ROUTER_GW = l3_constants.DEVICE_OWNER_ROUTER_GW
DEVICE_OWNER_FLOATINGIP = l3_constants.DEVICE_OWNER_FLOATINGIP
class Router(evs_db.EVS_DB_BASE):
"""Represents a v2 neutron router."""
id = sa.Column(sa.String(36), primary_key=True,
default=uuidutils.generate_uuid)
name = sa.Column(sa.String(255))
status = sa.Column(sa.String(16))
admin_state_up = sa.Column(sa.Boolean)
tenant_id = sa.Column(sa.String(255))
gw_port_id = sa.Column(sa.String(36))
gw_port_network_id = sa.Column(sa.String(36))
class FloatingIP(evs_db.EVS_DB_BASE):
"""Represents a floating IP address.
This IP address may or may not be allocated to a tenant, and may or
may not be associated with an internal port/ip address/router.
"""
id = sa.Column(sa.String(36), primary_key=True,
default=uuidutils.generate_uuid)
floating_ip_address = sa.Column(sa.String(64), nullable=False)
floating_network_id = sa.Column(sa.String(36), nullable=False)