|
|
|
@@ -16,7 +16,7 @@ INSERT INTO "Events" (
|
|
|
|
|
) VALUES(
|
|
|
|
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
|
|
|
|
)
|
|
|
|
|
RETURNING Eid, CloudId, Source, EventTime, ChainId, VmId, EventKey, DatacenterName, ComputeResourceName, UserName, Processed, DatacenterId, ComputeResourceId, VmName
|
|
|
|
|
RETURNING Eid, CloudId, Source, EventTime, ChainId, VmId, EventKey, DatacenterName, ComputeResourceName, UserName, Processed, DatacenterId, ComputeResourceId, VmName, EventType
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type CreateEventParams struct {
|
|
|
|
@@ -65,17 +65,18 @@ func (q *Queries) CreateEvent(ctx context.Context, arg CreateEventParams) (Event
|
|
|
|
|
&i.DatacenterId,
|
|
|
|
|
&i.ComputeResourceId,
|
|
|
|
|
&i.VmName,
|
|
|
|
|
&i.EventType,
|
|
|
|
|
)
|
|
|
|
|
return i, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const createInventory = `-- name: CreateInventory :one
|
|
|
|
|
INSERT INTO "Inventory" (
|
|
|
|
|
"Name", "Vcenter", "VmId", "EventKey", "EventId", "CreationTime", "ResourcePool", "VmType", "Datacenter", "Cluster", "Folder", "ProvisionedDisk", "InitialVcpus", "InitialRam", "SrmPlaceholder"
|
|
|
|
|
"Name", "Vcenter", "VmId", "EventKey", "EventId", "CreationTime", "ResourcePool", "VmType", "IsTemplate", "Datacenter", "Cluster", "Folder", "ProvisionedDisk", "InitialVcpus", "InitialRam", "SrmPlaceholder", "PowerState"
|
|
|
|
|
) VALUES(
|
|
|
|
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
|
|
|
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
|
|
|
|
)
|
|
|
|
|
RETURNING Iid, Name, Vcenter, VmId, EventKey, EventId, CreationTime, DeletionTime, ResourcePool, VmType, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, InitialRam, SrmPlaceholder
|
|
|
|
|
RETURNING Iid, Name, Vcenter, VmId, EventKey, EventId, CreationTime, DeletionTime, ResourcePool, VmType, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, InitialRam, SrmPlaceholder, IsTemplate, PowerState
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type CreateInventoryParams struct {
|
|
|
|
@@ -87,6 +88,7 @@ type CreateInventoryParams struct {
|
|
|
|
|
CreationTime sql.NullInt64
|
|
|
|
|
ResourcePool sql.NullString
|
|
|
|
|
VmType sql.NullString
|
|
|
|
|
IsTemplate sql.NullInt64
|
|
|
|
|
Datacenter sql.NullString
|
|
|
|
|
Cluster sql.NullString
|
|
|
|
|
Folder sql.NullString
|
|
|
|
@@ -94,6 +96,7 @@ type CreateInventoryParams struct {
|
|
|
|
|
InitialVcpus sql.NullInt64
|
|
|
|
|
InitialRam sql.NullInt64
|
|
|
|
|
SrmPlaceholder sql.NullInt64
|
|
|
|
|
PowerState sql.NullInt64
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (q *Queries) CreateInventory(ctx context.Context, arg CreateInventoryParams) (Inventory, error) {
|
|
|
|
@@ -106,6 +109,7 @@ func (q *Queries) CreateInventory(ctx context.Context, arg CreateInventoryParams
|
|
|
|
|
arg.CreationTime,
|
|
|
|
|
arg.ResourcePool,
|
|
|
|
|
arg.VmType,
|
|
|
|
|
arg.IsTemplate,
|
|
|
|
|
arg.Datacenter,
|
|
|
|
|
arg.Cluster,
|
|
|
|
|
arg.Folder,
|
|
|
|
@@ -113,6 +117,7 @@ func (q *Queries) CreateInventory(ctx context.Context, arg CreateInventoryParams
|
|
|
|
|
arg.InitialVcpus,
|
|
|
|
|
arg.InitialRam,
|
|
|
|
|
arg.SrmPlaceholder,
|
|
|
|
|
arg.PowerState,
|
|
|
|
|
)
|
|
|
|
|
var i Inventory
|
|
|
|
|
err := row.Scan(
|
|
|
|
@@ -133,6 +138,8 @@ func (q *Queries) CreateInventory(ctx context.Context, arg CreateInventoryParams
|
|
|
|
|
&i.InitialVcpus,
|
|
|
|
|
&i.InitialRam,
|
|
|
|
|
&i.SrmPlaceholder,
|
|
|
|
|
&i.IsTemplate,
|
|
|
|
|
&i.PowerState,
|
|
|
|
|
)
|
|
|
|
|
return i, err
|
|
|
|
|
}
|
|
|
|
@@ -184,7 +191,7 @@ func (q *Queries) CreateUpdate(ctx context.Context, arg CreateUpdateParams) (Upd
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getInventoryByName = `-- name: GetInventoryByName :many
|
|
|
|
|
SELECT Iid, Name, Vcenter, VmId, EventKey, EventId, CreationTime, DeletionTime, ResourcePool, VmType, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, InitialRam, SrmPlaceholder FROM "Inventory"
|
|
|
|
|
SELECT Iid, Name, Vcenter, VmId, EventKey, EventId, CreationTime, DeletionTime, ResourcePool, VmType, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, InitialRam, SrmPlaceholder, IsTemplate, PowerState FROM "Inventory"
|
|
|
|
|
WHERE "Name" = ?
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
@@ -215,6 +222,8 @@ func (q *Queries) GetInventoryByName(ctx context.Context, name string) ([]Invent
|
|
|
|
|
&i.InitialVcpus,
|
|
|
|
|
&i.InitialRam,
|
|
|
|
|
&i.SrmPlaceholder,
|
|
|
|
|
&i.IsTemplate,
|
|
|
|
|
&i.PowerState,
|
|
|
|
|
); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
@@ -230,7 +239,7 @@ func (q *Queries) GetInventoryByName(ctx context.Context, name string) ([]Invent
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getInventoryEventId = `-- name: GetInventoryEventId :one
|
|
|
|
|
SELECT Iid, Name, Vcenter, VmId, EventKey, EventId, CreationTime, DeletionTime, ResourcePool, VmType, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, InitialRam, SrmPlaceholder FROM "Inventory"
|
|
|
|
|
SELECT Iid, Name, Vcenter, VmId, EventKey, EventId, CreationTime, DeletionTime, ResourcePool, VmType, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, InitialRam, SrmPlaceholder, IsTemplate, PowerState FROM "Inventory"
|
|
|
|
|
WHERE "EventId" = ? LIMIT 1
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
@@ -255,12 +264,14 @@ func (q *Queries) GetInventoryEventId(ctx context.Context, eventid sql.NullStrin
|
|
|
|
|
&i.InitialVcpus,
|
|
|
|
|
&i.InitialRam,
|
|
|
|
|
&i.SrmPlaceholder,
|
|
|
|
|
&i.IsTemplate,
|
|
|
|
|
&i.PowerState,
|
|
|
|
|
)
|
|
|
|
|
return i, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getInventoryVmId = `-- name: GetInventoryVmId :one
|
|
|
|
|
SELECT Iid, Name, Vcenter, VmId, EventKey, EventId, CreationTime, DeletionTime, ResourcePool, VmType, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, InitialRam, SrmPlaceholder FROM "Inventory"
|
|
|
|
|
SELECT Iid, Name, Vcenter, VmId, EventKey, EventId, CreationTime, DeletionTime, ResourcePool, VmType, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, InitialRam, SrmPlaceholder, IsTemplate, PowerState FROM "Inventory"
|
|
|
|
|
WHERE "VmId" = ? LIMIT 1
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
@@ -285,12 +296,14 @@ func (q *Queries) GetInventoryVmId(ctx context.Context, vmid sql.NullString) (In
|
|
|
|
|
&i.InitialVcpus,
|
|
|
|
|
&i.InitialRam,
|
|
|
|
|
&i.SrmPlaceholder,
|
|
|
|
|
&i.IsTemplate,
|
|
|
|
|
&i.PowerState,
|
|
|
|
|
)
|
|
|
|
|
return i, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const listEvents = `-- name: ListEvents :many
|
|
|
|
|
SELECT Eid, CloudId, Source, EventTime, ChainId, VmId, EventKey, DatacenterName, ComputeResourceName, UserName, Processed, DatacenterId, ComputeResourceId, VmName FROM "Events"
|
|
|
|
|
SELECT Eid, CloudId, Source, EventTime, ChainId, VmId, EventKey, DatacenterName, ComputeResourceName, UserName, Processed, DatacenterId, ComputeResourceId, VmName, EventType FROM "Events"
|
|
|
|
|
ORDER BY "EventTime"
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
@@ -318,6 +331,7 @@ func (q *Queries) ListEvents(ctx context.Context) ([]Events, error) {
|
|
|
|
|
&i.DatacenterId,
|
|
|
|
|
&i.ComputeResourceId,
|
|
|
|
|
&i.VmName,
|
|
|
|
|
&i.EventType,
|
|
|
|
|
); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
@@ -333,7 +347,7 @@ func (q *Queries) ListEvents(ctx context.Context) ([]Events, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const listInventory = `-- name: ListInventory :many
|
|
|
|
|
SELECT Iid, Name, Vcenter, VmId, EventKey, EventId, CreationTime, DeletionTime, ResourcePool, VmType, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, InitialRam, SrmPlaceholder FROM "Inventory"
|
|
|
|
|
SELECT Iid, Name, Vcenter, VmId, EventKey, EventId, CreationTime, DeletionTime, ResourcePool, VmType, Datacenter, Cluster, Folder, ProvisionedDisk, InitialVcpus, InitialRam, SrmPlaceholder, IsTemplate, PowerState FROM "Inventory"
|
|
|
|
|
ORDER BY "Name"
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
@@ -364,6 +378,8 @@ func (q *Queries) ListInventory(ctx context.Context) ([]Inventory, error) {
|
|
|
|
|
&i.InitialVcpus,
|
|
|
|
|
&i.InitialRam,
|
|
|
|
|
&i.SrmPlaceholder,
|
|
|
|
|
&i.IsTemplate,
|
|
|
|
|
&i.PowerState,
|
|
|
|
|
); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
@@ -379,7 +395,7 @@ func (q *Queries) ListInventory(ctx context.Context) ([]Inventory, error) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const listUnprocessedEvents = `-- name: ListUnprocessedEvents :many
|
|
|
|
|
SELECT Eid, CloudId, Source, EventTime, ChainId, VmId, EventKey, DatacenterName, ComputeResourceName, UserName, Processed, DatacenterId, ComputeResourceId, VmName FROM "Events"
|
|
|
|
|
SELECT Eid, CloudId, Source, EventTime, ChainId, VmId, EventKey, DatacenterName, ComputeResourceName, UserName, Processed, DatacenterId, ComputeResourceId, VmName, EventType FROM "Events"
|
|
|
|
|
WHERE "Processed" = 0
|
|
|
|
|
ORDER BY "EventTime"
|
|
|
|
|
`
|
|
|
|
@@ -408,6 +424,7 @@ func (q *Queries) ListUnprocessedEvents(ctx context.Context) ([]Events, error) {
|
|
|
|
|
&i.DatacenterId,
|
|
|
|
|
&i.ComputeResourceId,
|
|
|
|
|
&i.VmName,
|
|
|
|
|
&i.EventType,
|
|
|
|
|
); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|