Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TC-184] Tenancy table creation #371

Closed
wants to merge 9 commits into from
Closed

[TC-184] Tenancy table creation #371

wants to merge 9 commits into from

Conversation

nir-sopher
Copy link
Contributor

This PR is the first step in adding "org tenancy" to TC. It comes to start and replace PR-322
It define the tenants table, including an "active" flag as well as "parent-tenant".
This PR is pre-requisite for adding the tenancy to the Users/CDN/DS tables

@nir-sopher nir-sopher changed the title Tenancy table creation [TC-184] Tenancy table creation Mar 15, 2017
Copy link
Member

@mitchell852 mitchell852 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it looks good. Just a few minor requests.

return $self->alert("Tenant '$name' has children tenant(s): e.g '$existing_child'. Please update these tenants and retry.");
}

#The order of the below tests is intentional - allowing UT to cover all cases - TODO(nirs) remove this comment when a full "tenancy" UT is added, including permissions and such (no use in putting effort into it yet)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just remove this part and then it will come in with your PR that adds tenant to ds?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No Problem.
Note that you'll need to be careful on the merge when the next 3 PRs are added - as the order of the tests is important for the UT, I hope to fix it later on.

#TODO(nirs) - add back when making available: return $self->alert("Tenant '$name' is assign with delivery-services(s): e.g. '$existing_ds'. Please update/delete these delivery-services and retry.");
#TODO(nirs) - add back when making available: }

#TODO(nirs) - add back when making available: my $existing_cdn = $self->db->resultset('Cdn')->search( { tenant_id => $id })->get_column('name')->first();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just remove this part and then it will come in with your PR that adds tenant to cdn?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No Problem.
Note that you'll need to be careful on the merge when the next 3 PRs are added - as the order of the tests is important for the UT, I hope to fix it later on.

#TODO(nirs) - add back when making available: return $self->alert("Tenant '$name' is assign with CDNs(s): e.g. '$existing_cdn'. Please update/delete these CDNs and retry.");
#TODO(nirs) - add back when making available: }

#TODO(nirs) - add back when making available: my $existing_user = $self->db->resultset('TmUser')->search( { tenant_id => $id })->get_column('username')->first();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just remove this part and then it will come in with your PR that adds tenant to user?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No Problem.
Note that you'll need to be careful on the merge when the next 3 PRs are added - as the order of the tests is important for the UT, I hope to fix it later on.

use Digest::SHA1 qw(sha1_hex);

my %definition_for = (
## id => 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you get rid of this comment? it's misleading.

@mitchell852
Copy link
Member

Also, you forgot one thing....documentation. I'll help you get started on that...I'll send a PR your way.


my $is_active = $params->{active};

if ( !$params->{active} && $self->isRootTenant($id)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you should just make "active" required on update. otherwise, if tenant.active=true (and not root) and I send thru no active parameter, I end up with tenant.active=false. it doesn't seem like a lot to ask of the api consumer to pass thru active=true|false...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not fully understand your point here.
The highlighted block does not come to verify that the parameter is set. It comes to block the ability to disable a "root" tenant - a change that cannot be fixed back without working directly with the DB.
I also believe "active" should be mandatory. Should I test the the params->{active} "exists"?
Nir

@mitchell852
Copy link
Member

I created a PR into your branch for the documentation - https://github.com/nir-sopher/incubator-trafficcontrol/pull/4

If it looks ok to you, just hit the merge button and my commit will be added to this PR.

@nir-sopher
Copy link
Contributor Author

Thanks Jeremy for your comments and help with documentation.
Most AIs are in.
Still need to further discuss "Active" input as required comment

@mitchell852
Copy link
Member

As far as the "active" flag being required on update, it's no big deal. either was is fine with me. i guess i was just thinking it might be confusing to a user that if I omit the active flag on an update, it would flip tenant.active back to false.

It makes sense on create - if you don't supply it, it gets its default value of false. but i'm not sure about update...

up to you.

@nir-sopher
Copy link
Contributor Author

I'll add the test, also as all other fields in the tenant module are tested upon update, so it is more consistent.

@asfgit asfgit closed this in 0bd8d4f Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants