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

Registration POST API and Synch_all implementation framework #12

Closed
wants to merge 2 commits into from
Closed

Registration POST API and Synch_all implementation framework #12

wants to merge 2 commits into from

Conversation

PravinRanjan10
Copy link
Contributor

What this PR does / why we need it:

  1. It Creates the /v1/storages ==> storage registartion
  2. implement the /v1/storages/sync_all API framework

Which issue this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged): fixes #

Special notes for your reviewer:

Release note:

@@ -11,23 +11,28 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from os_service_types import exc
Copy link
Collaborator

Choose a reason for hiding this comment

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

Where is this used?

else:
LOG.info("Stdout: {0}".format(stdout))
return stdout, stderr

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this a temporary implementation? If yes, Please mark/comment accordingly. This seems to be test placeholder

def register(self):

# the real implementation
time.sleep(1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this sleep required here?


class DeviceModel:
def __init__(self):
self.id = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

Follow python style of initialization self.id=self.name
self.description = None
:) :)

device = DeviceModel()
device.id = uuidutils.generate_uuid()
device.created_at = timeutils.utcnow()
if body.get('name'):
Copy link
Collaborator

Choose a reason for hiding this comment

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

body is dict..Now rather than going for if condition statements at multiple lines, will it be better to make it one liner as:
device.name = body.get('name', "")
So if you get the value fine, else it will assign the default which is "" here or you can keep it None



def build_storage(storage):
view = copy.deepcopy(storage)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you put comment why deepcopy is required?


driver = drivermanager.Driver()
device_info = driver.register()
if device_info.get('status') == 'available':
Copy link
Collaborator

Choose a reason for hiding this comment

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

So we are clear that the device will be registered only if the status is available and no other state (!error)?

driver = dm.Driver()
driver.list_volumes(context, request_spec)
except:
LOG.error("Volume retreival failed in driver")
Copy link
Collaborator

Choose a reason for hiding this comment

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

log the exception print_trace at debug level...Will help in future

:param req:
:return:
"""
LOG.info("Produce task, say hello ...")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hello :)
remove this line

try:
self.task_rpcapi.get_volumes(context, device)
except:
LOG.error('Volumes retreival failed!!')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
LOG.error('Volumes retreival failed!!')
LOG.error('Volumes retrieval failed!!')

@sfzeng
Copy link
Collaborator

sfzeng commented Apr 22, 2020

Is it possible to give the test example? For example, what url is used for test, and what is the supposed respone?

@PravinRanjan10
Copy link
Contributor Author

@sfzeng
1st API: http://localhost:8190/v1/storages
exampleBody : {
"storages":{
"id":"1234",
"hostname":"abvccc"
}
}

2nd API: http://localhost:8190/v1/storages/sync_all

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.

3 participants